]> granicus.if.org Git - php/commitdiff
Add check in fgetcsv in case sizeof(unit) != sizeof(size_t)
authorStanislav Malyshev <stas@php.net>
Mon, 12 Sep 2016 03:58:55 +0000 (20:58 -0700)
committerStanislav Malyshev <stas@php.net>
Tue, 13 Sep 2016 04:04:23 +0000 (21:04 -0700)
ext/standard/file.c

index 440276ab6e9284d0fd2b2eff2b2f7e487bbc06bc..067f9614eb8c5fdc011e8b5abbec946997368a8f 100644 (file)
@@ -2301,6 +2301,10 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char
 
                /* 3. Now pass our field back to php */
                *comp_end = '\0';
+               if (UNEXPECTED((comp_end - temp) > INT_MAX)) {
+                       zend_error_noreturn(E_WARNING, "String overflow, max size is %d", INT_MAX);
+                       break;
+               }
                add_next_index_stringl(return_value, temp, comp_end - temp, 1);
        } while (inc_len > 0);