mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
CPP: Add a test where different word sizes are present.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
| tests_32.cpp:14:16:14:23 | void_ptr | This argument should be of type 'long' but is of type 'void *' |
|
||||
| tests_32.cpp:15:15:15:15 | l | This argument should be of type 'void *' but is of type 'long' |
|
||||
| tests_64.cpp:14:16:14:23 | void_ptr | This argument should be of type 'long' but is of type 'void *' |
|
||||
| tests_64.cpp:15:15:15:15 | l | This argument should be of type 'void *' but is of type 'long' |
|
||||
@@ -0,0 +1 @@
|
||||
Likely Bugs/Format/WrongTypeFormatArguments.ql
|
||||
@@ -0,0 +1,17 @@
|
||||
// semmle-extractor-options: --edg --target --edg linux_i686
|
||||
/*
|
||||
* Test for printf in a snapshot that contains multiple word/pointer sizes.
|
||||
*/
|
||||
|
||||
int printf(const char * format, ...);
|
||||
|
||||
void test_32()
|
||||
{
|
||||
long l;
|
||||
void *void_ptr;
|
||||
|
||||
printf("%li", l); // GOOD
|
||||
printf("%li", void_ptr); // BAD
|
||||
printf("%p", l); // BAD
|
||||
printf("%p", void_ptr); // GOOD
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// semmle-extractor-options: --edg --target --edg linux_x86_64
|
||||
/*
|
||||
* Test for printf in a snapshot that contains multiple word/pointer sizes.
|
||||
*/
|
||||
|
||||
int printf(const char * format, ...);
|
||||
|
||||
void test_64()
|
||||
{
|
||||
long l;
|
||||
void *void_ptr;
|
||||
|
||||
printf("%li", l); // GOOD
|
||||
printf("%li", void_ptr); // BAD
|
||||
printf("%p", l); // BAD
|
||||
printf("%p", void_ptr); // GOOD
|
||||
}
|
||||
Reference in New Issue
Block a user