com php-src: Fix potential segfault in dns_get_record() : ext/standard/dns.c

From: Date: Wed, 25 Jun 2014 09:45:15 +0000
Subject: com php-src: Fix potential segfault in dns_get_record() : ext/standard/dns.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-79074@lists.php.net to get a copy of this message
Commit: 038baca3a1f0676a8062b04a2923ef6630c3e41c Author: Sara Golemon <pollita@php.net> Tue, 10 Jun 2014 11:18:02 -0700 Committer: Julien Pauli <jpauli@php.net> Wed, 25 Jun 2014 11:45:15 +0200 Parents: 33f5d7853145fff91cbfbab38588293d8765cecd Branches: PHP-5.5.14 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=038baca3a1f0676a8062b04a2923ef6630c3e41c Log: Fix potential segfault in dns_get_record() If the remote sends us a packet with a malformed TXT record, we could end up trying to over-consume the packet and wander off into overruns. Changed paths: M ext/standard/dns.c Diff: diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 6a89446..214a7dc 100644 --- a/ext/standard/dns.c +++ b/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;

« previous php.cvs (#79074) next »