Skip to content

Conversation

@rlubos
Copy link
Contributor

@rlubos rlubos commented Nov 19, 2025

As the loop unpacking the DNS name from records checks the current
label length on each iteration, it's also needed to update the remaining
buffer length on each iteration, otherwise the buffer length checks
doesn't work as expected.

Additionally, the remaining buffer checks while technically worked, they
were conceptually wrong and unintuitive. The buf->data pointer doesn't
move, so comparing against this pointer when adding new labels doesn't
make sense. It's more intuitive to simply compare the label size vs
the remaining buffer space.

Fixes #99682

As the loop unpacking the DNS name from records checks the current
label length on each iteration, it's also needed to update the remaining
buffer length on each iteration, otherwise the buffer length checks
doesn't work as expected.

Additionally, the remaining buffer checks while technically worked, they
were conceptually wrong and unintuitive. The buf->data pointer doesn't
move, so comparing against this pointer when adding new labels doesn't
make sense. It's more intuitive to simply compare the label size vs
the remaining buffer space.

Signed-off-by: Robert Lubos <[email protected]>
Verify that dns_unpack_name() generates a valid DNS name when unpacking
records and that it returns an error in case of overflow.

Signed-off-by: Robert Lubos <[email protected]>
@rlubos rlubos added backport v3.7-branch Request backport to the v3.7-branch backport v4.2-branch Request backport to the v4.2-branch backport v4.3-branch Request backport to the v4.3-branch labels Nov 19, 2025
@zephyrbot zephyrbot added area: Networking area: Tests Issues related to a particular existing or missing test labels Nov 19, 2025
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Networking area: Tests Issues related to a particular existing or missing test backport v3.7-branch Request backport to the v3.7-branch backport v4.2-branch Request backport to the v4.2-branch backport v4.3-branch Request backport to the v4.3-branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

net: lib: dns: Unpacking query name can overflow the destination buffer

4 participants