Patch for OnUpdateBool in zend_ini.c
| From: | Moriyoshi Koizumi | Date: | Mon, 12 May 2003 13:27:17 +0000 |
| Subject: | Patch for OnUpdateBool in zend_ini.c | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-1447@lists.php.net to get a copy of this message | ||
Hi,
I just found OnUpdateBool ini handler is not working properly at the
moment.
<quote>
ZEND_API ZEND_INI_MH(OnUpdateBool)
{
zend_bool *p;
#ifndef ZTS
char *base = (char *) mh_arg2;
#else
char *base;
base = (char *) ts_resource(*((int *) mh_arg2));
#endif
p = (zend_bool *) (base+(size_t) mh_arg1);
if (strncasecmp("on", new_value, sizeof("on"))) {
*p = (zend_bool) atoi(new_value);
} else {
*p = (zend_bool) 1;
}
return SUCCESS;
}
</quote>
IMO, this part
if (strncasecmp("on", new_value, sizeof("on"))) {
*p = (zend_bool) atoi(new_value);
} else {
*p = (zend_bool) 1;
}
should be
if (new_value_length == sizeof("on") -1 &&
strcasecmp("on", new_value) == 0) {
*p = (zend_bool) 1;
} else {
*p = (zend_bool) atoi(new_value);
}
Otherwise you can set the corresponding entry to 1 if you specify
a single letter "o" for it.
The patch is attached.
Moriyoshi
Index: Zend/zend_ini.c =================================================================== RCS file: /repository/ZendEngine2/zend_ini.c,v retrieving revision 1.30 diff -u -r1.30 zend_ini.c --- Zend/zend_ini.c 24 Mar 2003 14:53:30 -0000 1.30 +++ Zend/zend_ini.c 12 May 2003 13:23:03 -0000 @@ -431,10 +431,10 @@ p = (zend_bool *) (base+(size_t) mh_arg1); - if (strncasecmp("on", new_value, sizeof("on"))) { - *p = (zend_bool) atoi(new_value); + if (new_value_length == sizeof("on") - 1 && strcasecmp("on", new_value) == 0) { + *p = (zend_bool) 1; } else { - *p = (zend_bool) 1; + *p = (zend_bool) atoi(new_value); } return SUCCESS; }
Index: Zend/zend_ini.c =================================================================== RCS file: /repository/ZendEngine2/zend_ini.c,v retrieving revision 1.30 diff -u -r1.30 zend_ini.c --- Zend/zend_ini.c 24 Mar 2003 14:53:30 -0000 1.30 +++ Zend/zend_ini.c 12 May 2003 13:23:03 -0000 @@ -431,10 +431,10 @@ p = (zend_bool *) (base+(size_t) mh_arg1); - if (strncasecmp("on", new_value, sizeof("on"))) { - *p = (zend_bool) atoi(new_value); + if (new_value_length == sizeof("on") - 1 && strcasecmp("on", new_value) == 0) { + *p = (zend_bool) 1; } else { - *p = (zend_bool) 1; + *p = (zend_bool) atoi(new_value); } return SUCCESS; }