RFC: libnetfilter_queue: nfq_udp_get_payload_len() gives wrong answer
nfq_udp_get_payload() correctly returns a pointer to the first data byte in a UDP message, e.g. to "A" in the message "ASD\n".
BUT nfq_udp_get_payload_len() returns 12 for the length of the above message, i.e. combined lengths of payload and UDP header.
I plan to do an update of the documentation in src/extra/udp.c so I can document this behaviour then.
OR
Should I change the behaviour of nfq_udp_get_payload_len() to what one would expect? (e.g. return 4 in the example above)
OR
Should there be a new function, say nfq_udp_get_payload_len2(), to give the expected answer?
AND, should the new or updated function guard against returning a -ve result? (which, being unsigned, would become a large +ve result)
Any opinions?
Cheers ... Duncan.
Pablo Neira Ayuso
maintainerOn Sun, Dec 08, 2019 at 02:49:30PM +1100, Duncan Roe wrote:
[...]
Quoted 2 lines
Should I change the behaviour of
nfq_udp_get_payload_len()to what one would expect? (e.g. return 4 in the example above)
This option, just fix it, please.
Thanks.
PATCH 1/1 src: Fix value returned by nfq_udp_get_payload_len()
Updated:
src/extra/udp.c: Remember to subtract the UDP header length
--- src/extra/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/extra/udp.c +1 -1
@@ -78,7 +78,7 @@ void *nfq_udp_get_payload(struct udphdr *udph, struct pkt_buff *pktb)EXPORT_SYMBOL unsigned int nfq_udp_get_payload_len(struct udphdr *udph, struct pkt_buff *pktb) { -return pktb->tail - pktb->transport_header; +return pktb->tail - pktb->transport_header -sizeof (struct udphdr ); }/**
Signature · 1 line
2.14.5
Re: [PATCH libnetfilter_queue] src: Fix value returned by nfq_udp_get_payload_len()
Applied, thanks.