Skip to content

Commit 0067c3c

Browse files
committed
Fix lexing of zero octal followed by whitespace
We'd call strtol starting at the whitespace, and strtol strips whitespace... Fixes oss-fuzz #29272.
1 parent ed4f18b commit 0067c3c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Zend/tests/oct_whitespace.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
Octal literal followed by whitespace and another number
3+
--FILE--
4+
<?php
5+
var_dump(0o0 2);
6+
?>
7+
--EXPECTF--
8+
Parse error: syntax error, unexpected integer "2", expecting ")" in %s on line %d

Zend/zend_language_scanner.l

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,11 @@ NEWLINE ("\r"|"\n"|"\r\n")
19631963
--len;
19641964
}
19651965

1966+
if (len == 0) {
1967+
ZVAL_LONG(zendlval, 0);
1968+
RETURN_TOKEN_WITH_VAL(T_LNUMBER);
1969+
}
1970+
19661971
if (contains_underscores) {
19671972
octal = estrndup(octal, len);
19681973
strip_underscores(octal, &len);

0 commit comments

Comments
 (0)