[lld] [LLD] Use uint64_t timestamp to overcome potential overflow (PR #81665)

Jinsong Ji via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 14:30:37 PST 2024


================
@@ -1830,7 +1830,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
       StringRef value(*epoch);
       if (value.getAsInteger(0, config->timestamp))
         fatal(Twine("invalid SOURCE_DATE_EPOCH timestamp: ") + value +
-              ".  Expected 32-bit integer");
+              ".  Expected 64-bit integer");
     } else {
       config->timestamp = time(nullptr);
----------------
jsji wrote:

1495973 [Use of 32-bit time_t](https://scan6.scan.coverity.com/doc/en/cov_checker_ref.html#static_checker_Y2K38_SAFETY)
The time value stored in this integer will represent a different, but possibly valid, time.

In lld::​coff::​LinkerDriver::​linkerMain(llvm::​ArrayRef<char const *>): A 64-bit time_t value is stored in a smaller width integer. ([CWE-197](http://cwe.mitre.org/data/definitions/197.html))

https://github.com/llvm/llvm-project/pull/81665


More information about the llvm-commits mailing list