@@ -109,24 +109,25 @@ abstract class FormattingFunction extends ArrayFunction, TaintFunction {
109109 }
110110
111111 /**
112- * Gets the position at which the output parameter, if any, occurs. This may
113- * be a buffer that characters are written to if this function behaves like
114- * `sprintf`. Alternatively it may be a stream that is used for output if
115- * this function behaves like `fprintf` (see `isOutputStream `).
112+ * Gets the position at which the output parameter, if any, occurs. If
113+ * `isStream` is `true`, the output parameter is a stream (that is, this
114+ * function behaves like `fprintf`). If `isStream` is `false`, the output
115+ * parameter is a buffer (that is, this function behaves like `sprintf `).
116116 */
117- int getOutputParameterIndex ( ) { none ( ) }
117+ int getOutputParameterIndex ( boolean isStream ) { none ( ) }
118118
119119 /**
120- * Holds if this function outputs to a global stream such as standard output,
121- * standard error or a system log. For example `printf`.
120+ * Gets the position at which the output parameter, if any, occurs.
121+ *
122+ * DEPRECATED: use `getOutputParameterIndex(boolean isStream)` instead.
122123 */
123- predicate isOutputGlobal ( ) { none ( ) }
124+ deprecated int getOutputParameterIndex ( ) { result = getOutputParameterIndex ( _ ) }
124125
125126 /**
126- * Holds if this function outputs to the stream indicated by
127- * `getOutputParameterIndex()`, that is, this function behaves like `fprintf `.
127+ * Holds if this function outputs to a global stream such as standard output,
128+ * standard error or a system log. For example `printf `.
128129 */
129- predicate isOutputStream ( ) { none ( ) }
130+ predicate isOutputGlobal ( ) { none ( ) }
130131
131132 /**
132133 * Gets the position of the first format argument, corresponding with
@@ -156,20 +157,18 @@ abstract class FormattingFunction extends ArrayFunction, TaintFunction {
156157 }
157158
158159 override predicate hasArrayWithVariableSize ( int bufParam , int countParam ) {
159- bufParam = getOutputParameterIndex ( ) and
160+ bufParam = getOutputParameterIndex ( false ) and
160161 countParam = getSizeParameterIndex ( )
161162 }
162163
163164 override predicate hasArrayWithUnknownSize ( int bufParam ) {
164- bufParam = getOutputParameterIndex ( ) and
165+ bufParam = getOutputParameterIndex ( false ) and
165166 not exists ( getSizeParameterIndex ( ) )
166167 }
167168
168169 override predicate hasArrayInput ( int bufParam ) { bufParam = getFormatParameterIndex ( ) }
169170
170- override predicate hasArrayOutput ( int bufParam ) {
171- bufParam = getOutputParameterIndex ( ) and not isOutputStream ( )
172- }
171+ override predicate hasArrayOutput ( int bufParam ) { bufParam = getOutputParameterIndex ( false ) }
173172
174173 override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
175174 exists ( int arg |
@@ -178,7 +177,7 @@ abstract class FormattingFunction extends ArrayFunction, TaintFunction {
178177 arg >= getFirstFormatArgumentIndex ( )
179178 ) and
180179 input .isParameterDeref ( arg ) and
181- output .isParameterDeref ( getOutputParameterIndex ( ) )
180+ output .isParameterDeref ( getOutputParameterIndex ( _ ) )
182181 )
183182 }
184183}
0 commit comments