chiark / gitweb /
integer and buffer overflows: introduce a number of asserts
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 12 Jun 2011 21:23:15 +0000 (22:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Jun 2011 11:07:17 +0000 (12:07 +0100)
commit59230b9b9fc44453f24c6b3cf33a0f4c570a3563
tree984b2e0a3d63fde88073df9c0fb0db20fce121df
parent7908f2c6b5be419f8f4031876139953d4ee8340d
integer and buffer overflows: introduce a number of asserts

In various places we add and increment integers, hoping that they
don't overflow.  We also prepend and append things to our internal
buffer, which is of fixed size, without checking that they will fit.

This means that malicious configuration (for example, long site names)
might be able to take over the secnet program.

So, add a whole lot of checking.  Many of these places don't have a
sensible way to return an error; in those cases we assert.  Some of
the checks are off-by-one in the sense that they say "assert(x<...)"
when "<=" would be OK too.  This is done to avoid having to think too
hard about fenceposts, as it's a simple way to avoid introducing bugs.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Signed-off-by: Richard Kettlewell <richard@greenend.org.uk>
conffile.c
conffile.fl
dh.c
ipaddr.c
log.c
netlink.c
secnet.c
secnet.h
site.c
util.c