]> granicus.if.org Git - php/commitdiff
A better, strtok() free implementaion of php_disable_functions().
authorIlia Alshanetsky <iliaa@php.net>
Mon, 16 Dec 2002 15:43:52 +0000 (15:43 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 16 Dec 2002 15:43:52 +0000 (15:43 +0000)
main/main.c

index 0005dd32745925a2fc53358856bd4a26d5e0bccd..9980df420f40d39926747ecb3346b84de3fd17bb 100644 (file)
@@ -168,15 +168,36 @@ static PHP_INI_MH(OnChangeMemoryLimit)
  */
 static void php_disable_functions(TSRMLS_D)
 {
-       char *func;
-       char *new_value_dup = strdup(INI_STR("disable_functions"));     /* This is an intentional leak,
-                                                                                                                                * it's not a big deal as it's process-wide
-                                                                                                                                */
-
-       func = strtok(new_value_dup, ", ");
-       while (func) {
-               zend_disable_function(func, strlen(func) TSRMLS_CC);
-               func = strtok(NULL, ", ");
+       char *s = NULL;
+       char *e = INI_STR("disable_functions");
+       char p;
+
+       if (!*e) {
+               return;
+       }
+
+       while (*e) {
+               switch (*e) {
+                       case ' ':
+                       case ',':
+                               if (s) {
+                                       p = *e;
+                                       *e = '\0';
+                                       zend_disable_function(s, e-s TSRMLS_CC);
+                                       *e = p;
+                                       s = NULL;
+                               }
+                               break;
+                       default:
+                               if (!s) {
+                                       s = e;
+                               }
+                               break;
+               }
+               e++;
+       }
+       if (s) {
+               zend_disable_function(s, e-s TSRMLS_CC);
        }
 }
 /* }}} */