C++: Test case for cpp/badly-bounded-write

This commit is contained in:
Calum Grant
2024-12-05 13:16:59 +00:00
parent 9c4030ed45
commit fd7469848e
2 changed files with 12 additions and 0 deletions

View File

@@ -1,2 +1,3 @@
| errors.c:10:5:10:12 | call to swprintf | This 'call to swprintf' operation is limited to 12 bytes but the destination is only 3 bytes. |
| tests.c:43:3:43:10 | call to snprintf | This 'call to snprintf' operation is limited to 111 bytes but the destination is only 110 bytes. |
| tests.c:46:3:46:10 | call to snprintf | This 'call to snprintf' operation is limited to 111 bytes but the destination is only 110 bytes. |

View File

@@ -0,0 +1,11 @@
// semmle-extractor-options: --expect_errors
typedef unsigned long size_t;
typedef int wchar_t;
int swprintf(wchar_t *s, size_t n, const wchar_t *format, ...);
void test_extraction_errors() {
WCHAR buffer[3];
swprintf(buffer, 3, L"abc");
}