Module Name:    src
Committed By:   maxv
Date:           Fri May 11 14:07:58 UTC 2018

Modified Files:
        src/sys/netinet: raw_ip.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/netinet/raw_ip.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/raw_ip.c
diff -u src/sys/netinet/raw_ip.c:1.176 src/sys/netinet/raw_ip.c:1.177
--- src/sys/netinet/raw_ip.c:1.176	Sat Apr 28 13:26:57 2018
+++ src/sys/netinet/raw_ip.c	Fri May 11 14:07:58 2018
@@ -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 @@ rip_output(struct mbuf *m, struct inpcb 
 			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 @@ rip_output(struct mbuf *m, struct inpcb 
 
 			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 @@ rip_output(struct mbuf *m, struct inpcb 
 		}
 		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);
 	}
 

Reply via email to