-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18222 from github/calumgrant/bmn/badly-bounded-write
C++: Fix FPs in cpp/badly-bounded-write caused by extraction errors
- Loading branch information
Showing
3 changed files
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: minorAnalysis | ||
--- | ||
* The "Badly bounded write" query (`cpp/badly-bounded-write`) no longer produces results if there is an extraction error in the type of the output buffer. |
11 changes: 11 additions & 0 deletions
11
cpp/ql/test/query-tests/Security/CWE/CWE-120/semmle/tests/errors.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} |