NetBSD-Bugs archive

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

kern/50905: Useless comparision.



>Number:         50905
>Category:       kern
>Synopsis:       Useless comparision.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 07 10:40:00 +0000 2016
>Originator:     Henning Petersen
>Release:        
>Organization:
>Environment:
>Description:
In function key_parse is useless comparision at line 7358:

if ((m->m_flags & M_PKTHDR) == 0 ||
	    m->m_pkthdr.len != m->m_pkthdr.len) <<<===

Patch is taken from freebsd.
>How-To-Repeat:

>Fix:
diff -u -p -r1.96 key.c
--- sys/netipsec/key.c	6 Mar 2016 04:19:51 -0000	1.96
+++ sys/netipsec/key.c	7 Mar 2016 10:25:21 -0000
@@ -7333,6 +7333,7 @@ key_parse(struct mbuf *m, struct socket 
 {
 	struct sadb_msg *msg;
 	struct sadb_msghdr mh;
+	u_int orglen;
 	int error;
 	int target;
 
@@ -7352,10 +7353,11 @@ key_parse(struct mbuf *m, struct socket 
 			return ENOBUFS;
 	}
 	msg = mtod(m, struct sadb_msg *);
+	orglen = PFKEY_UNUNIT64(msg->sadb_msg_len);
 	target = KEY_SENDUP_ONE;
 
 	if ((m->m_flags & M_PKTHDR) == 0 ||
-	    m->m_pkthdr.len != m->m_pkthdr.len) {
+	    m->m_pkthdr.len != orglen) {
 		ipseclog((LOG_DEBUG, "key_parse: invalid message length.\n"));
 		PFKEY_STATINC(PFKEY_STAT_OUT_INVLEN);
 		error = EINVAL;



Home | Main Index | Thread Index | Old Index