Skip to content

Commit b979f02

Browse files
authored
C++: fix OverrunWrite for backward compatibility
Rather than testing for `TypeBoundsAnalysis`, we test that the reason is not `ValueFlowAnalysis` (which is reported by the new `cpp/very-likely-overruning-write` query), so that if a client has overridden `BufferWrite::getMaxData` the `NoSpecifiedEstimateReason` is taken into account.
1 parent db6214f commit b979f02

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ import semmle.code.cpp.commons.Alloc
2121
* See CWE-120/UnboundedWrite.ql for a summary of CWE-120 alert cases.
2222
*/
2323

24-
from BufferWrite bw, Expr dest, int destSize, int estimated, TypeBoundsAnalysis reason
24+
from BufferWrite bw, Expr dest, int destSize, int estimated, BufferWriteEstimationReason reason
2525
where
2626
not bw.hasExplicitLimit() and // has no explicit size limit
2727
dest = bw.getDest() and
2828
destSize = getBufferSize(dest, _) and
2929
estimated = bw.getMaxDataLimited(reason) and
30+
// we exclude ValueFlowAnalysis as it is reported in cpp/very-likely-overruning-write
31+
not reason instanceof ValueFlowAnalysis and
3032
// we can deduce that too much data may be copied (even without
3133
// long '%f' conversions)
3234
estimated > destSize

0 commit comments

Comments
 (0)