libuuid: Fix pre-1970 UUID timestamp overflow
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest4 patches 1 replyIn review
- v44 patches 2 repliesSuperseded
- v21 patch 4 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 1 patch | 1 reply | Superseded |
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | libuuid: simplify gregorian-to-unix offset calculationlibuuid/ | +2 | 0 replies | |
| 2/4 | libuuid: refactor gregorian_to_unix to populate timeval directlylibuuid/ | +6 | 0 replies | |
| 3/4 | libuuid: fix timestamp overflow for pre-1970 dateslibuuid/ tests/ | +2 | 0 replies | |
| 4/4 | tests: correct UUID timestamp test expectationstests/ tests/ | +6 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.
Cover letter [PATCH v5 0/4] libuuid: Fix pre-1970 UUID timestamp overflow
Quoted 10 lines · Kiran Rangoon
Quoted 1 line
I revised the code in response to your feedback.
Thanks!
Quoted 5 lines
Quoted 4 lines
Looking at this more closely:
__uuid_time()is directly exposed to users of libuuid asuuid_time(). This means that any change of the function's contract would break all external users and should be avoided at all costs.
Quoted 5 lines
Quoted 1 line
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.
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
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_twithout any risk of over- or underflow. Please try to implement it that way instead.I'm using signed
int64_there as suggested.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
It might be useful to change the signature of
gregorian_to_unix()to "static voidgregorian_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).
Quoted 10 lines
Quoted 6 lines
Quoted 5 lines
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.
Quoted 7 lines
I see the following commits:
1) Switch to the simpler constant definition
2) Pass 'struct timeval' togregorian_to_unix()
3) Fix the overflow, adapt the existing test
4) Add a hand full of additional testcases.
Implemented exactly as suggested in v4.
Quoted 3 lines
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.
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ 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(-)
Signature · 1 line
2.47.3