fix(mdns): Fix null pointer exception in mdns_parse_packet (IDFGH-17353)#1025
Open
scaiper wants to merge 1 commit intoespressif:masterfrom
Open
fix(mdns): Fix null pointer exception in mdns_parse_packet (IDFGH-17353)#1025scaiper wants to merge 1 commit intoespressif:masterfrom
scaiper wants to merge 1 commit intoespressif:masterfrom
Conversation
david-cermak
approved these changes
Mar 13, 2026
Collaborator
david-cermak
left a comment
There was a problem hiding this comment.
Hi @scaiper
Thank you for your contribution!
I briefly checked and it seems to be possible that the question list is NULL while nr of questions is non zero in the packet header (and even with valid packets!).
thanks again for the fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a null pointer exception in mdns component.
In
mdns_parse_packetfunction there is a call toremove_parsed_questionwhich might getparsed_packetwith the NULLquestionsfield.https://github.com/espressif/esp-protocols/blob/mdns-v1.10.1/components/mdns/mdns_receive.c#L860
There is the log of the crash. Backtrace points to the neighboring call, probably, due to compiler optimizations.
Related
All of my esphome devices running esp32 started crashing with this error after I updated my routers to OpenWrt 25.12.
I don't know, are mdns packets causing this issue valid or not. Regardless, mdns componets should not just crash.
Testing
Checklist
Before submitting a Pull Request, please ensure the following:
Note
Low Risk
Low risk: adds a simple NULL check to avoid dereferencing an empty questions list during mDNS packet parsing, with no behavioral change when questions are present.
Overview
Prevents a crash in
mdns_parse_packetby makingremove_parsed_questionreturn early whenparsed_packet->questionsisNULL, avoiding a null dereference inquestion_matchesfor packets that produce no saved questions.Written by Cursor Bugbot for commit 5681209. This will update automatically on new commits. Configure here.