Skip to content

Commit b34d784

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: Fix potential segfault in dns_get_record()
2 parents ec974c4 + e2ef56f commit b34d784

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: ext/standard/dns.c

+4
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
517517

518518
while (ll < dlen) {
519519
n = cp[ll];
520+
if ((ll + n) >= dlen) {
521+
// Invalid chunk length, truncate
522+
n = dlen - (ll + 1);
523+
}
520524
memcpy(tp + ll , cp + ll + 1, n);
521525
add_next_index_stringl(entries, cp + ll + 1, n, 1);
522526
ll = ll + n + 1;

0 commit comments

Comments
 (0)