libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / taint-pr112927.c
blob9c3f7ab670860aca6a2231bf680fd740d1c7c3bb
1 /* Reduced from false positive in Linux kernel
2 in drivers/char/ipmi/ipmi_devintf.c. */
4 /* { dg-do compile } */
5 /* { dg-options "-fanalyzer -O2 -Wno-attributes" } */
6 /* { dg-require-effective-target analyzer } */
8 typedef __SIZE_TYPE__ size_t;
9 extern void
10 __check_object_size(const void* ptr, unsigned long n);
12 extern unsigned long
13 copy_from_user(void*, const void*, unsigned long);
15 __attribute__((__always_inline__)) unsigned long
16 call_copy_from_user(void* to, const void* from, unsigned long n)
18 __check_object_size(to, n);
19 n = copy_from_user(to, from, n); /* { dg-bogus "use of attacker-controlled value as size without upper-bounds checking" } */
20 return n;
22 struct ipmi_msg
24 unsigned short data_len;
25 unsigned char* data;
28 static int
29 handle_send_req(struct ipmi_msg* msg)
31 char buf[273];
32 if (msg->data_len > 272) {
33 return -90;
35 if (call_copy_from_user(buf, msg->data, msg->data_len)) {
36 return -14;
38 return 0;
40 long
41 ipmi_ioctl(void* arg)
43 struct ipmi_msg msg;
44 if (call_copy_from_user(&msg, arg, sizeof(msg))) {
45 return -14;
48 return handle_send_req(&msg);