]> granicus.if.org Git - php/commitdiff
Fixed hex char parsing
authorDmitry Stogov <dmitry@zend.com>
Wed, 30 Sep 2020 08:00:25 +0000 (11:00 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 30 Sep 2020 08:00:25 +0000 (11:00 +0300)
ext/ffi/ffi.c

index 214e71de757d48b91bf6074d0c7938fc72a6a15a..f350f91d8a3c29cd79ab7f225270fa0888dff9be 100644 (file)
@@ -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) {