mattwil         Fri Jun  5 18:50:32 2009 UTC

  Modified files:              (Branch: PHP_5_3)
    /ZendEngine2        zend_builtin_functions.c zend_execute.h 
                        zend_execute_API.c 
    /php-src/ext/interbase      php_ibase_udf.c 
    /php-src/ext/mbstring       php_mbregex.c 
    /php-src/ext/pcre   php_pcre.c 
    /php-src/ext/standard       assert.c 
    /php-src/sapi/cli   php_cli.c 
  Log:
  MFH: Added zend_eval_stringl and made create_function(), etc. binary-safe
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.277.2.12.2.25.2.49&r2=1.277.2.12.2.25.2.50&diff_format=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.49 
ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.50
--- ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.49   Fri May 22 
11:19:30 2009
+++ ZendEngine2/zend_builtin_functions.c        Fri Jun  5 18:50:31 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.c,v 1.277.2.12.2.25.2.49 2009/05/22 11:19:30 
lbarnaud Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.277.2.12.2.25.2.50 2009/06/05 18:50:31 
mattwil Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -1673,7 +1673,7 @@
 ZEND_FUNCTION(create_function)
 {
        char *eval_code, *function_name, *function_args, *function_code;
-       int function_name_length, function_args_len, function_code_len;
+       int eval_code_length, function_name_length, function_args_len, 
function_code_len;
        int retval;
        char *eval_name;
 
@@ -1681,10 +1681,29 @@
                return;
        }
 
-       zend_spprintf(&eval_code, 0, "function " LAMBDA_TEMP_FUNCNAME 
"(%s){%s}", function_args, function_code);
+       eval_code = (char *) emalloc(sizeof("function " LAMBDA_TEMP_FUNCNAME)
+                       +function_args_len
+                       +2      /* for the args parentheses */
+                       +2      /* for the curly braces */
+                       +function_code_len);
+
+       eval_code_length = sizeof("function " LAMBDA_TEMP_FUNCNAME "(") - 1;
+       memcpy(eval_code, "function " LAMBDA_TEMP_FUNCNAME "(", 
eval_code_length);
+
+       memcpy(eval_code + eval_code_length, function_args, function_args_len);
+       eval_code_length += function_args_len;
+
+       eval_code[eval_code_length++] = ')';
+       eval_code[eval_code_length++] = '{';
+
+       memcpy(eval_code + eval_code_length, function_code, function_code_len);
+       eval_code_length += function_code_len;
+
+       eval_code[eval_code_length++] = '}';
+       eval_code[eval_code_length] = '\0';
 
        eval_name = zend_make_compiled_string_description("runtime-created 
function" TSRMLS_CC);
-       retval = zend_eval_string(eval_code, NULL, eval_name TSRMLS_CC);
+       retval = zend_eval_stringl(eval_code, eval_code_length, NULL, eval_name 
TSRMLS_CC);
        efree(eval_code);
        efree(eval_name);
 
@@ -1699,10 +1718,10 @@
                function_add_ref(&new_function);
 
                function_name = (char *) 
emalloc(sizeof("0lambda_")+MAX_LENGTH_OF_LONG);
+               function_name[0] = '\0';
 
                do {
-                       sprintf(function_name, "%clambda_%d", 0, 
++EG(lambda_count));
-                       function_name_length = strlen(function_name+1)+1;
+                       function_name_length = 1 + sprintf(function_name + 1, 
"lambda_%d", ++EG(lambda_count));
                } while (zend_hash_add(EG(function_table), function_name, 
function_name_length+1, &new_function, sizeof(zend_function), NULL)==FAILURE);
                zend_hash_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, 
sizeof(LAMBDA_TEMP_FUNCNAME));
                RETURN_STRINGL(function_name, function_name_length, 0);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute.h?r1=1.84.2.4.2.8.2.13&r2=1.84.2.4.2.8.2.14&diff_format=u
Index: ZendEngine2/zend_execute.h
diff -u ZendEngine2/zend_execute.h:1.84.2.4.2.8.2.13 
ZendEngine2/zend_execute.h:1.84.2.4.2.8.2.14
--- ZendEngine2/zend_execute.h:1.84.2.4.2.8.2.13        Fri Jun  5 11:21:31 2009
+++ ZendEngine2/zend_execute.h  Fri Jun  5 18:50:32 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute.h,v 1.84.2.4.2.8.2.13 2009/06/05 11:21:31 lbarnaud Exp $ 
*/
+/* $Id: zend_execute.h,v 1.84.2.4.2.8.2.14 2009/06/05 18:50:32 mattwil Exp $ */
 
 #ifndef ZEND_EXECUTE_H
 #define ZEND_EXECUTE_H
@@ -73,7 +73,9 @@
 ZEND_API int zend_lookup_class(const char *name, int name_length, 
zend_class_entry ***ce TSRMLS_DC);
 ZEND_API int zend_lookup_class_ex(const char *name, int name_length, int 
use_autoload, zend_class_entry ***ce TSRMLS_DC);
 ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name 
TSRMLS_DC);
+ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char 
*string_name TSRMLS_DC);
 ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char 
*string_name, int handle_exceptions TSRMLS_DC);
+ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, 
char *string_name, int handle_exceptions TSRMLS_DC);
 
 static inline int i_zend_is_true(zval *op)
 {
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.331.2.20.2.24.2.77&r2=1.331.2.20.2.24.2.78&diff_format=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.77 
ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.78
--- ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.77 Thu Jun  4 18:20:42 2009
+++ ZendEngine2/zend_execute_API.c      Fri Jun  5 18:50:32 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.77 2009/06/04 18:20:42 mattwil 
Exp $ */
+/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.78 2009/06/05 18:50:32 mattwil 
Exp $ */
 
 #include <stdio.h>
 #include <signal.h>
@@ -1116,7 +1116,7 @@
 }
 /* }}} */
 
-ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name 
TSRMLS_DC) /* {{{ */
+ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char 
*string_name TSRMLS_DC) /* {{{ */
 {
        zval pv;
        zend_op_array *new_op_array;
@@ -1125,15 +1125,14 @@
        int retval;
 
        if (retval_ptr) {
-               int l = strlen(str);
-               Z_STRLEN(pv) = l + sizeof("return ;") - 1;
+               Z_STRLEN(pv) = str_len + sizeof("return ;") - 1;
                Z_STRVAL(pv) = emalloc(Z_STRLEN(pv) + 1);
                memcpy(Z_STRVAL(pv), "return ", sizeof("return ") - 1);
-               memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, str, l);
+               memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, str, str_len);
                Z_STRVAL(pv)[Z_STRLEN(pv) - 1] = ';';
                Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0';
        } else {
-               Z_STRLEN(pv) = strlen(str);
+               Z_STRLEN(pv) = str_len;
                Z_STRVAL(pv) = str;
        }
        Z_TYPE(pv) = IS_STRING;
@@ -1188,11 +1187,17 @@
 }
 /* }}} */
 
-ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char 
*string_name, int handle_exceptions TSRMLS_DC) /* {{{ */
+ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name 
TSRMLS_DC) /* {{{ */
+{
+       return zend_eval_stringl(str, strlen(str), retval_ptr, string_name 
TSRMLS_CC);
+}
+/* }}} */
+
+ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, 
char *string_name, int handle_exceptions TSRMLS_DC) /* {{{ */
 {
        int result;
 
-       result = zend_eval_string(str, retval_ptr, string_name TSRMLS_CC);
+       result = zend_eval_stringl(str, str_len, retval_ptr, string_name 
TSRMLS_CC);
        if (handle_exceptions && EG(exception)) {
                zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
                result = FAILURE;
@@ -1201,6 +1206,12 @@
 }
 /* }}} */
 
+ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char 
*string_name, int handle_exceptions TSRMLS_DC) /* {{{ */
+{
+       return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, 
handle_exceptions TSRMLS_CC);
+}
+/* }}} */
+
 void execute_new_code(TSRMLS_D) /* {{{ */
 {
        zend_op *opline, *end;
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/php_ibase_udf.c?r1=1.9.2.1.2.2.2.3&r2=1.9.2.1.2.2.2.4&diff_format=u
Index: php-src/ext/interbase/php_ibase_udf.c
diff -u php-src/ext/interbase/php_ibase_udf.c:1.9.2.1.2.2.2.3 
php-src/ext/interbase/php_ibase_udf.c:1.9.2.1.2.2.2.4
--- php-src/ext/interbase/php_ibase_udf.c:1.9.2.1.2.2.2.3       Wed Dec 31 
11:15:38 2008
+++ php-src/ext/interbase/php_ibase_udf.c       Fri Jun  5 18:50:32 2009
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_ibase_udf.c,v 1.9.2.1.2.2.2.3 2008/12/31 11:15:38 sebastian Exp $ 
*/
+/* $Id: php_ibase_udf.c,v 1.9.2.1.2.2.2.4 2009/06/05 18:50:32 mattwil Exp $ */
 
 /**
 * This UDF library adds the ability to call PHP functions from SQL
@@ -165,7 +165,7 @@
 #endif
                        /* feed it to the parser */
                        zend_first_try {
-                               result = zend_eval_string(code, NULL, "Firebird 
Embedded PHP engine" TSRMLS_CC);
+                               result = zend_eval_stringl(code, 
b->blob_total_length, NULL, "Firebird Embedded PHP engine" TSRMLS_CC);
                        } zend_end_try();
        }
        
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/php_mbregex.c?r1=1.53.2.1.2.4.2.13&r2=1.53.2.1.2.4.2.14&diff_format=u
Index: php-src/ext/mbstring/php_mbregex.c
diff -u php-src/ext/mbstring/php_mbregex.c:1.53.2.1.2.4.2.13 
php-src/ext/mbstring/php_mbregex.c:1.53.2.1.2.4.2.14
--- php-src/ext/mbstring/php_mbregex.c:1.53.2.1.2.4.2.13        Wed Dec 31 
11:15:38 2008
+++ php-src/ext/mbstring/php_mbregex.c  Fri Jun  5 18:50:32 2009
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_mbregex.c,v 1.53.2.1.2.4.2.13 2008/12/31 11:15:38 sebastian Exp $ 
*/
+/* $Id: php_mbregex.c,v 1.53.2.1.2.4.2.14 2009/06/05 18:50:32 mattwil Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -914,9 +914,9 @@
                        if (eval) {
                                zval v;
                                /* null terminate buffer */
-                               smart_str_appendc(&eval_buf, '\0');
+                               smart_str_0(&eval_buf);
                                /* do eval */
-                               if (zend_eval_string(eval_buf.c, &v, 
description TSRMLS_CC) == FAILURE) {
+                               if (zend_eval_stringl(eval_buf.c, eval_buf.len, 
&v, description TSRMLS_CC) == FAILURE) {
                                        efree(description);
                                        php_error_docref(NULL 
TSRMLS_CC,E_ERROR, "Failed evaluating code: %s%s", PHP_EOL, eval_buf.c);
                                        /* zend_error() does not return in this 
case */
http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/php_pcre.c?r1=1.168.2.9.2.21.2.31&r2=1.168.2.9.2.21.2.32&diff_format=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.168.2.9.2.21.2.31 
php-src/ext/pcre/php_pcre.c:1.168.2.9.2.21.2.32
--- php-src/ext/pcre/php_pcre.c:1.168.2.9.2.21.2.31     Fri Apr 10 15:47:15 2009
+++ php-src/ext/pcre/php_pcre.c Fri Jun  5 18:50:32 2009
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcre.c,v 1.168.2.9.2.21.2.31 2009/04/10 15:47:15 nlopess Exp $ */
+/* $Id: php_pcre.c,v 1.168.2.9.2.21.2.32 2009/06/05 18:50:32 mattwil Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -913,7 +913,7 @@
 
        compiled_string_description = 
zend_make_compiled_string_description("regexp code" TSRMLS_CC);
        /* Run the code */
-       if (zend_eval_string(code.c, &retval, compiled_string_description 
TSRMLS_CC) == FAILURE) {
+       if (zend_eval_stringl(code.c, code.len, &retval, 
compiled_string_description TSRMLS_CC) == FAILURE) {
                efree(compiled_string_description);
                php_error_docref(NULL TSRMLS_CC,E_ERROR, "Failed evaluating 
code: %s%s", PHP_EOL, code.c);
                /* zend_error() does not return in this case */
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/assert.c?r1=1.60.2.3.2.6.2.5&r2=1.60.2.3.2.6.2.6&diff_format=u
Index: php-src/ext/standard/assert.c
diff -u php-src/ext/standard/assert.c:1.60.2.3.2.6.2.5 
php-src/ext/standard/assert.c:1.60.2.3.2.6.2.6
--- php-src/ext/standard/assert.c:1.60.2.3.2.6.2.5      Wed Dec 31 11:15:44 2008
+++ php-src/ext/standard/assert.c       Fri Jun  5 18:50:32 2009
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: assert.c,v 1.60.2.3.2.6.2.5 2008/12/31 11:15:44 sebastian Exp $ */
+/* $Id: assert.c,v 1.60.2.3.2.6.2.6 2009/06/05 18:50:32 mattwil Exp $ */
 
 /* {{{ includes */
 #include "php.h"
@@ -164,7 +164,7 @@
                }
 
                compiled_string_description = 
zend_make_compiled_string_description("assert code" TSRMLS_CC);
-               if (zend_eval_string(myeval, &retval, 
compiled_string_description TSRMLS_CC) == FAILURE) {
+               if (zend_eval_stringl(myeval, Z_STRLEN_PP(assertion), &retval, 
compiled_string_description TSRMLS_CC) == FAILURE) {
                        efree(compiled_string_description);
                        php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, 
"Failure evaluating code: %s%s", PHP_EOL, myeval);
                        if (ASSERTG(bail)) {
http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php_cli.c?r1=1.129.2.13.2.22.2.25&r2=1.129.2.13.2.22.2.26&diff_format=u
Index: php-src/sapi/cli/php_cli.c
diff -u php-src/sapi/cli/php_cli.c:1.129.2.13.2.22.2.25 
php-src/sapi/cli/php_cli.c:1.129.2.13.2.22.2.26
--- php-src/sapi/cli/php_cli.c:1.129.2.13.2.22.2.25     Thu Apr  9 10:20:02 2009
+++ php-src/sapi/cli/php_cli.c  Fri Jun  5 18:50:32 2009
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_cli.c,v 1.129.2.13.2.22.2.25 2009/04/09 10:20:02 bjori Exp $ */
+/* $Id: php_cli.c,v 1.129.2.13.2.22.2.26 2009/06/05 18:50:32 mattwil Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -1165,7 +1165,7 @@
                                                continue;
                                        }
 
-                                       zend_eval_string(code, NULL, "php shell 
code" TSRMLS_CC);
+                                       zend_eval_stringl(code, pos, NULL, "php 
shell code" TSRMLS_CC);
                                        pos = 0;
                                        
                                        if (php_last_char != '\0' && 
php_last_char != '\n') {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to