mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
Merge pull request #189 from geoffw0/wrongtypedef
CPP: Permit more typedefs in WrongTypeFormatArguments.ql
This commit is contained in:
@@ -11,14 +11,6 @@
|
||||
| printf1.h:45:18:45:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:46:18:46:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:47:19:47:21 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:68:19:68:21 | sst | This argument should be of type 'size_t' but is of type 'long' |
|
||||
| printf1.h:70:19:70:20 | ul | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:71:19:71:20 | st | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:72:19:72:20 | ST | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:73:19:73:22 | c_st | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:74:19:74:22 | C_ST | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:75:19:75:28 | sizeof(<expr>) | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:83:23:83:35 | ... - ... | This argument should be of type 'size_t' but is of type 'long' |
|
||||
| real_world.h:61:21:61:22 | & ... | This argument should be of type 'int *' but is of type 'short *' |
|
||||
| real_world.h:62:22:62:23 | & ... | This argument should be of type 'short *' but is of type 'int *' |
|
||||
| real_world.h:63:22:63:24 | & ... | This argument should be of type 'short *' but is of type 'unsigned int *' |
|
||||
|
||||
@@ -65,14 +65,14 @@ void g()
|
||||
printf("%zu", c_st); // ok
|
||||
printf("%zu", C_ST); // ok
|
||||
printf("%zu", sizeof(ul)); // ok
|
||||
printf("%zu", sst); // not ok [NOT DETECTED ON MICROSOFT]
|
||||
printf("%zu", sst); // not ok [NOT DETECTED]
|
||||
|
||||
printf("%zd", ul); // not ok
|
||||
printf("%zd", st); // not ok
|
||||
printf("%zd", ST); // not ok
|
||||
printf("%zd", c_st); // not ok
|
||||
printf("%zd", C_ST); // not ok
|
||||
printf("%zd", sizeof(ul)); // not ok
|
||||
printf("%zd", ul); // not ok [NOT DETECTED]
|
||||
printf("%zd", st); // not ok [NOT DETECTED]
|
||||
printf("%zd", ST); // not ok [NOT DETECTED]
|
||||
printf("%zd", c_st); // not ok [NOT DETECTED]
|
||||
printf("%zd", C_ST); // not ok [NOT DETECTED]
|
||||
printf("%zd", sizeof(ul)); // not ok [NOT DETECTED]
|
||||
printf("%zd", sst); // ok
|
||||
{
|
||||
char *ptr_a, *ptr_b;
|
||||
@@ -80,8 +80,8 @@ void g()
|
||||
|
||||
printf("%tu", ptr_a - ptr_b); // ok
|
||||
printf("%td", ptr_a - ptr_b); // ok
|
||||
printf("%zu", ptr_a - ptr_b); // ok (dubious) [DETECTED ON LINUX ONLY]
|
||||
printf("%zd", ptr_a - ptr_b); // ok (dubious) [DETECTED ON MICROSOFT ONLY]
|
||||
printf("%zu", ptr_a - ptr_b); // ok (dubious)
|
||||
printf("%zd", ptr_a - ptr_b); // ok (dubious)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,3 +92,12 @@ void h(int i, struct some_type *j, int k)
|
||||
// going on.
|
||||
printf("%i %R %i", i, j, k); // GOOD (as far as we can tell)
|
||||
}
|
||||
|
||||
typedef long ptrdiff_t;
|
||||
|
||||
void fun1(unsigned char* a, unsigned char* b) {
|
||||
ptrdiff_t pdt;
|
||||
|
||||
printf("%td\n", pdt); // GOOD
|
||||
printf("%td\n", a-b); // GOOD
|
||||
}
|
||||
|
||||
@@ -11,14 +11,6 @@
|
||||
| printf1.h:45:18:45:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:46:18:46:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:47:19:47:21 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:68:19:68:21 | sst | This argument should be of type 'size_t' but is of type 'long' |
|
||||
| printf1.h:70:19:70:20 | ul | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:71:19:71:20 | st | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:72:19:72:20 | ST | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:73:19:73:22 | c_st | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:74:19:74:22 | C_ST | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:75:19:75:28 | sizeof(<expr>) | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:83:23:83:35 | ... - ... | This argument should be of type 'size_t' but is of type 'long' |
|
||||
| real_world.h:61:21:61:22 | & ... | This argument should be of type 'int *' but is of type 'short *' |
|
||||
| real_world.h:62:22:62:23 | & ... | This argument should be of type 'short *' but is of type 'int *' |
|
||||
| real_world.h:63:22:63:24 | & ... | This argument should be of type 'short *' but is of type 'unsigned int *' |
|
||||
|
||||
@@ -65,14 +65,14 @@ void g()
|
||||
printf("%zu", c_st); // ok
|
||||
printf("%zu", C_ST); // ok
|
||||
printf("%zu", sizeof(ul)); // ok
|
||||
printf("%zu", sst); // not ok [NOT DETECTED ON MICROSOFT]
|
||||
printf("%zu", sst); // not ok [NOT DETECTED]
|
||||
|
||||
printf("%zd", ul); // not ok
|
||||
printf("%zd", st); // not ok
|
||||
printf("%zd", ST); // not ok
|
||||
printf("%zd", c_st); // not ok
|
||||
printf("%zd", C_ST); // not ok
|
||||
printf("%zd", sizeof(ul)); // not ok
|
||||
printf("%zd", ul); // not ok [NOT DETECTED]
|
||||
printf("%zd", st); // not ok [NOT DETECTED]
|
||||
printf("%zd", ST); // not ok [NOT DETECTED]
|
||||
printf("%zd", c_st); // not ok [NOT DETECTED]
|
||||
printf("%zd", C_ST); // not ok [NOT DETECTED]
|
||||
printf("%zd", sizeof(ul)); // not ok [NOT DETECTED]
|
||||
printf("%zd", sst); // ok
|
||||
{
|
||||
char *ptr_a, *ptr_b;
|
||||
@@ -80,8 +80,8 @@ void g()
|
||||
|
||||
printf("%tu", ptr_a - ptr_b); // ok
|
||||
printf("%td", ptr_a - ptr_b); // ok
|
||||
printf("%zu", ptr_a - ptr_b); // ok (dubious) [DETECTED ON LINUX ONLY]
|
||||
printf("%zd", ptr_a - ptr_b); // ok (dubious) [DETECTED ON MICROSOFT ONLY]
|
||||
printf("%zu", ptr_a - ptr_b); // ok (dubious)
|
||||
printf("%zd", ptr_a - ptr_b); // ok (dubious)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,3 +92,12 @@ void h(int i, struct some_type *j, int k)
|
||||
// going on.
|
||||
printf("%i %R %i", i, j, k); // GOOD (as far as we can tell)
|
||||
}
|
||||
|
||||
typedef long ptrdiff_t;
|
||||
|
||||
void fun1(unsigned char* a, unsigned char* b) {
|
||||
ptrdiff_t pdt;
|
||||
|
||||
printf("%td\n", pdt); // GOOD
|
||||
printf("%td\n", a-b); // GOOD
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
| printf1.h:45:18:45:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:46:18:46:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:47:19:47:21 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:70:19:70:20 | ul | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:71:19:71:20 | st | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
|
||||
| printf1.h:72:19:72:20 | ST | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
|
||||
| printf1.h:73:19:73:22 | c_st | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
|
||||
|
||||
@@ -65,9 +65,9 @@ void g()
|
||||
printf("%zu", c_st); // ok
|
||||
printf("%zu", C_ST); // ok
|
||||
printf("%zu", sizeof(ul)); // ok
|
||||
printf("%zu", sst); // not ok [NOT DETECTED ON MICROSOFT]
|
||||
printf("%zu", sst); // not ok [NOT DETECTED]
|
||||
|
||||
printf("%zd", ul); // not ok
|
||||
printf("%zd", ul); // not ok [NOT DETECTED]
|
||||
printf("%zd", st); // not ok
|
||||
printf("%zd", ST); // not ok
|
||||
printf("%zd", c_st); // not ok
|
||||
@@ -80,8 +80,8 @@ void g()
|
||||
|
||||
printf("%tu", ptr_a - ptr_b); // ok
|
||||
printf("%td", ptr_a - ptr_b); // ok
|
||||
printf("%zu", ptr_a - ptr_b); // ok (dubious) [DETECTED ON LINUX ONLY]
|
||||
printf("%zd", ptr_a - ptr_b); // ok (dubious) [DETECTED ON MICROSOFT ONLY]
|
||||
printf("%zu", ptr_a - ptr_b); // ok (dubious)
|
||||
printf("%zd", ptr_a - ptr_b); // ok (dubious) [FALSE POSITIVE]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,3 +92,12 @@ void h(int i, struct some_type *j, int k)
|
||||
// going on.
|
||||
printf("%i %R %i", i, j, k); // GOOD (as far as we can tell)
|
||||
}
|
||||
|
||||
typedef long long ptrdiff_t;
|
||||
|
||||
void fun1(unsigned char* a, unsigned char* b) {
|
||||
ptrdiff_t pdt;
|
||||
|
||||
printf("%td\n", pdt); // GOOD
|
||||
printf("%td\n", a-b); // GOOD
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ void someFunction()
|
||||
WCHAR filename[MAX_LONGPATH];
|
||||
int linenum;
|
||||
|
||||
msg_out("Source file: %S @ %d\n", filename, linenum); // GOOD
|
||||
msg_out("Source file: %S @ %d\n", filename, linenum); // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
| printf1.h:45:18:45:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:46:18:46:20 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:47:19:47:21 | ull | This argument should be of type 'unsigned int' but is of type 'unsigned long long' |
|
||||
| printf1.h:70:19:70:20 | ul | This argument should be of type 'ssize_t' but is of type 'unsigned long' |
|
||||
| printf1.h:71:19:71:20 | st | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
|
||||
| printf1.h:72:19:72:20 | ST | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
|
||||
| printf1.h:73:19:73:22 | c_st | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
|
||||
| printf1.h:74:19:74:22 | C_ST | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
|
||||
| printf1.h:75:19:75:28 | sizeof(<expr>) | This argument should be of type 'ssize_t' but is of type 'unsigned long long' |
|
||||
| printf1.h:84:23:84:35 | ... - ... | This argument should be of type 'ssize_t' but is of type 'long long' |
|
||||
| real_world.h:46:36:46:43 | filename | This argument should be of type 'wchar_t *' but is of type 'char16_t *' |
|
||||
| real_world.h:61:21:61:22 | & ... | This argument should be of type 'int *' but is of type 'short *' |
|
||||
| real_world.h:62:22:62:23 | & ... | This argument should be of type 'short *' but is of type 'int *' |
|
||||
| real_world.h:63:22:63:24 | & ... | This argument should be of type 'short *' but is of type 'unsigned int *' |
|
||||
|
||||
@@ -65,9 +65,9 @@ void g()
|
||||
printf("%zu", c_st); // ok
|
||||
printf("%zu", C_ST); // ok
|
||||
printf("%zu", sizeof(ul)); // ok
|
||||
printf("%zu", sst); // not ok [NOT DETECTED ON MICROSOFT]
|
||||
printf("%zu", sst); // not ok [NOT DETECTED]
|
||||
|
||||
printf("%zd", ul); // not ok
|
||||
printf("%zd", ul); // not ok [NOT DETECTED]
|
||||
printf("%zd", st); // not ok
|
||||
printf("%zd", ST); // not ok
|
||||
printf("%zd", c_st); // not ok
|
||||
@@ -80,8 +80,8 @@ void g()
|
||||
|
||||
printf("%tu", ptr_a - ptr_b); // ok
|
||||
printf("%td", ptr_a - ptr_b); // ok
|
||||
printf("%zu", ptr_a - ptr_b); // ok (dubious) [DETECTED ON LINUX ONLY]
|
||||
printf("%zd", ptr_a - ptr_b); // ok (dubious) [DETECTED ON MICROSOFT ONLY]
|
||||
printf("%zu", ptr_a - ptr_b); // ok (dubious)
|
||||
printf("%zd", ptr_a - ptr_b); // ok (dubious) [FALSE POSITIVE]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,3 +92,12 @@ void h(int i, struct some_type *j, int k)
|
||||
// going on.
|
||||
printf("%i %R %i", i, j, k); // GOOD (as far as we can tell)
|
||||
}
|
||||
|
||||
typedef long long ptrdiff_t;
|
||||
|
||||
void fun1(unsigned char* a, unsigned char* b) {
|
||||
ptrdiff_t pdt;
|
||||
|
||||
printf("%td\n", pdt); // GOOD
|
||||
printf("%td\n", a-b); // GOOD
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user