@@ -15,7 +15,7 @@ import semmle.code.cpp.models.interfaces.SideEffect
1515private class Sscanf extends ArrayFunction , TaintFunction , AliasFunction , SideEffectFunction {
1616 Sscanf ( ) {
1717 this .hasGlobalOrStdName ( [
18- "sscanf" , // sscanf(src_stream , format, args...)
18+ "sscanf" , // sscanf(src , format, args...)
1919 "swscanf" , // swscanf(src, format, args...)
2020 "fscanf" , // fscanf(src_stream, format, args...)
2121 "fwscanf" // fwscanf(src_stream, format, args...)
@@ -32,11 +32,16 @@ private class Sscanf extends ArrayFunction, TaintFunction, AliasFunction, SideEf
3232 ] )
3333 }
3434
35+ private predicate isSscanf ( ) { this .getName ( ) .regexpMatch ( ".*sn?w?scanf.*" ) }
36+
3537 override predicate hasArrayWithNullTerminator ( int bufParam ) {
36- bufParam = [ 0 , getFormatPosition ( ) ]
38+ bufParam = getFormatPosition ( )
39+ or
40+ isSscanf ( ) and
41+ bufParam = 0
3742 }
3843
39- override predicate hasArrayInput ( int bufParam ) { bufParam = [ 0 , getFormatPosition ( ) ] }
44+ override predicate hasArrayInput ( int bufParam ) { hasArrayWithNullTerminator ( bufParam ) }
4045
4146 private int getLengthPosition ( ) {
4247 this .getName ( ) .matches ( "\\_sn%" ) and
0 commit comments