@@ -1021,6 +1021,11 @@ class FormatLiteral extends Literal {
1021
1021
*/
1022
1022
int getMaxConvertedLength ( int n ) { result = max ( int l | l = getMaxConvertedLength ( n , _) | l ) }
1023
1023
1024
+ /**
1025
+ * Gets the maximum length of the string that can be produced by the nth
1026
+ * conversion specifier of this format string, specifying the estimation reason;
1027
+ * has no result if this cannot be determined.
1028
+ */
1024
1029
int getMaxConvertedLength ( int n , BufferWriteEstimationReason reason ) {
1025
1030
exists ( int len |
1026
1031
(
@@ -1238,6 +1243,13 @@ class FormatLiteral extends Literal {
1238
1243
result = max ( int l | l = getMaxConvertedLengthLimited ( n , _) | l )
1239
1244
}
1240
1245
1246
+ /**
1247
+ * Gets the maximum length of the string that can be produced by the nth
1248
+ * conversion specifier of this format string, specifying the reason for the
1249
+ * estimation, except that float to string conversions are assumed to be 8
1250
+ * characters. This is helpful for determining whether a buffer overflow is
1251
+ * caused by long float to string conversions.
1252
+ */
1241
1253
int getMaxConvertedLengthLimited ( int n , BufferWriteEstimationReason reason ) {
1242
1254
if this .getConversionChar ( n ) .toLowerCase ( ) = "f"
1243
1255
then result = this .getMaxConvertedLength ( n , reason ) .minimum ( 8 )
@@ -1319,10 +1331,21 @@ class FormatLiteral extends Literal {
1319
1331
*/
1320
1332
int getMaxConvertedLengthLimited ( ) { result = this .getMaxConvertedLengthAfterLimited ( 0 , _) }
1321
1333
1334
+ /**
1335
+ * Gets the maximum length of the string that can be produced by this format
1336
+ * string, specifying the reason for the estimate. Has no result if no estimate
1337
+ * can be found.
1338
+ */
1322
1339
int getMaxConvertedLengthWithReason ( BufferWriteEstimationReason reason ) {
1323
1340
result = this .getMaxConvertedLengthAfter ( 0 , reason )
1324
1341
}
1325
1342
1343
+ /**
1344
+ * Gets the maximum length of the string that can be produced by this format
1345
+ * string, specifying the reason for the estimate, except that float to string
1346
+ * conversions are assumed to be 8 characters. This is helpful for determining
1347
+ * whether a buffer overflow is caused by long float to string conversions.
1348
+ */
1326
1349
int getMaxConvertedLengthLimitedWithReason ( BufferWriteEstimationReason reason ) {
1327
1350
result = this .getMaxConvertedLengthAfterLimited ( 0 , reason )
1328
1351
}
0 commit comments