-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix GH-13142: Undefined variable name is shortened when contains \0 #13200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c006610
b02076f
beb4670
fd98afa
07ed57a
3163b43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--TEST-- | ||
GH-13142 (Undefined variable name is shortened when contains \0) | ||
--FILE-- | ||
<?php | ||
|
||
$a = "test\0test"; | ||
$$a; | ||
$a = "\0test"; | ||
$$a; | ||
$a = "test\0"; | ||
$$a; | ||
|
||
compact("a\0b"); | ||
compact("\0ab"); | ||
compact("ab\0"); | ||
|
||
?> | ||
--EXPECTF-- | ||
Warning: Undefined variable $test%0test in %s on line %d | ||
|
||
Warning: Undefined variable $%0test in %s on line %d | ||
|
||
Warning: Undefined variable $test%0 in %s on line %d | ||
|
||
Warning: compact(): Undefined variable $a%0b in %s on line %d | ||
|
||
Warning: compact(): Undefined variable $%0ab in %s on line %d | ||
|
||
Warning: compact(): Undefined variable $ab%0 in %s on line %d |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1597,26 +1597,22 @@ ZEND_API ZEND_COLD void zend_error_at( | |
va_end(args); | ||
} | ||
|
||
ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) { | ||
zend_string *filename; | ||
uint32_t lineno; | ||
va_list args; | ||
#define zend_error_impl(type, format) do { \ | ||
zend_string *filename; \ | ||
uint32_t lineno; \ | ||
va_list args; \ | ||
get_filename_lineno(type, &filename, &lineno); \ | ||
va_start(args, format); \ | ||
zend_error_va_list(type, filename, lineno, format, args); \ | ||
va_end(args); \ | ||
} while (0) | ||
|
||
get_filename_lineno(type, &filename, &lineno); | ||
va_start(args, format); | ||
zend_error_va_list(type, filename, lineno, format, args); | ||
va_end(args); | ||
ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) { | ||
zend_error_impl(type, format); | ||
} | ||
|
||
ZEND_API ZEND_COLD void zend_error_unchecked(int type, const char *format, ...) { | ||
zend_string *filename; | ||
uint32_t lineno; | ||
va_list args; | ||
|
||
get_filename_lineno(type, &filename, &lineno); | ||
va_start(args, format); | ||
zend_error_va_list(type, filename, lineno, format, args); | ||
va_end(args); | ||
zend_error_impl(type, format); | ||
} | ||
|
||
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_at_noreturn( | ||
|
@@ -1636,18 +1632,26 @@ ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_at_noreturn( | |
abort(); | ||
} | ||
|
||
#define zend_error_noreturn_impl(type, format) do { \ | ||
zend_string *filename; \ | ||
uint32_t lineno; \ | ||
va_list args; \ | ||
get_filename_lineno(type, &filename, &lineno); \ | ||
va_start(args, format); \ | ||
zend_error_va_list(type, filename, lineno, format, args); \ | ||
va_end(args); \ | ||
/* Should never reach this. */ \ | ||
abort(); \ | ||
} while (0) | ||
|
||
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...) | ||
{ | ||
zend_string *filename; | ||
uint32_t lineno; | ||
va_list args; | ||
zend_error_noreturn_impl(type, format); | ||
} | ||
|
||
get_filename_lineno(type, &filename, &lineno); | ||
va_start(args, format); | ||
zend_error_va_list(type, filename, lineno, format, args); | ||
va_end(args); | ||
/* Should never reach this. */ | ||
abort(); | ||
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn_unchecked(int type, const char *format, ...) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the point of this function, it is 1:1 as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The format attribute There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, |
||
{ | ||
zend_error_noreturn_impl(type, format); | ||
} | ||
|
||
ZEND_API ZEND_COLD ZEND_NORETURN void zend_strerror_noreturn(int type, int errn, const char *message) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better if there were also tests in the case of
\0test
andtest\0