Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Fix #81400: Unterminated string in dns_get_record() results
This commit is contained in:
Christoph M. Becker 2021-08-30 18:52:22 +02:00
commit fcbe737218
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
2 changed files with 5 additions and 4 deletions

1
NEWS
View file

@ -18,6 +18,7 @@ PHP NEWS
- Standard: - Standard:
. Fixed bug #71542 (disk_total_space does not work with relative paths). (cmb) . Fixed bug #71542 (disk_total_space does not work with relative paths). (cmb)
. Fixed bug #81400 (Unterminated string in dns_get_record() results). (cmb)
- SysVMsg: - SysVMsg:
. Fixed bug #78819 (Heap Overflow in msg_send). (cmb) . Fixed bug #78819 (Heap Overflow in msg_send). (cmb)

View file

@ -220,18 +220,18 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
array_init(&entries); array_init(&entries);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
txt_len += strlen(data_txt->pStringArray[i]) + 1; txt_len += strlen(data_txt->pStringArray[i]);
} }
txt = zend_string_safe_alloc(txt_len, 2, 0, 0); txt = zend_string_alloc(txt_len, 0);
txt_dst = txt->val; txt_dst = ZSTR_VAL(txt);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
size_t len = strlen(data_txt->pStringArray[i]); size_t len = strlen(data_txt->pStringArray[i]);
memcpy(txt_dst, data_txt->pStringArray[i], len); memcpy(txt_dst, data_txt->pStringArray[i], len);
add_next_index_stringl(&entries, data_txt->pStringArray[i], len); add_next_index_stringl(&entries, data_txt->pStringArray[i], len);
txt_dst += len; txt_dst += len;
} }
txt->len = txt_dst - txt->val; *txt_dst = '\0';
add_assoc_str(subarray, "txt", txt); add_assoc_str(subarray, "txt", txt);
add_assoc_zval(subarray, "entries", &entries); add_assoc_zval(subarray, "entries", &entries);
} }