Source-Changes-HG archive

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

[src/trunk]: src/sys/netipsec Add missing NULL-checking for m_pullup (CID 142...



details:   https://anonhg.NetBSD.org/src/rev/14fe28ea0352
branches:  trunk
changeset: 829233:14fe28ea0352
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Tue Jan 23 02:21:49 2018 +0000

description:
Add missing NULL-checking for m_pullup (CID 1427770: Null pointer dereferences (NULL_RETURNS))

diffstat:

 sys/netipsec/ipsec_input.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r 667483444f19 -r 14fe28ea0352 sys/netipsec/ipsec_input.c
--- a/sys/netipsec/ipsec_input.c        Tue Jan 23 02:18:57 2018 +0000
+++ b/sys/netipsec/ipsec_input.c        Tue Jan 23 02:21:49 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ipsec_input.c,v 1.52 2018/01/23 02:18:57 ozaki-r Exp $ */
+/*     $NetBSD: ipsec_input.c,v 1.53 2018/01/23 02:21:49 ozaki-r Exp $ */
 /*     $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $ */
 /*     $OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $        */
 
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.52 2018/01/23 02:18:57 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.53 2018/01/23 02:21:49 ozaki-r Exp $");
 
 /*
  * IPsec input processing.
@@ -133,8 +133,11 @@
        int poff, off;
        int plen;
 
-       if (m->m_len < sizeof(*ip))
+       if (m->m_len < sizeof(*ip)) {
                m = m_pullup(m, sizeof(*ip));
+               if (m == NULL)
+                       return NULL;
+       }
        ip = mtod(m, struct ip *); 
        poff = ip->ip_hl << 2;
        plen = ntohs(ip->ip_len) - poff;



Home | Main Index | Thread Index | Old Index