@@ -16,9 +16,19 @@ import semmle.code.cpp.controlflow.IRGuards
1616/**
1717 * Functions whose operations should never be considered a
1818 * source or sink of a dangerous leap year operation.
19+ * The general concept is to add conversion functions
20+ * that convert one time type to another. Often
21+ * other ignorable operation heuristics will filter these,
22+ * but some cases, the simplest approach is to simply filter
23+ * the function entirely.
24+ * Note that flow through these functions should still be allowed
25+ * we just cannot start or end flow from an operation to a
26+ * year assignment in one of these functions.
1927 */
2028class IgnorableFunction extends Function {
2129 IgnorableFunction ( ) {
30+ this instanceof TimeConversionFunction
31+ or
2232 // Helper utility in postgres with string time conversions
2333 this .getName ( ) = "DecodeISO8601Interval"
2434 or
@@ -119,6 +129,9 @@ predicate isLikelyConversionConstant(int c) {
119129 i = 1899 or // Observed in uses with 1900 to address off by one scenarios
120130 i = 292275056 or // qdatetime.h Qt Core year range first year constant
121131 i = 292278994 or // qdatetime.h Qt Core year range last year constant
132+ i = 1601 or // Windows FILETIME epoch start year
133+ i = 1970 or // Unix epoch start year
134+ i = 70 or // Unix epoch start year short form
122135 i = 0
123136 )
124137}
@@ -351,9 +364,12 @@ module OperationToYearAssignmentConfig implements DataFlow::ConfigSig {
351364 predicate isBarrier ( DataFlow:: Node n ) {
352365 exists ( ArrayExpr arr | arr .getArrayOffset ( ) = n .asExpr ( ) )
353366 or
354- n .asExpr ( ) .getUnspecifiedType ( ) instanceof PointerType
367+ n .getType ( ) .getUnspecifiedType ( ) instanceof PointerType
368+ or
369+ n .getType ( ) .getUnspecifiedType ( ) instanceof CharType
355370 or
356- n .asExpr ( ) .getUnspecifiedType ( ) instanceof CharType
371+ // If a type resembles "string" ignore flow (likely string conversion, currently ignored)
372+ n .getType ( ) .getUnspecifiedType ( ) .stripType ( ) .getName ( ) .toLowerCase ( ) .matches ( "%string%" )
357373 or
358374 n .asExpr ( ) instanceof IgnorableOperation
359375 or
0 commit comments