com php-src: Fix potential segfault in dns_get_record() : NEWS ext/standard/dns.c
| From: | Stanislav Malyshev | Date: | Sun, 15 Jun 2014 08:04:24 +0000 |
| Subject: | com php-src: Fix potential segfault in dns_get_record() : NEWS ext/standard/dns.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-79045@lists.php.net to get a copy of this message | ||
Commit: 21525d041369484d49781b34a8333a78798806e4
Author: Sara Golemon <pollita@php.net> Tue, 10 Jun 2014 11:18:02 -0700
Committer: Stanislav Malyshev <stas@php.net> Sun, 15 Jun 2014 01:04:24 -0700
Parents: 2b04d689724bdfd5db9351c017566e2f51d61568
Branches: PHP-5.4 PHP-5..4.30 PHP-5.5
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=21525d041369484d49781b34a8333a78798806e4
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 NEWS
M ext/standard/dns.c
Diff:
diff --git a/NEWS b/NEWS
index f0367a8..a5eaabc 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,10 @@ PHP NEWS
. Fixed bug #67413 (fileinfo: cdf_read_property_info insufficient boundary
check). (Francisco Alonso, Jan Kaluza, Remi)
+- Network:
+ . Fixed bug #67432 (Fix potential segfault in dns_get_record()).
+ (CVE-2014-4049). (Sara)
+
- OpenSSL:
. Fixed bug #65698 (certificates validity parsing does not work past 2050).
(Paul Oehler)
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;