Skip to content

Commit 1643a83

Browse files
authored
Merge pull request github#13996 from jbj/accept-BadlyBoundedWrite
C++: Accept regression in test after evaluator fix
2 parents 222aa41 + a002f59 commit 1643a83

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

cpp/ql/src/Security/CWE/CWE-120/BadlyBoundedWrite.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import semmle.code.cpp.security.BufferWrite
2424
from BufferWrite bw, int destSize
2525
where
2626
bw.hasExplicitLimit() and // has an explicit size limit
27-
destSize = max(getBufferSize(bw.getDest(), _)) and
27+
destSize = getBufferSize(bw.getDest(), _) and
2828
bw.getExplicitLimit() > destSize // but it's larger than the destination
2929
select bw,
3030
"This '" + bw.getBWDesc() + "' operation is limited to " + bw.getExplicitLimit() +

cpp/ql/src/change-notes/2023-08-09-badly-bounded-write.md

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
| tests2.cpp:59:3:59:10 | call to snprintf | This 'call to snprintf' operation is limited to 13 bytes but the destination is only 0 bytes. |
2+
| tests2.cpp:59:3:59:10 | call to snprintf | This 'call to snprintf' operation is limited to 13 bytes but the destination is only 2 bytes. |
3+
| tests2.cpp:63:3:63:10 | call to snprintf | This 'call to snprintf' operation is limited to 13 bytes but the destination is only 0 bytes. |
4+
| tests2.cpp:63:3:63:10 | call to snprintf | This 'call to snprintf' operation is limited to 13 bytes but the destination is only 3 bytes. |
15
| 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. |
26
| 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. |

cpp/ql/test/query-tests/Security/CWE/CWE-120/semmle/tests/tests2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ void test3() {
5656
dest1 = (char*)malloc(sizeof(src));
5757
if (!dest1)
5858
return;
59-
snprintf(dest1, sizeof(src), "%s", src); // GOOD
59+
snprintf(dest1, sizeof(src), "%s", src); // GOOD [FALSE POSITIVE]
6060
dest2 = (char*)malloc(3);
6161
if (!dest2)
6262
return;
63-
snprintf(dest2, sizeof(src), "%s", src); // BAD [NOT DETECTED]: buffer overflow
63+
snprintf(dest2, sizeof(src), "%s", src); // BAD (but with duplicate alerts)
6464
}

0 commit comments

Comments
 (0)