unread
Hi,
I just found OnUpdateBool ini handler is not working properly at the
moment.
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
unread
At 16:27 12/05/2003, Moriyoshi Koizumi wrote:
Hi,
I just found OnUpdateBool ini handler is not working properly at the
<quote> ZEND_API ZEND_INI_MH(OnUpdateBool) { zend_bool *p; #ifndef ZTS char *base = (char *) mh_arg2; #else char *base;
moment.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.
Why? Does strncasecmp("on", "o", 2) return 0 on your system?
Either way, I can't think of any reason not to simply replace strncasecmp
with strcasecmp. The lengths should be identical either way.
Zeev