diff options
author | 2015-01-30 23:38:49 +0000 | |
---|---|---|
committer | 2015-01-30 23:38:49 +0000 | |
commit | 494c46d1e354923d2032d67a379a196df76cddb7 (patch) | |
tree | 663a7afba3f59f84513508c9a309497dc56eaac7 | |
parent | Have pity on the poor stack. (diff) | |
download | wireguard-openbsd-494c46d1e354923d2032d67a379a196df76cddb7.tar.xz wireguard-openbsd-494c46d1e354923d2032d67a379a196df76cddb7.zip |
Fix mbuf leak in Linux compat setsockopt() in the error path when
optval is not valid. Found by Maxime Villard. OK bluhm@
-rw-r--r-- | sys/compat/linux/linux_socket.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 4adc69e31c3..1c16aab6a5b 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_socket.c,v 1.59 2015/01/21 13:47:45 mpi Exp $ */ +/* $OpenBSD: linux_socket.c,v 1.60 2015/01/30 23:38:49 millert Exp $ */ /* $NetBSD: linux_socket.c,v 1.14 1996/04/05 00:01:50 christos Exp $ */ /* @@ -969,10 +969,8 @@ linux_setsockopt(p, v, retval) if (lsa.optval != NULL) { m = m_get(M_WAIT, MT_SOOPTS); error = copyin(lsa.optval, mtod(m, caddr_t), lsa.optlen); - if (error) { - (void) m_free(m); + if (error) goto bad; - } m->m_len = lsa.optlen; } so = (struct socket *)fp->f_data; @@ -984,7 +982,10 @@ linux_setsockopt(p, v, retval) goto bad; } error = sosetopt(so, level, name, m); + m = NULL; bad: + if (m) + m_free(m); FRELE(fp, p); return (error); } |