arithmetic on void pointer

Kenneth Porter shiva@well.com
30 Jan 2002 16:31:28 -0800


Not sure who owns this or whether it's already fixed in more recent
sources....

I was rebuilding the Red Hat iptables package from the 7.2 updates tree
and I normally have compiler warnings cranked up, and I saw several
messages about arithmetic on null pointers. These appear to be in
iptables headers in the kernel source tree, and are of the form
"(void*)p + offset". This is wrong because an object pointed at by a
void pointer has no size, so the offset has no meaning. The correct
construct should be a char pointer (ie. "(char*)p + offset").

An example is in ipt_get_target() in
/usr/include/linux/netfilter_ipv4/ip_tables.h. (2 more instances follow
in the same file.) This file is listed as belonging to
kernel-headers-2.4.7-10. The same mistake is also in 2.4.9-21 (which I
have building as I type this).