unsafe C in netgraph/pppoed.c
Roman Divacky
rdivacky at freebsd.org
Tue Feb 10 14:17:42 PST 2009
hi
struct pppoe_tag {
u_int16_t tag_type;
u_int16_t tag_len;
char tag_data[];
}__packed;
struct pppoe_hdr{
u_int8_t ver:4;
u_int8_t type:4;
u_int8_t code;
u_int16_t sid;
u_int16_t length;
struct pppoe_tag tag[];
}__packed;
this is inherently unsafe as the tag_data can only have 0 elements
to be used safely. gcc compiles this without warning although there
should be a big one.
I found this using clang, which produces this error/warning:
lev pppoed$ ccc -c pppoed.c ccc: Unknown host 'freebsd', using generic host information.
In file included from pppoed.c:41:
/usr/include/netgraph/ng_pppoe.h:213:22: error: 'struct pppoe_tag' may not be used as an array element due to flexible array member
struct pppoe_tag tag[];
^
1 diagnostic generated.
can you guys take a look at this issue?
thnx!
roman
p.s. please keep me CCed as I am not subscribed to net@
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20090210/82984cca/attachment.pgp
More information about the freebsd-net
mailing list