chiark / gitweb /
DNS packet parsing: Slight fix when packet is truncated
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 8 Dec 2016 18:58:40 +0000 (18:58 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 26 May 2020 19:23:40 +0000 (20:23 +0100)
commitd4b6031596d2b42d44ca120db72178d8a86fb658
tree881ccc762360d2f15616b5a5b137ec3a6ca20848
parentccf05d0f258c7f158b0436f11137702ee78d4ddb
DNS packet parsing: Slight fix when packet is truncated

If the packet is truncated, adns__findrr_anychk returns adns_s_ok,
setting *type_r to -1.  It does not guarantee to set the other
outputs.

So, in pap_findaddrs, check for this first, rather than perhaps
reading the uninitialised `ownermatched' value.

And in adns__procdgram check the type before checking the (technically
in this case undefined) class.

In practice there is no bug in actual compiled code, because in both
call sites another test will DTRT.  I don't think contemporary
compilers spot and exploit this bug for "optimisation".

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/reply.c
src/types.c