summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2015-02-11 05:58:08 +0000
committerclaudio <claudio@openbsd.org>2015-02-11 05:58:08 +0000
commit1c6429008f048ad6889f47f1f5daaa31c8a93f43 (patch)
treeef6d830638b3b08dcca5b4817f1f9667f87efc36
parentUse sizeof(u_short) in the first check since there are RT messages that (diff)
downloadwireguard-openbsd-1c6429008f048ad6889f47f1f5daaa31c8a93f43.tar.xz
wireguard-openbsd-1c6429008f048ad6889f47f1f5daaa31c8a93f43.zip
Use sizeof(u_short) in the first check since there are RT messages that
are less then sizeof(*rtm) bytes long (e.g. interface announcements). Found the hard way by phessler@
-rw-r--r--usr.sbin/ripd/kroute.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/ripd/kroute.c b/usr.sbin/ripd/kroute.c
index ff66a291107..4c13ea087e6 100644
--- a/usr.sbin/ripd/kroute.c
+++ b/usr.sbin/ripd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.28 2015/02/10 08:23:13 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.29 2015/02/11 05:58:08 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -1039,7 +1039,7 @@ dispatch_rtmsg(void)
lim = buf + n;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
- if (lim < next + sizeof(*rtm) ||
+ if (lim < next + sizeof(u_short) ||
lim < next + rtm->rtm_msglen)
fatalx("dispatch_rtmsg: partial rtm in buffer");
if (rtm->rtm_version != RTM_VERSION)