diff mbox

[2/3] extra: fix wrong implementation in nfq_udp_get_payload

Message ID 1403260021-8732-2-git-send-email-lantw44@gmail.com
State Accepted
Headers show

Commit Message

lantw44@gmail.com June 20, 2014, 10:27 a.m. UTC
From: Ting-Wei Lan <lantw44@gmail.com>

---
 src/extra/udp.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Pablo Neira Ayuso June 30, 2014, 10:02 a.m. UTC | #1
On Fri, Jun 20, 2014 at 06:27:00PM +0800, lantw44@gmail.com wrote:
> From: Ting-Wei Lan <lantw44@gmail.com>
> 
> ---
>  src/extra/udp.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --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);
                            ^

removed this space.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lantw44@gmail.com June 30, 2014, 5 p.m. UTC | #2
於 一,2014-06-30 於 12:02 +0200,Pablo Neira Ayuso 提到:
> On Fri, Jun 20, 2014 at 06:27:00PM +0800, lantw44@gmail.com wrote:
> > From: Ting-Wei Lan <lantw44@gmail.com>
> > 
> > ---
> >  src/extra/udp.c | 12 ++++++++----
> >  1 file changed, 8 insertions(+), 4 deletions(-)
> > 
> > diff --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);
>                             ^
> 
> removed this space.
> 
> Applied, thanks.

but I cannot find this patch in libnetfilter_queue git log ...


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --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);