]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libuuid: fix timestamp overflow for pre-1970 dates
authorKiran Rangoon <kiranrangoon0@gmail.com>
Mon, 29 Dec 2025 03:50:59 +0000 (22:50 -0500)
committerThomas Weißschuh <thomas@t-8ch.de>
Mon, 29 Dec 2025 13:43:34 +0000 (14:43 +0100)
Use int64_t arithmetic to correctly handle timestamps before Unix epoch.
This fixes the overflow that was causing UUID timestamps from 1582 to
appear as far-future dates. Update test expectations accordingly.

Signed-off-by: Kiran Rangoon <kiranrangoon0@gmail.com>
Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de>
libuuid/src/uuid_time.c
tests/expected/uuid/uuidparse

index 2f7c6652c8904e8510cc2389c9ed51b28d41702d..63179fd76c3519385ea3b741395898365c109559 100644 (file)
@@ -63,7 +63,7 @@ time_t __uuid_time(const uuid_t uu, struct timeval *ret_tv);
 static void gregorian_to_unix(uint64_t ts, struct timeval *tv)
 {
        const uint64_t offset = 0x01B21DD213814000ULL;
-       uint64_t clock_reg = ts - offset;
+       int64_t clock_reg = (int64_t)(ts - offset);
        tv->tv_sec = clock_reg / 10000000;
        tv->tv_usec = (clock_reg % 10000000) / 10;
 }
index 9edb05e4e94430e57585b31ad025c98b5992da42..e44964b302198d30c83ae56b2498f57d3757fea3 100644 (file)
@@ -11,7 +11,7 @@ UUID                                  VARIANT   TYPE       TIME
 00000000-0000-3000-8000-000000000000  DCE       name-based 
 00000000-0000-4000-8000-000000000000  DCE       random     
 00000000-0000-5000-8000-000000000000  DCE       sha1-based 
-00000000-0000-6000-8000-000000000000  DCE       time-v6    60038-03-11 05:36:10,955161+00:00
+00000000-0000-6000-8000-000000000000  DCE       time-v6    1582-10-15 00:00:00,000000+00:00
 00000000-0000-0000-d000-000000000000  Microsoft            
 00000000-0000-1000-d000-000000000000  Microsoft            
 00000000-0000-2000-d000-000000000000  Microsoft