summaryrefslogtreecommitdiff
path: root/ext/mysqlnd/mysqlnd_ps.c
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2010-10-06 11:11:02 +0000
committerAndrey Hristov <andrey@php.net>2010-10-06 11:11:02 +0000
commit4f62c099cd6b0f8dcea939e6527447909ff39341 (patch)
tree17c476610eae9424e165f0c7af762cd8c838fa63 /ext/mysqlnd/mysqlnd_ps.c
parent1cca9d4bf1f089902ffffd6bf3d88bfc1fbd213c (diff)
downloadphp-git-4f62c099cd6b0f8dcea939e6527447909ff39341.tar.gz
Fix for Bug #52686 mysql_stmt_attr_[gs]et arg. points to incorrect type
Diffstat (limited to 'ext/mysqlnd/mysqlnd_ps.c')
-rw-r--r--ext/mysqlnd/mysqlnd_ps.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c
index 70bcef9e38..cecce5ec43 100644
--- a/ext/mysqlnd/mysqlnd_ps.c
+++ b/ext/mysqlnd/mysqlnd_ps.c
@@ -1827,39 +1827,42 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_set)(MYSQLND_STMT * const s,
const void * const value TSRMLS_DC)
{
MYSQLND_STMT_DATA * stmt = s? s->data:NULL;
- unsigned long val = *(unsigned long *) value;
DBG_ENTER("mysqlnd_stmt::attr_set");
if (!stmt) {
DBG_RETURN(FAIL);
}
- DBG_INF_FMT("stmt=%lu attr_type=%u value=%lu", stmt->stmt_id, attr_type, val);
+ DBG_INF_FMT("stmt=%lu attr_type=%u", stmt->stmt_id, attr_type);
switch (attr_type) {
- case STMT_ATTR_UPDATE_MAX_LENGTH:
+ case STMT_ATTR_UPDATE_MAX_LENGTH:{
+ zend_uchar bval = *(zend_uchar *) value;
/*
XXX : libmysql uses my_bool, but mysqli uses ulong as storage on the stack
and mysqlnd won't be used out of the scope of PHP -> use ulong.
*/
- stmt->update_max_length = val? TRUE:FALSE;
+ stmt->update_max_length = bval? TRUE:FALSE;
break;
+ }
case STMT_ATTR_CURSOR_TYPE: {
- if (val > (unsigned long) CURSOR_TYPE_READ_ONLY) {
+ unsigned int ival = *(unsigned int *) value;
+ if (ival > (unsigned long) CURSOR_TYPE_READ_ONLY) {
SET_STMT_ERROR(stmt, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
DBG_INF("FAIL");
DBG_RETURN(FAIL);
}
- stmt->flags = val;
+ stmt->flags = ival;
break;
}
case STMT_ATTR_PREFETCH_ROWS: {
- if (val == 0) {
- val = MYSQLND_DEFAULT_PREFETCH_ROWS;
- } else if (val > 1) {
+ unsigned int ival = *(unsigned int *) value;
+ if (ival == 0) {
+ ival = MYSQLND_DEFAULT_PREFETCH_ROWS;
+ } else if (ival > 1) {
SET_STMT_ERROR(stmt, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
DBG_INF("FAIL");
DBG_RETURN(FAIL);
}
- stmt->prefetch_rows = val;
+ stmt->prefetch_rows = ival;
break;
}
default: