Stefan Esser pointed out that the following commit fixes a heap-based buffer overflow in DNS TXT record parsing:
https://github.com/php/php-src/commit/b34d7849ed90ced9345f8ea1c59bc8d101c18468
A malicious server or man-in-the-middle attacker could possibly use this flaw to execute arbitrary code as the PHP interpreter if a PHP application uses dns_get_record() to perform a DNS query.
Can a CVE please be assigned if one has not been already?
(Red Hat bug with no further details: https://bugzilla.redhat.com/show_bug.cgi?id=1108447)
ext/standard/dns.c
@@ -517,6 +517,10 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
while (ll < dlen) {
n = cp[ll];
+ if ((ll + n) >= dlen) {
+ // Invalid chunk length, truncate
+ n = dlen - (ll + 1);
+ }
memcpy(tp + ll , cp + ll + 1, n);
add_next_index_stringl(entries, cp + ll + 1, n, 1);
ll = ll + n + 1;