dns: check there is room in answer packet#24
Conversation
`dns_packet_record_add` will return `NULL` if there is not enough room in the packet. This needs to be check to avoid crashes. Signed-off-by: Matthew Cather <mattbob4@gmail.com>
|
need to take a closer look but at first glance we have broken packet accumulation logic that causes unnecessary buffer exhaustion thus causing a failed NULL check |
|
Makes sense. I can see this patch being a band-aid on an underlying issue. I have a handful of these crashes most of them are all the same code path as above ^^^. I do have a small amounts of similar crashes that look like this: |
|
I dug into this bug a little bit more. Using the coredump to dump the current packet, it looks like the packet accumulation logic is fine. It was just caused by appearing to exhaust the buffer. The packet was ~900 bytes long. This is the effective max size since Line 110 in 2f75344 Somehow the interface got assigned 30+ IPv6 addresses. That many addresses hit the effective max size on the buffer and caused We could lower the length assumption to something smaller to avoid the crash but adding a |
I came across some crashes on some of my systems that looks like this:
I am no able to recreate the issue on demand. Looking through the code, I would guess the crash is caused by
dns_packet_answernot checking if there is enough room in the packet (causing us to de-referenceNULL).This patch changes the code to do this patch and skip adding an answer if there is not enough room.