Skip to content

Fix GH-25968: dns_get_record() reads A record bytes past a short RDATA - #25984

Open
lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-25968
Open

lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-25968

Conversation

@lazerg

@lazerg lazerg commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

For an A record, php_parserr() only checked that 4 bytes were left in the whole message, not in the record itself. With an RDLENGTH below 4, the missing bytes came from the next record, so dns_get_record() returned a made-up address like 9.192.12.0. A short A record is now treated as malformed, the same way other bad RDATA already goes to fail.

CHECKCP(dlen) already runs before the switch, so dlen >= 4 also keeps the read inside the message. I checked it with the reporter's fake DNS server: the bogus record is gone and well-formed replies are unchanged. No .phpt, since the BIND server used by the DNS tests won't serve an A record with short RDATA.

Fixes #25968

@lazerg
lazerg requested a review from bukka as a code owner December 1, 2026 01:40
@lazerg lazerg changed the title [PHP-8.4] Fix GH-25968: dns_get_record() reads A record bytes past a short RDATA Fix GH-25968: dns_get_record() reads A record bytes past a short RDATA Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant