[cloud_firestore]: Creating Timestamp from DateTimes before 1970-01-01 could throw due to invalid nanosecond calculation #17189
Labels
Needs Attention
This issue needs maintainer attention.
platform: all
Issues / PRs which are for all platforms.
plugin: cloud_firestore
type: bug
Something isn't working
Is there an existing issue for this?
Which plugins are affected?
Cloud Firestore
Which platforms are affected?
Android, iOS, macOS, Web, Windows
Description
Creating a
Timestamp
(from packagecloud_firestore_platform_interface
) with the factoriesfromMicrosecondsSinceEpoch
andfromMillisecondsSinceEpoch
, passing a negative value with non-zero millisecond value (which could come from aDateTime
object representing a date before 1970-01-01, causes_validateRange
to throw because it fails the precondition_check(nanoseconds >= 0, 'nanoseconds', nanoseconds);
.The thrown exception is
Invalid argument(s): Timestamp nanoseconds out of range: -<nanoseconds>
This is due to erroneous calculation of nanoseconds in the body of the aforementioned factories.
Reproducing the issue
Firebase Core version
3.12.1
Flutter Version
3.29.1
Relevant Log Output
Flutter dependencies
No response
Additional context and comments
No response
The text was updated successfully, but these errors were encountered: