From: Dmitry Stogov Date: Wed, 30 Sep 2020 08:00:25 +0000 (+0300) Subject: Fixed hex char parsing X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=583093844e421d27c52a06a57c13efc6f5b8918b;p=php Fixed hex char parsing --- diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 214e71de75..f350f91d8a 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -7445,7 +7445,7 @@ void zend_ffi_val_character(zend_ffi_val *val, const char *str, size_t str_len) val->kind = ZEND_FFI_VAL_ERROR; } } else if (str[2] == 'x') { - if (str[3] >= '0' && str[3] <= '7') { + if (str[3] >= '0' && str[3] <= '9') { n = str[3] - '0'; } else if (str[3] >= 'A' && str[3] <= 'F') { n = str[3] - 'A'; @@ -7453,8 +7453,9 @@ void zend_ffi_val_character(zend_ffi_val *val, const char *str, size_t str_len) n = str[3] - 'a'; } else { val->kind = ZEND_FFI_VAL_ERROR; + return; } - if ((str[4] >= '0' && str[4] <= '7') && str_len == 6) { + if ((str[4] >= '0' && str[4] <= '9') && str_len == 6) { n = n * 16 + (str[4] - '0'); } else if ((str[4] >= 'A' && str[4] <= 'F') && str_len == 6) { n = n * 16 + (str[4] - 'A'); @@ -7462,6 +7463,7 @@ void zend_ffi_val_character(zend_ffi_val *val, const char *str, size_t str_len) n = n * 16 + (str[4] - 'a'); } else if (str_len != 5) { val->kind = ZEND_FFI_VAL_ERROR; + return; } val->ch = n; } else if (str_len == 4) {