com php-src: Fix memcpy null arg UB: ext/standard/http.c
| From: | Nikita Popov | Date: | Wed, 19 Jun 2019 13:09:00 +0000 |
| Subject: | com php-src: Fix memcpy null arg UB: ext/standard/http.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106898@lists.php.net to get a copy of this message | ||
Commit: 317dfab81bedd918de9cf6a9b93428a0b0f86307
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 19 Jun 2019 13:11:07 +0200
Parents: ed2a242317213e7f483b2967c2921d2bae5d1097
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=317dfab81bedd918de9cf6a9b93428a0b0f86307
Log:
Fix memcpy null arg UB
Changed paths:
M ext/standard/http.c
Diff:
diff --git a/ext/standard/http.c b/ext/standard/http.c
index 3ec6d3b..dbd71ad 100644
--- a/ext/standard/http.c
+++ b/ext/standard/http.c
@@ -130,8 +130,10 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
p += key_prefix_len;
}
- memcpy(p, num_prefix, num_prefix_len);
- p += num_prefix_len;
+ if (num_prefix) {
+ memcpy(p, num_prefix, num_prefix_len);
+ p += num_prefix_len;
+ }
memcpy(p, ekey, ekey_len);
p += ekey_len;
@@ -162,7 +164,9 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
smart_str_appendl(formstr, arg_sep, arg_sep_len);
}
/* Simple key=value */
- smart_str_appendl(formstr, key_prefix, key_prefix_len);
+ if (key_prefix) {
+ smart_str_appendl(formstr, key_prefix, key_prefix_len);
+ }
if (key) {
zend_string *ekey;
if (enc_type == PHP_QUERY_RFC3986) {
@@ -179,7 +183,9 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
}
smart_str_append_long(formstr, idx);
}
- smart_str_appendl(formstr, key_suffix, key_suffix_len);
+ if (key_suffix) {
+ smart_str_appendl(formstr, key_suffix, key_suffix_len);
+ }
smart_str_appendl(formstr, "=", 1);
switch (Z_TYPE_P(zdata)) {
case IS_STRING: {