]> granicus.if.org Git - php/commitdiff
Allow zend_parse_parameters to handle non-well formed integers, but raise
authorIlia Alshanetsky <iliaa@php.net>
Thu, 17 Nov 2005 00:19:23 +0000 (00:19 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 17 Nov 2005 00:19:23 +0000 (00:19 +0000)
E_NOTICE in the process.

Zend/zend_API.c
Zend/zend_operators.h

index 5aa684b4c85f6353afee4e21aa17ae01dd3325dd..af70c3dd485009ccd972542d9e7f16a78072ecd1 100644 (file)
@@ -296,7 +296,7 @@ static char *zend_parse_arg_impl(zval **arg, va_list *va, char **spec TSRMLS_DC)
                                                        double d;
                                                        int type;
 
-                                                       if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), p, &d, 0)) == 0) {
+                                                       if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), p, &d, -1)) == 0) {
                                                                return "long";
                                                        } else if (type == IS_DOUBLE) {
                                                                *p = (long) d;
@@ -330,7 +330,7 @@ static char *zend_parse_arg_impl(zval **arg, va_list *va, char **spec TSRMLS_DC)
                                                        long l;
                                                        int type;
 
-                                                       if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &l, p, 0)) == 0) {
+                                                       if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &l, p, -1)) == 0) {
                                                                return "double";
                                                        } else if (type == IS_LONG) {
                                                                *p = (double) l;
index 0f1f23e4695981f650fa37361f7fb9e98832cf55..fa7f304f103280fff4aba3f7942a0dd80ddb8f70 100644 (file)
@@ -65,7 +65,7 @@ ZEND_API zend_bool instanceof_function_ex(zend_class_entry *instance_ce, zend_cl
 ZEND_API zend_bool instanceof_function(zend_class_entry *instance_ce, zend_class_entry *ce TSRMLS_DC);
 END_EXTERN_C()
 
-static inline zend_bool is_numeric_string(char *str, int length, long *lval, double *dval, zend_bool allow_errors)
+static inline zend_bool is_numeric_string(char *str, int length, long *lval, double *dval, int allow_errors)
 {
        long local_lval;
        double local_dval;
@@ -116,16 +116,21 @@ static inline zend_bool is_numeric_string(char *str, int length, long *lval, dou
        } else {
                end_ptr_double=NULL;
        }
-       if (allow_errors) {
-               if (end_ptr_double>end_ptr_long && dval) {
-                       *dval = local_dval;
-                       return IS_DOUBLE;
-               } else if (end_ptr_long && lval) {
-                       *lval = local_lval;
-                       return IS_LONG;
-               }
+
+       if (!allow_errors) {
+               return 0;
+       }
+       if (allow_errors == -1) {
+               zend_error(E_NOTICE, "A non well formed numeric value encountered");
+       }
+
+       if (end_ptr_double>end_ptr_long && dval) {
+               *dval = local_dval;
+               return IS_DOUBLE;
+       } else if (end_ptr_long && lval) {
+               *lval = local_lval;
+               return IS_LONG;
        }
-       return 0;
 }
 
 static inline char *