summaryrefslogtreecommitdiff
path: root/Zend/zend_language_scanner.l
diff options
context:
space:
mode:
authorNuno Lopes <nlopess@php.net>2008-04-04 15:01:23 +0000
committerNuno Lopes <nlopess@php.net>2008-04-04 15:01:23 +0000
commitbfcdbbcd33a3011aa9bc681433017999a2ce5fe7 (patch)
tree3d9084f147d7d52de6a1c2cc4358df8c8baea48b /Zend/zend_language_scanner.l
parentc3474b91163118f69d24d2859d7c3ff07460e992 (diff)
downloadphp-git-bfcdbbcd33a3011aa9bc681433017999a2ce5fe7.tar.gz
add sanity checks for ZEND_MMAP_AHEAD and reduce the value from 32 to 16 (lowest safe value)
Diffstat (limited to 'Zend/zend_language_scanner.l')
-rw-r--r--Zend/zend_language_scanner.l11
1 files changed, 9 insertions, 2 deletions
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index be2be3694c..182538dc1f 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -66,6 +66,13 @@
#define yyless(x) YYCURSOR = yytext + x
#define yymore() goto yymore_restart
+/* perform sanity check. If this message is triggered you should
+ increase the ZEND_MMAP_AHEAD value in the zend_streams.h file */
+/*!max:re2c */
+#if ZEND_MMAP_AHEAD < YYMAXFILL
+# error ZEND_MMAP_AHEAD should be greater than or equal to YYMAXFILL
+#endif
+
#ifdef HAVE_STDARG_H
# include <stdarg.h>
#endif
@@ -356,9 +363,9 @@ zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename TSRMLS_DC)
{
/* enforce two trailing NULLs for flex... */
- STR_REALLOC(str->value.str.val, str->value.str.len+2);
+ str->value.str.val = safe_erealloc(str->value.str.val, 1, str->value.str.len, ZEND_MMAP_AHEAD);
- str->value.str.val[str->value.str.len+1]=0;
+ memset(str->value.str.val + str->value.str.len, 0, ZEND_MMAP_AHEAD);
SCNG(yy_in)=NULL;