Skip to content

Conversation

shnayak-msft
Copy link
Collaborator

Description

This PR addresses an integer overflow issue in timestamp handling, particularly for dates before 1970 (unix epoch time), which are unsupported due to limitations in int64 and UnixNano usage.

Root Cause:

  • UnixNano uses int64, supporting ±292 years from 1970, but our implementation only handled positive values.
  • Pre-1970 timestamps failed due to incorrect use of time.Unix(0, nanoSeconds) with uint64.
  • Even with signed values, the lower bound is 1678, leaving 1601–1678 unsupported.
  • Additional overflow occurred in StatxTimestampToFiletime() due to unchecked arithmetic on seconds and nanoseconds.

Fix:

  • Replaced Unix epoch base with Windows epoch time (1601) in nanoseconds.
  • Used uint64 to represent time, extending support from 1601 to 2185.
  • Preserved existing struct definitions and ensured backward compatibility.
  • Implemented workarounds for Go’s time package limitations on nanosecond precision

Status:

  • Manual testing passed.
  • Some pipeline failures observed due to precision mismatches between Go time and filesystem time (under investigation).

Type of Change

  • [x ] Bug fix
  • New feature
  • Documentation update required
  • Code quality improvement
  • Other (describe):

How Has This Been Tested?

Thank you for your contribution to AzCopy!

Current file timestamp handling is based on Unix epoch time which doesn't handle dates closer to windows epoch time. This change takes care of that issue for both linux and windows. It also makes sure the correct timestamps are updated in cloud.
@@ -362,7 +362,7 @@ type JobPartPlanTransfer struct {
// We use a dedicated field for this because the alternative (of doing something fancy the names) was too complex and error-prone
EntityType common.EntityType
// ModifiedTime represents the last time at which source was modified before start of transfer stored as nanoseconds.
ModifiedTime int64
ModifiedTime uint64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be sure to update the schema version at the top of this file.

@gapra-msft gapra-msft added the XDM label Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants