From f4d34bb28eca3397fca507104c7fb96087c8e90d Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Mon, 3 Nov 2008 11:39:34 +0000 Subject: [PATCH] - MFH: Fixed bug #42855 (dns_get_record() doesn't return all text from TXT record) patch by: a dot u dot savchuk at gmail dot com --- NEWS | 2 ++ ext/standard/dns.c | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index bd51b89e245..f30ff3e6560 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,8 @@ PHP NEWS - Fixed bug #43452 (strings containing a weekday, or a number plus weekday behaved incorrect of the current day-of-week was the same as the one in the phrase).(Derick) +- Fixed bug #42855 (dns_get_record() doesn't return all text from TXT record). + (a dot u dot savchuk at gmail dot com) - Fixed bug #42718 (FILTER_UNSAFE_RAW not applied when configured as default filter). (Arnaud) - Fixed bug #42294 (Unified solution for round() based on C99 round). (Ilia) diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 35ec37ced6f..d2bc8529e4a 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -472,14 +472,23 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int add_assoc_stringl(*subarray, "os", cp, n, 1); cp += n; break; - case DNS_T_TXT: - add_assoc_string(*subarray, "type", "TXT", 1); - n = cp[0]; - tp = emalloc(n + 1); - memcpy(tp, cp + 1, n); - tp[n] = '\0'; - cp += dlen; - add_assoc_stringl(*subarray, "txt", tp, n, 0); + case DNS_T_TXT: + { + int ll = 0; + + add_assoc_string(*subarray, "type", "TXT", 1); + tp = emalloc(dlen + 1); + + while (ll < dlen) { + n = cp[ll]; + memcpy(tp + ll , cp + ll + 1, n); + ll = ll + n + 1; + } + tp[dlen] = '\0'; + cp += dlen; + + add_assoc_stringl(*subarray, "txt", tp, dlen, 0); + } break; case DNS_T_SOA: add_assoc_string(*subarray, "type", "SOA", 1);