Skip to content

Commit 5cef0e2

Browse files
committed
CPP: Add a test of NonPortablePrintf.ql.
1 parent a7fb2e1 commit 5cef0e2

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| test.cpp:10:17:10:17 | l | This argument should be of type int but is of type long (which changes size from 32 to 64 on 64-bit systems). |
2+
| test.cpp:13:17:13:19 | ptr | This argument should be of type int but is of type void * (which changes size from 32 to 64 on 64-bit systems). |
3+
| test.cpp:14:17:14:19 | ptr | This argument should be of type unsigned int but is of type void * (which changes size from 32 to 64 on 64-bit systems). |
4+
| test.cpp:15:17:15:19 | ptr | This argument should be of type unsigned int but is of type void * (which changes size from 32 to 64 on 64-bit systems). |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Likely Bugs/Memory Management/Padding/NonPortablePrintf.ql
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
int printf(const char *format, ...);
3+
4+
void test1()
5+
{
6+
long l;
7+
void *ptr;
8+
9+
printf("%l\n", l); // GOOD
10+
printf("%d\n", l); // BAD
11+
12+
printf("%p\n", ptr); // GOOD
13+
printf("%d\n", ptr); // BAD
14+
printf("%u\n", ptr); // BAD
15+
printf("%x\n", ptr); // BAD
16+
}

0 commit comments

Comments
 (0)