# Patch for OnUpdateBool in zend_ini.c

- Thread: https://externals.io/message/1447
- Original archive: https://news-web.php.net/php.internals/1447
- Started by Moriyoshi Koizumi on 2003-05-12T13:27:17+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #1447 — Moriyoshi Koizumi — 2003-05-12T13:27:17+00:00

URL: https://externals.io/message/1447#1447

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

---

## #1448 — Zeev Suraski — 2003-05-12T13:35:33+00:00

URL: https://externals.io/message/1447#1448 · In reply to: #1447

At 16:27 12/05/2003, Moriyoshi Koizumi wrote:
>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.

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
