1 #include <stdio.h>
2 #include <string.h>
3 #include "check_debug.h"
4
5 void *kmalloc(int size, int mask);
6
7 struct foo {
8 int x, y, z;
9 int buf[0];
10 };
11
12 int main(void)
13 {
14 struct foo *p;
15
16 p = kmalloc(sizeof(*p) + 100, 0);
17 if (!p)
18 return -12;
19 __smatch_buf_size(p->buf);
20
21 return 0;
22 }
23
24
25 /*
26 * check-name: smatch: overflow check #5
27 * check-command: smatch -p=kernel -I.. sm_array_overflow5.c
28 *
29 * check-output-start
30 sm_array_overflow5.c:19 main() buf size: 'p->buf' 25 elements, 100 bytes
31 * check-output-end
32 */