1
0
mirror of https://github.com/php/php-src.git synced 2026-04-20 06:21:12 +02:00

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.
This commit is contained in:
Sara Golemon
2014-06-10 11:18:02 -07:00
committed by Stanislav Malyshev
parent 08334293f8
commit d400b74296

View File

@@ -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;