Bug 1439236 - Exit early if m_copym gets called with null ptr. r=dminor, a=RyanVM
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Wed, 16 May 2018 09:51:35 -0700
changeset 473474 84df66c7e5457a1e93b9b92a9f1987494c0148bb
parent 473473 f94fff29d17cf53aa1390df917de4f5e428a1a3f
child 473475 9f007f15b9cf5d98308f0a9f1e1356733dc78c11
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdminor, RyanVM
bugs1439236
milestone61.0
Bug 1439236 - Exit early if m_copym gets called with null ptr. r=dminor, a=RyanVM Cheery-picked upstream commit: https://github.com/sctplab/usrsctp/commit/d89882d04900c80860874b5eb389b3ed3a0bca3d MozReview-Commit-ID: 36bYbfIaqEz
netwerk/sctp/src/user_mbuf.c
--- a/netwerk/sctp/src/user_mbuf.c
+++ b/netwerk/sctp/src/user_mbuf.c
@@ -982,16 +982,23 @@ m_copym(struct mbuf *m, int off0, int le
 {
 	struct mbuf *n, **np;
 	int off = off0;
 	struct mbuf *top;
 	int copyhdr = 0;
 
 	KASSERT(off >= 0, ("m_copym, negative off %d", off));
 	KASSERT(len >= 0, ("m_copym, negative len %d", len));
+	KASSERT(m != NULL, ("m_copym, m is NULL"));
+
+#if !defined(INVARIANTS)
+	if (m == NULL) {
+		return (NULL);
+	}
+#endif
 
 	if (off == 0 && m->m_flags & M_PKTHDR)
 		copyhdr = 1;
 	while (off > 0) {
 		KASSERT(m != NULL, ("m_copym, offset > size of mbuf chain"));
 		if (off < m->m_len)
 			break;
 		off -= m->m_len;