From: Kiran Rangoon <kiranrangoon0@gmail.com>
To: util-linux@vger.kernel.org
Cc: thomas@t-8ch.de, Kiran Rangoon <kiranrangoon0@gmail.com>
Subject: [PATCH v5 0/4] libuuid: Fix pre-1970 UUID timestamp overflow
Date: Sun, 28 Dec 2025 22:50:56 -0500 [thread overview]
Message-ID: <20251229035100.5778-1-kiranrangoon0@gmail.com> (raw)
> On 2025-12-18 16:31:21-0500, Kiran Rangoon wrote:
> > I revised the code in response to your feedback.
> Thanks!
> > > Looking at this more closely: __uuid_time() is directly exposed to users
> > > of libuuid as uuid_time(). This means that any change of the function's
> > > contract would break all external users and should be avoided at all
> > > costs.
> >
> > Reversed the change there.
>
> Your new revision is based on top of your old series.
> Instead it should always be based on upstream code.
> In this case the util-linux master branch.
Fixed in v4: I rebased directly on origin/master instead of building
on my previous patch series.
>
> > > Fortunately it turns out that the timestamps embedded in UUIDs
> > > only use 60 bits. This means that the calculation can be performed in an
> > > int64_t without any risk of over- or underflow. Please try to implement
> > > it that way instead.
> >
> > I'm using signed int64_t here as suggested.
> >
> > > It might be useful to change the signature of gregorian_to_unix() to
> > > "static void gregorian_to_unix(uint64_t ts, struct timeval *tv)".
> >
> > I revised the code to use a struct timeval now.
>
> That looks good. However that refactoring should be in its own commit.
> More on that below.
Fixed in v4: The refactoring is now in its own dedicated commit (patch 2/4).
>
> > > Also please perform each logical step in a dedicated commit.
> >
> > > I made two commits, one for the code change and the other for tests, but
> > > if there is a way you would perfer me to do it I could change it.
> >
> The test is a bad candidate to split out. After each commit the
> repository needs to be in a consistent state, which means that the code
> builds and the tests pass. As the code change breaks the existing test,
> the test needs to be adapted in lockstep.
Understood. In v4, the test updates are included with the code changes
that require them, maintaining repository consistency at each commit.
>
> I see the following commits:
>
> 1) Switch to the simpler constant definition
> 2) Pass 'struct timeval' to gregorian_to_unix()
> 3) Fix the overflow, adapt the existing test
> 4) Add a hand full of additional testcases.
Implemented exactly as suggested in v4.
> Also this patch now lost its useful commit message which got replaced by
> our discussion. This should not happen. Each commit should explain why
> it is being done.
Fixed in v4: All commits now have proper descriptive messages explaining
the rationale for each change.
>
> > + const uint64_t offset = 0x01B21DD213814000ULL;
> > + int64_t t = (int64_t) ts - (int64_t) offset;
>
> Whitespace corruption?
Fixed in v4: Proper tab indentation is used throughout.
---
This v4 patch series addresses all the feedback points above:
Kiran Rangoon (4):
libuuid: simplify gregorian-to-unix offset calculation
libuuid: refactor gregorian_to_unix to populate timeval directly
libuuid: fix timestamp overflow for pre-1970 dates
tests: correct UUID timestamp test expectations
libuuid/src/uuid_time.c | 15 +++++++--------
tests/expected/uuid/uuidparse | 5 ++++-
tests/ts/uuid/uuidparse | 3 +++
3 files changed, 14 insertions(+), 9 deletions(-)
--
2.47.3
next reply other threads:[~2025-12-29 3:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-29 3:50 Kiran Rangoon [this message]
2025-12-29 3:50 ` [PATCH v5 1/4] libuuid: simplify gregorian-to-unix offset calculation Kiran Rangoon
2025-12-29 3:50 ` [PATCH v5 2/4] libuuid: refactor gregorian_to_unix to populate timeval directly Kiran Rangoon
2025-12-29 3:50 ` [PATCH v5 3/4] libuuid: fix timestamp overflow for pre-1970 dates Kiran Rangoon
2025-12-29 3:51 ` [PATCH v5 4/4] tests: correct UUID timestamp test expectations Kiran Rangoon
2026-01-05 13:35 ` [PATCH v5 0/4] libuuid: Fix pre-1970 UUID timestamp overflow Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251229035100.5778-1-kiranrangoon0@gmail.com \
--to=kiranrangoon0@gmail.com \
--cc=thomas@t-8ch.de \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox