Skip to content

Commit a002f59

Browse files
committed
C++: Undo BadlyBoundedWrite change from github#13929
This rolls back the query change, ensuring that there is no need for a change note.
1 parent 478a105 commit a002f59

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
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() +
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +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. |
12
| 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. |
25
| 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. |
36
| 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ void test3() {
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)