]> granicus.if.org Git - php/commitdiff
Check if given string is long enough in zend_*_strtod
authorDavid Soria Parra <dsp@php.net>
Wed, 27 Jul 2011 14:17:45 +0000 (14:17 +0000)
committerDavid Soria Parra <dsp@php.net>
Wed, 27 Jul 2011 14:17:45 +0000 (14:17 +0000)
Zend/zend_strtod.c

index 3f41f85a28c0ae63ac69f0e4dc3ce7e2bfdfc262..c43587eef30bb733f122d13896ad1afda55c3ebe 100644 (file)
@@ -2585,6 +2585,11 @@ ZEND_API double zend_hex_strtod(const char *str, const char **endptr)
        int any = 0;
        double value = 0;
 
+       if (strlen(str) < 2) {
+               *endptr = str;
+               return 0.0;
+       }
+
        if (*s == '0' && (s[1] == 'x' || s[1] == 'X')) {
                s += 2;
        }
@@ -2618,6 +2623,11 @@ ZEND_API double zend_oct_strtod(const char *str, const char **endptr)
        double value = 0;
        int any = 0;
 
+       if (strlen(str) < 1) {
+               *endptr = str;
+               return 0.0;
+       }
+
        /* skip leading zero */
        s++;
 
@@ -2646,6 +2656,11 @@ ZEND_API double zend_bin_strtod(const char *str, const char **endptr)
        double          value = 0;
        int             any = 0;
 
+       if (strlen(str) < 2) {
+               *endptr = str;
+               return 0.0;
+       }
+
        if ('0' == *s && ('b' == s[1] || 'B' == s[1])) {
                s += 2;
        }