Skip to content

Commit 24fe7f0

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #81400: Unterminated string in dns_get_record() results
2 parents f1f4403 + fcbe737 commit 24fe7f0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/standard/dns_win32.c

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

223223
for (i = 0; i < count; i++) {
224-
txt_len += strlen(data_txt->pStringArray[i]) + 1;
224+
txt_len += strlen(data_txt->pStringArray[i]);
225225
}
226226

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

0 commit comments

Comments
 (0)