]> granicus.if.org Git - php/commitdiff
- Avoid direct tsrm manipulating in ini setting
authorMarcus Boerger <helly@php.net>
Tue, 6 Feb 2007 22:41:39 +0000 (22:41 +0000)
committerMarcus Boerger <helly@php.net>
Tue, 6 Feb 2007 22:41:39 +0000 (22:41 +0000)
ext/phar/phar.c

index 95571a8173e5e5f1ca8d6079a984f3e3366af732..2a053f4822d1b0baa6837ca2b2d1b636fc0b40cf 100644 (file)
@@ -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;
 }
 /* }}}*/