Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet Make sure we have at least an IP header, and rem...



details:   https://anonhg.NetBSD.org/src/rev/5c08b6b9896e
branches:  trunk
changeset: 322673:5c08b6b9896e
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri May 11 14:07:58 2018 +0000

description:
Make sure we have at least an IP header, and remove pointless XXXs (there
is no issue).

diffstat:

 sys/netinet/raw_ip.c |  15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r 3e83946de0e3 -r 5c08b6b9896e sys/netinet/raw_ip.c
--- a/sys/netinet/raw_ip.c      Fri May 11 13:56:43 2018 +0000
+++ b/sys/netinet/raw_ip.c      Fri May 11 14:07:58 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: raw_ip.c,v 1.176 2018/04/28 13:26:57 maxv Exp $        */
+/*     $NetBSD: raw_ip.c,v 1.177 2018/05/11 14:07:58 maxv Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.176 2018/04/28 13:26:57 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.177 2018/05/11 14:07:58 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -355,6 +355,10 @@
                        error = EMSGSIZE;
                        goto release;
                }
+               if (m->m_pkthdr.len < sizeof(struct ip)) {
+                       error = EINVAL;
+                       goto release;
+               }
                ip = mtod(m, struct ip *);
 
                /*
@@ -367,7 +371,7 @@
 
                        m = m_copyup(m, hlen, (max_linkhdr + 3) & ~3);
                        if (m == NULL) {
-                               error = ENOMEM; /* XXX */
+                               error = ENOMEM;
                                goto release;
                        }
                        ip = mtod(m, struct ip *);
@@ -380,11 +384,14 @@
                }
                HTONS(ip->ip_len);
                HTONS(ip->ip_off);
+
                if (ip->ip_id != 0 || m->m_pkthdr.len < IP_MINFRAGSIZE)
                        flags |= IP_NOIPNEWID;
                opts = NULL;
-               /* XXX prevent ip_output from overwriting header fields */
+
+               /* Prevent ip_output from overwriting header fields. */
                flags |= IP_RAWOUTPUT;
+
                IP_STATINC(IP_STAT_RAWOUT);
        }
 



Home | Main Index | Thread Index | Old Index