From: Tobias Stoeckmann Date: Wed, 10 Jun 2026 18:09:24 +0000 (+0200) Subject: time: Use archive_integer.h X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=710503d83c8a103e2b59de6dce015b38059dfb67;p=thirdparty%2Flibarchive.git time: Use archive_integer.h Use archive_integer's checked integer arithmetic. Signed-off-by: Tobias Stoeckmann --- diff --git a/libarchive/archive_time.c b/libarchive/archive_time.c index 0f02345f3..bc7708288 100644 --- a/libarchive/archive_time.c +++ b/libarchive/archive_time.c @@ -35,6 +35,7 @@ #include #endif +#include "archive_integer.h" #include "archive_private.h" #include "archive_time_private.h" @@ -157,15 +158,11 @@ unix_to_ntfs(int64_t secs, uint32_t nsecs) if (secs < -(int64_t)NTFS_EPOC_TIME) return 0; - ntfs = secs + NTFS_EPOC_TIME; - - if (ntfs > UINT64_MAX / NTFS_TICKS) - return UINT64_MAX; - - ntfs *= NTFS_TICKS; - - if (ntfs > UINT64_MAX - nsecs/100) + /* (secs + NTFS_EPOC_TIME) * NTFS_TICKS + nsecs / 100 */ + if (archive_ckd_add_u64(&ntfs, secs, NTFS_EPOC_TIME) || + archive_ckd_mul_u64(&ntfs, ntfs, NTFS_TICKS) || + archive_ckd_add_u64(&ntfs, ntfs, nsecs / 100)) return UINT64_MAX; - return ntfs + nsecs/100; + return ntfs; }