Skip to content

Commit fcbe737

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #81400: Unterminated string in dns_get_record() results
2 parents e94731f + edab9ad commit fcbe737

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PHP NEWS
1818

1919
- Standard:
2020
. Fixed bug #71542 (disk_total_space does not work with relative paths). (cmb)
21+
. Fixed bug #81400 (Unterminated string in dns_get_record() results). (cmb)
2122

2223
- SysVMsg:
2324
. Fixed bug #78819 (Heap Overflow in msg_send). (cmb)

ext/standard/dns_win32.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,18 @@ static void php_parserr(PDNS_RECORD pRec, int type_to_fetch, int store, int raw,
220220
array_init(&entries);
221221

222222
for (i = 0; i < count; i++) {
223-
txt_len += strlen(data_txt->pStringArray[i]) + 1;
223+
txt_len += strlen(data_txt->pStringArray[i]);
224224
}
225225

226-
txt = zend_string_safe_alloc(txt_len, 2, 0, 0);
227-
txt_dst = txt->val;
226+
txt = zend_string_alloc(txt_len, 0);
227+
txt_dst = ZSTR_VAL(txt);
228228
for (i = 0; i < count; i++) {
229229
size_t len = strlen(data_txt->pStringArray[i]);
230230
memcpy(txt_dst, data_txt->pStringArray[i], len);
231231
add_next_index_stringl(&entries, data_txt->pStringArray[i], len);
232232
txt_dst += len;
233233
}
234-
txt->len = txt_dst - txt->val;
234+
*txt_dst = '\0';
235235
add_assoc_str(subarray, "txt", txt);
236236
add_assoc_zval(subarray, "entries", &entries);
237237
}

0 commit comments

Comments
 (0)