diff options
author | Sara Golemon <pollita@php.net> | 2014-06-10 11:18:02 -0700 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2014-06-13 16:42:55 -0700 |
commit | d400b74296989afadddc960db5ad103bf61e51d0 (patch) | |
tree | 9772ff4727c12fd6f9a5a731c7ffdf01adafcb9f | |
parent | 08334293f8883c2bcbb74ed10b8133672fee8706 (diff) | |
download | php-git-d400b74296989afadddc960db5ad103bf61e51d0.tar.gz |
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.
-rw-r--r-- | ext/standard/dns.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 8e24a817ff..67ea459ea2 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -507,6 +507,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; |