From: lantw44@gmail.com
To: netfilter-devel@vger.kernel.org
Cc: Ting-Wei Lan <lantw44@gmail.com>
Subject: [PATCH 2/3] extra: fix wrong implementation in nfq_udp_get_payload
Date: Fri, 20 Jun 2014 18:27:00 +0800 [thread overview]
Message-ID: <1403260021-8732-2-git-send-email-lantw44@gmail.com> (raw)
In-Reply-To: <1403260021-8732-1-git-send-email-lantw44@gmail.com>
From: Ting-Wei Lan <lantw44@gmail.com>
---
| 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
--git a/src/extra/udp.c b/src/extra/udp.c
index eee732e..2a17a2f 100644
--- a/src/extra/udp.c
+++ b/src/extra/udp.c
@@ -56,13 +56,17 @@ EXPORT_SYMBOL(nfq_udp_get_hdr);
*/
void *nfq_udp_get_payload(struct udphdr *udph, struct pkt_buff *pktb)
{
- unsigned int doff = udph->len;
+ uint16_t len = ntohs (udph->len);
- /* malformed UDP data offset. */
- if (pktb->transport_header + doff > pktb->tail)
+ /* the UDP packet is too short. */
+ if (len < sizeof(struct udphdr))
return NULL;
- return pktb->transport_header + doff;
+ /* malformed UDP packet. */
+ if (pktb->transport_header + len > pktb->tail)
+ return NULL;
+
+ return pktb->transport_header + sizeof(struct udphdr);
}
EXPORT_SYMBOL(nfq_udp_get_payload);
--
1.9.3
next prev parent reply other threads:[~2014-06-20 10:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 10:26 [PATCH 1/3] extra: use inet_ntop instead of inet_ntoa lantw44
2014-06-20 10:27 ` lantw44 [this message]
2014-06-30 10:02 ` [PATCH 2/3] extra: fix wrong implementation in nfq_udp_get_payload Pablo Neira Ayuso
2014-06-30 17:00 ` 藍挺瑋
2014-06-20 10:27 ` [PATCH 3/3] extra: fix wrong implementation in nfq_udp_get_payload_len lantw44
2014-06-30 10:11 ` Pablo Neira Ayuso
2014-06-30 9:48 ` [PATCH 1/3] extra: use inet_ntop instead of inet_ntoa Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403260021-8732-2-git-send-email-lantw44@gmail.com \
--to=lantw44@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).