Skip to content

Commit b7f47f7

Browse files
committed
C++: Remove FPs from cpp/badly-bounded-write
1 parent fd74698 commit b7f47f7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ from BufferWrite bw, int destSize
2525
where
2626
bw.hasExplicitLimit() and // has an explicit size limit
2727
destSize = max(getBufferSize(bw.getDest(), _)) and
28-
bw.getExplicitLimit() > destSize // but it's larger than the destination
28+
bw.getExplicitLimit() > destSize and // but it's larger than the destination
29+
not bw.getDest().getUnderlyingType().stripType() instanceof ErroneousType // destSize may be incorrect
2930
select bw,
3031
"This '" + bw.getBWDesc() + "' operation is limited to " + bw.getExplicitLimit() +
3132
" bytes but the destination is only " + destSize + " bytes."
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
| 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. |
21
| 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. |
32
| 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. |

0 commit comments

Comments
 (0)