summaryrefslogtreecommitdiff
path: root/usr.sbin/ospfd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2006-04-25 08:22:15 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2006-04-25 08:22:15 +0000
commit30d4305729811111d4c05ab997418516596a76d7 (patch)
tree023690abf42330f8301588e14a0d0327fae51305 /usr.sbin/ospfd
parente753765157f75a90d0d97d5d513969a245875c0e (diff)
Path the length of the packet as size_t to in_cksum(). Enforce that the
passed size is not bigger than 2^16 (limit of the used algorithm). This removes some more lint warnings and makes sense.
Diffstat (limited to 'usr.sbin/ospfd')
-rw-r--r--usr.sbin/ospfd/in_cksum.c13
-rw-r--r--usr.sbin/ospfd/ospfd.h4
2 files changed, 11 insertions, 6 deletions
diff --git a/usr.sbin/ospfd/in_cksum.c b/usr.sbin/ospfd/in_cksum.c
index 10918c725bc..cdd61baec16 100644
--- a/usr.sbin/ospfd/in_cksum.c
+++ b/usr.sbin/ospfd/in_cksum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_cksum.c,v 1.3 2006/03/09 09:43:03 claudio Exp $ */
+/* $OpenBSD: in_cksum.c,v 1.4 2006/04/25 08:22:14 claudio Exp $ */
/* $NetBSD: in_cksum.c,v 1.3 1995/04/22 13:53:48 cgd Exp $ */
/*
@@ -43,6 +43,7 @@
#include <sys/types.h>
#include "ospfd.h"
+#include "log.h"
/*
* Checksum routine for Internet Protocol family headers.
@@ -51,13 +52,17 @@
* In particular, it should not be this one.
*/
u_int16_t
-in_cksum(void *p, int len)
+in_cksum(void *p, size_t l)
{
unsigned int sum = 0;
- int oddbyte = 0, v = 0;
+ int len, oddbyte = 0, v = 0;
u_char *cp = p;
- /* we assume < 2^16 bytes being summed */
+ /* ensure that < 2^16 bytes being summed */
+ if (l >= (1 << 16))
+ fatalx("in_cksum: packet to big");
+ len = (int)l;
+
while (len > 0) {
if (oddbyte) {
sum += v + *cp++;
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index d15b711a0c4..51dd18c9049 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.56 2006/04/24 20:18:03 claudio Exp $ */
+/* $OpenBSD: ospfd.h,v 1.57 2006/04/25 08:22:14 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -524,7 +524,7 @@ void imsg_free(struct imsg *);
void imsg_event_add(struct imsgbuf *); /* needs to be provided externally */
/* in_cksum.c */
-u_int16_t in_cksum(void *, int);
+u_int16_t in_cksum(void *, size_t);
/* iso_cksum.c */
u_int16_t iso_cksum(void *, u_int16_t, u_int16_t);