From: Marcus Boerger Date: Tue, 6 Feb 2007 22:41:39 +0000 (+0000) Subject: - Avoid direct tsrm manipulating in ini setting X-Git-Tag: RELEASE_1_0_1~316 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f11f4875db8586b07a4d5ee2fca216234115dfb;p=php - Avoid direct tsrm manipulating in ini setting --- diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 95571a8173..2a053f4822 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -28,49 +28,43 @@ ZEND_DECLARE_MODULE_GLOBALS(phar) otherwise, only allow 1 (enabled), and error on disabling */ ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */ { - zend_bool *p, test; -#ifndef ZTS - char *base = (char *) mh_arg2; -#else - char *base; - - base = (char *) ts_resource(*((int *) mh_arg2)); -#endif + zend_bool old, ini; - p = (zend_bool *) (base+(size_t) mh_arg1); + if (entry->name_length == 14) { + old = PHAR_G(readonly_orig); + } else { + old = PHAR_G(require_hash_orig); + } - if (new_value_length==2 && strcasecmp("on", new_value)==0) { - *p = (zend_bool) 1; + if (new_value_length == 2 && !strcasecmp("on", new_value)) { + ini = (zend_bool) 1; } - else if (new_value_length==3 && strcasecmp("yes", new_value)==0) { - *p = (zend_bool) 1; + else if (new_value_length == 3 && !strcasecmp("yes", new_value)) { + ini = (zend_bool) 1; } - else if (new_value_length==4 && strcasecmp("true", new_value)==0) { - *p = (zend_bool) 1; + else if (new_value_length == 4 && !strcasecmp("true", new_value)) { + ini = (zend_bool) 1; } else { - *p = (zend_bool) atoi(new_value); - } - if (stage == ZEND_INI_STAGE_STARTUP && !entry->modified) { - /* this is more efficient than processing orig_value every time */ - if (entry->name_length == 14) { /* phar.readonly */ - PHAR_G(readonly_orig) = *p; - } else { /* phar.require_hash */ - PHAR_G(require_hash_orig) = *p; - } + ini = (zend_bool) atoi(new_value); } - if (stage != ZEND_INI_STAGE_STARTUP) { - if (entry->name_length == 14) { /* phar.readonly */ - test = PHAR_G(readonly_orig); - } else { /* phar.require_hash */ - test = PHAR_G(require_hash_orig); + + /* do not allow unsetting in runtime */ + if (stage == ZEND_INI_STAGE_STARTUP) { + if (entry->name_length == 14) { + PHAR_G(readonly_orig) = ini; + } else { + PHAR_G(require_hash_orig) = ini; } - if (test && !*p) { - /* do not allow unsetting in runtime */ - *p = (zend_bool) 1; - return FAILURE; - } + } else if (old && !ini) { + return FAILURE; } + + if (entry->name_length == 14) { + PHAR_G(readonly) = ini; + } else { + PHAR_G(require_hash) = ini; + } return SUCCESS; } /* }}}*/