andrey Tue Sep 16 14:34:11 2008 UTC
Modified files:
/php-src/ext/mysqlnd mysqlnd_statistics.h mysqlnd_wireprotocol.c
Log:
Fix a crash introduced yesterday in mysqlnd, non-zts mode - missing if () for
STAT_LAST was accessing wrong memory thus overwritting method pointers.
Windows doesn't have atoll(), which is C99, C89 has only atoi() + atol().
Win has _atoi64, so use it.
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_statistics.h?r1=1.9&r2=1.10&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_statistics.h
diff -u php-src/ext/mysqlnd/mysqlnd_statistics.h:1.9
php-src/ext/mysqlnd/mysqlnd_statistics.h:1.10
--- php-src/ext/mysqlnd/mysqlnd_statistics.h:1.9 Fri Sep 12 15:06:55 2008
+++ php-src/ext/mysqlnd/mysqlnd_statistics.h Tue Sep 16 14:34:11 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mysqlnd_statistics.h,v 1.9 2008/09/12 15:06:55 andrey Exp $ */
+/* $Id: mysqlnd_statistics.h,v 1.10 2008/09/16 14:34:11 andrey Exp $ */
#ifndef MYSQLND_STATISTICS_H
#define MYSQLND_STATISTICS_H
@@ -62,9 +62,9 @@
#define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2,
value2) \
{ \
if (MYSQLND_G(collect_statistics)) { \
- DBG_INF_FMT("Global stat increase [%s] [%s]",
mysqlnd_stats_values_names[statistic1],
mysqlnd_stats_values_names[statistic2]); \
uint64 v1 = (uint64) (value1); \
uint64 v2 = (uint64) (value2); \
+ DBG_INF_FMT("Global stat increase [%s] [%s]",
mysqlnd_stats_values_names[statistic1],
mysqlnd_stats_values_names[statistic2]); \
\
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
if (statistic1 != STAT_LAST)
mysqlnd_global_stats->values[(statistic1)]+= v1; \
@@ -111,8 +111,8 @@
if (statistic2 != STAT_LAST)
mysqlnd_global_stats->values[(statistic2)]+= v2; \
tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
if ((conn_stats)) { \
- ((MYSQLND_STATS *) conn_stats)->values[(statistic1)]+=
v1; \
- ((MYSQLND_STATS *) conn_stats)->values[(statistic2)]+=
v2; \
+ if (statistic1 != STAT_LAST) ((MYSQLND_STATS *)
conn_stats)->values[(statistic1)]+= v1; \
+ if (statistic2 != STAT_LAST) ((MYSQLND_STATS *)
conn_stats)->values[(statistic2)]+= v2; \
} \
} \
}
@@ -164,9 +164,9 @@
#define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2,
value2) \
{ \
if (MYSQLND_G(collect_statistics)) { \
- DBG_INF_FMT("Global stat increase [%s] [%s]",
mysqlnd_stats_values_names[statistic1],
mysqlnd_stats_values_names[statistic2]); \
uint64 v1 = (uint64) (value1); \
uint64 v2 = (uint64) (value2); \
+ DBG_INF_FMT("Global stat increase [%s] [%s]",
mysqlnd_stats_values_names[statistic1],
mysqlnd_stats_values_names[statistic2]); \
\
if (statistic1 != STAT_LAST)
mysqlnd_global_stats->values[(statistic1)]+= v1; \
if (statistic2 != STAT_LAST)
mysqlnd_global_stats->values[(statistic2)]+= v2; \
@@ -205,8 +205,8 @@
if (statistic1 != STAT_LAST)
mysqlnd_global_stats->values[(statistic1)]+= v1; \
if (statistic2 != STAT_LAST)
mysqlnd_global_stats->values[(statistic2)]+= v2; \
if ((conn_stats)) { \
- ((MYSQLND_STATS *) conn_stats)->values[(statistic1)]+=
v1; \
- ((MYSQLND_STATS *) conn_stats)->values[(statistic2)]+=
v2; \
+ if (statistic1 != STAT_LAST) ((MYSQLND_STATS *)
conn_stats)->values[(statistic1)]+= v1; \
+ if (statistic2 != STAT_LAST) ((MYSQLND_STATS *)
conn_stats)->values[(statistic2)]+= v2; \
} \
} \
}
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_wireprotocol.c?r1=1.21&r2=1.22&diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_wireprotocol.c
diff -u php-src/ext/mysqlnd/mysqlnd_wireprotocol.c:1.21
php-src/ext/mysqlnd/mysqlnd_wireprotocol.c:1.22
--- php-src/ext/mysqlnd/mysqlnd_wireprotocol.c:1.21 Mon Sep 15 18:07:58 2008
+++ php-src/ext/mysqlnd/mysqlnd_wireprotocol.c Tue Sep 16 14:34:11 2008
@@ -1560,10 +1560,20 @@
if (perm_bind.pack_len < SIZEOF_LONG)
{
/* direct conversion */
- int64 v = atoll((char *) p);
+ int64 v =
+#ifndef PHP_WIN32
+ atoll((char *) p);
+#else
+ _atoi64((char *) p);
+#endif
ZVAL_LONG(*current_field, v);
} else {
- uint64 v = (uint64) atoll((char *) p);
+ uint64 v =
+#ifndef PHP_WIN32
+ (uint64) atoll((char *) p);
+#else
+ (uint64) _atoi64((char *) p);
+#endif
zend_bool uns =
fields_metadata[i].flags & UNSIGNED_FLAG? TRUE:FALSE;
/* We have to make it ASCIIZ
temporarily */
#if SIZEOF_LONG==8
@@ -1580,13 +1590,11 @@
}
}
*(p + len) = save;
- } else if (as_int_or_float && perm_bind.php_type ==
IS_DOUBLE)
- {
+ } else if (as_int_or_float && perm_bind.php_type ==
IS_DOUBLE) {
zend_uchar save = *(p + len);
/* We have to make it ASCIIZ temporarily */
*(p + len) = '\0';
- double v = atof((char *) p);
- ZVAL_DOUBLE(*current_field, v);
+ ZVAL_DOUBLE(*current_field, atof((char *) p));
*(p + len) = save;
} else
#endif /* MYSQLND_STRING_TO_INT_CONVERSION */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php