buffer_too_small_for_struct: a variable size buffer is smaller a struct
commit9e18e1d4e621b108203ca5a69adfbf2709dfa8c5
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 8 Nov 2014 11:55:08 +0000 (8 14:55 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Sat, 8 Nov 2014 11:55:08 +0000 (8 14:55 +0300)
tree1f672240b3c19751fa95ebf0dede6f3e408195b8
parentd942fbd49486013f161456579a217af3b753b154
buffer_too_small_for_struct: a variable size buffer is smaller a struct

It's common to get some data from the user and put it in a struct, but
what about if the struct is too small?  This check prints a warning.

There are some false positives:
1) Sometimes you only care about the first members of the struct.
2) Lustre is confusing.
3) You're allocating an array and only loop through the elements when the
   number is non-zero.
4) One driver passes the size of the buffer as a parameter but sometimes
   overloads the size to mean something else instead of the size.
5) Smatch couldn't figure out the size.  Sometimes this is because it came
   from the hardware.

But mostly it's good stuff and these sometimes bad bugs so I'm going to
release this check to the public.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
check_buffer_too_small_for_struct.c [new file with mode: 0644]
check_list.h