com php-src: Improve white-space handling: ext/ffi/ffi.c
| From: | Dmitry Stogov | Date: | Tue, 19 Mar 2019 10:52:55 +0000 |
| Subject: | com php-src: Improve white-space handling: ext/ffi/ffi.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105241@lists.php.net to get a copy of this message | ||
Commit: defd421c0f605a29de2edf3b903a9bf2607b940d
Author: Dmitry Stogov <dmitry@zend.com> Tue, 19 Mar 2019 13:52:55 +0300
Parents: f2438a57ff3b8667f538f8a29a0c492b192c0d2b
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=defd421c0f605a29de2edf3b903a9bf2607b940d
Log:
Improve white-space handling
Changed paths:
M ext/ffi/ffi.c
Diff:
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c
index 1885c63..0b4a319 100644
--- a/ext/ffi/ffi.c
+++ b/ext/ffi/ffi.c
@@ -4292,7 +4292,22 @@ static char *zend_ffi_parse_directives(const char *filename, char *code_pos,
cha
*scope_name = NULL;
*lib = NULL;
while (*code_pos == '#') {
- if (strncmp(code_pos, "#define FFI_SCOPE \"", sizeof("#define FFI_SCOPE
\"") - 1) == 0) {
+ if (strncmp(code_pos, "#define FFI_SCOPE", sizeof("#define FFI_SCOPE") - 1)
== 0
+ && (code_pos[sizeof("#define FFI_SCOPE") - 1] == ' '
+ || code_pos[sizeof("#define FFI_SCOPE") - 1] == '\t')) {
+ p = code_pos + sizeof("#define FFI_SCOPE");
+ while (*p == ' ' || *p == '\t') {
+ p++;
+ }
+ if (*p != '"') {
+ if (preload) {
+ zend_error(E_WARNING, "FFI: failed pre-loading '%s', bad FFI_SCOPE
define", filename);
+ } else {
+ zend_throw_error(zend_ffi_exception_ce, "Failed loading '%s', bad FFI_SCOPE
define", filename);
+ }
+ return NULL;
+ }
+ p++;
if (*scope_name) {
if (preload) {
zend_error(E_WARNING, "FFI: failed pre-loading '%s', FFI_SCOPE defined
twice", filename);
@@ -4301,7 +4316,7 @@ static char *zend_ffi_parse_directives(const char *filename, char *code_pos,
cha
}
return NULL;
}
- *scope_name = p = code_pos + sizeof("#define FFI_SCOPE \"") - 1;
+ *scope_name = p;
while (1) {
if (*p == '\"') {
*p = 0;
@@ -4324,7 +4339,22 @@ static char *zend_ffi_parse_directives(const char *filename, char *code_pos,
cha
p++;
}
code_pos = p;
- } else if (strncmp(code_pos, "#define FFI_LIB \"", sizeof("#define FFI_LIB
\"") - 1) == 0) {
+ } else if (strncmp(code_pos, "#define FFI_LIB", sizeof("#define FFI_LIB") -
1) == 0
+ && (code_pos[sizeof("#define FFI_LIB") - 1] == ' '
+ || code_pos[sizeof("#define FFI_LIB") - 1] == '\t')) {
+ p = code_pos + sizeof("#define FFI_LIB");
+ while (*p == ' ' || *p == '\t') {
+ p++;
+ }
+ if (*p != '"') {
+ if (preload) {
+ zend_error(E_WARNING, "FFI: failed pre-loading '%s', bad FFI_LIB define",
filename);
+ } else {
+ zend_throw_error(zend_ffi_exception_ce, "Failed loading '%s', bad FFI_LIB
define", filename);
+ }
+ return NULL;
+ }
+ p++;
if (*lib) {
if (preload) {
zend_error(E_WARNING, "FFI: failed pre-loading '%s', FFI_LIB defined
twice", filename);
@@ -4333,7 +4363,7 @@ static char *zend_ffi_parse_directives(const char *filename, char *code_pos,
cha
}
return NULL;
}
- *lib = p = code_pos + sizeof("#define FFI_LIB \"") - 1;
+ *lib = p;
while (1) {
if (*p == '\"') {
*p = 0;