diff options
| author | 2007-09-07 11:15:19 +0000 | |
|---|---|---|
| committer | 2007-09-07 11:15:19 +0000 | |
| commit | 3268bbb360879710e527d86196bad2c2ee328876 (patch) | |
| tree | 51b69760859394a4d1409a072fa813415bf782fa /sys/net/rtsock.c | |
| parent | use M_ZERO (diff) | |
| download | wireguard-openbsd-3268bbb360879710e527d86196bad2c2ee328876.tar.xz wireguard-openbsd-3268bbb360879710e527d86196bad2c2ee328876.zip | |
Check if rtm_hdrlen is smaller then the passed message or it would be possible
to access uninitialised memory.
Set dst to 0 on error, the error path tries to access dst but dst is inited
later down the code. This fixes a kernel panic seen by aanriot@
OK henning@
Diffstat (limited to 'sys/net/rtsock.c')
| -rw-r--r-- | sys/net/rtsock.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 9ccb8befa4a..661192c0f9e 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.64 2007/09/03 15:24:49 claudio Exp $ */ +/* $OpenBSD: rtsock.c,v 1.65 2007/09/07 11:15:19 claudio Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -234,15 +234,22 @@ route_output(struct mbuf *m, ...) rtm->rtm_pid = curproc->p_pid; if (rtm->rtm_hdrlen == 0) /* old client */ rtm->rtm_hdrlen = sizeof(struct rt_msghdr); + if (len < rtm->rtm_hdrlen) { + dst = 0; + error = EINVAL; + goto flush; + } tableid = rtm->rtm_tableid; if (!rtable_exists(tableid)) { if (rtm->rtm_type == RTM_ADD) { if (rtable_add(tableid)) { + dst = 0; error = EINVAL; goto flush; } } else { + dst = 0; error = EINVAL; goto flush; } |
