Bug: newTimestampFromTime panics on dates outside ~1678-2262 due to UnixNano overflow #15
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In
mfer/serialize.go,newTimestampFromTimecomputes nanoseconds via:time.Time.UnixNano()returns anint64that overflows for dates before approximately year 1678 or after year 2262. The Go documentation explicitly warns: "The result is undefined if the Unix time in nanoseconds cannot be represented by an int64 (a date before the year 1678 or after 2262). Note that this means the result of calling UnixNano on the zero Time is undefined."Archival tools may encounter files with very old modification times (e.g., zero time, or dates from early computing history). This would cause a panic.
Note: The
ModTime.Timestamp()method inbuilder.gocorrectly usest.Nanosecond()which never panics. OnlynewTimestampFromTimehas this bug.Fix: Use
t.Nanosecond()instead of the manualUnixNano()subtraction, matching the pattern already used inModTime.Timestamp().