buf_size: handle empty arrays on the end of structs
commit2dcf7dbdb926e9f2a5279097e0e1375616479649
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 26 Feb 2013 07:18:51 +0000 (26 10:18 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Tue, 26 Feb 2013 07:18:51 +0000 (26 10:18 +0300)
tree5cc7027dba6d08f172247071968095852cfd9080
parent7e269a07860950f4f42cec8a7ac9042195f3e34d
buf_size: handle empty arrays on the end of structs

It's a common idiom to do:

struct my_struct {
int x, y, z;
char buf[0];
};

struct my_struct *p = malloc(sizeof(*my_struct) + 100);

That gives you a struct with a dynamically sized array on the end.  Up
to now Smatch hasn't tried to track the size of those arrays.  This patch
adds support for doing that.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch_buf_size.c
validation/sm_array_overflow5.c [new file with mode: 0644]