mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
C++: Repair the test.
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
| printf.cpp:39:29:39:35 | test | This argument should be of type 'wchar_t *' but is of type 'char16_t *' |
|
||||
| printf.cpp:45:29:45:35 | test | This argument should be of type 'char *' but is of type 'char16_t *' |
|
||||
| printf.cpp:24:31:24:37 | test | This argument should be of type 'char *' but is of type 'char16_t *' |
|
||||
| printf.cpp:36:29:36:35 | test | This argument should be of type 'char *' but is of type 'char16_t *' |
|
||||
| printf.cpp:43:29:43:35 | test | This argument should be of type 'char16_t *' but is of type 'wchar_t *' |
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
| printf.cpp:26:5:26:11 | sprintf | char | wchar_t | wchar_t |
|
||||
| printf.cpp:15:5:15:12 | swprintf | char | char16_t | char16_t |
|
||||
| printf.cpp:17:5:17:11 | sprintf | char | char16_t | char16_t |
|
||||
|
||||
@@ -12,16 +12,7 @@ int vswprintf(WCHAR *dest, WCHAR *format, va_list args) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int swprintf(WCHAR *dest, WCHAR *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
int ret = vswprintf(dest, format, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
return ret;
|
||||
}
|
||||
int swprintf(WCHAR *dest, WCHAR *format, ...);
|
||||
|
||||
int sprintf(char *dest, char *format, ...);
|
||||
|
||||
@@ -30,13 +21,13 @@ int sprintf(char *dest, char *format, ...);
|
||||
void test1() {
|
||||
WCHAR string[20];
|
||||
|
||||
swprintf(string, u"test %s", u"test"); // BAD: `char16_t` string parameter read as `char` string [NOT DETECTED]
|
||||
swprintf(string, u"test %s", u"test"); // BAD: `char16_t` string parameter read as `char` string
|
||||
}
|
||||
|
||||
void test2() {
|
||||
char string[20];
|
||||
|
||||
sprintf(string, "test %S", u"test"); // GOOD [FALSE POSITIVE]
|
||||
sprintf(string, "test %S", u"test"); // GOOD
|
||||
}
|
||||
|
||||
void test3() {
|
||||
@@ -49,5 +40,5 @@ void test3() {
|
||||
void test4() {
|
||||
char string[20];
|
||||
|
||||
sprintf(string, "test %S", L"test"); // BAD: `wchar_t` string parameter read as `char16_t` string [NOT DETECTED]
|
||||
sprintf(string, "test %S", L"test"); // BAD: `wchar_t` string parameter read as `char16_t` string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user