Skip to content

feat: improve and fix extended timestamp extra field parsing#713

Merged
Its-Just-Nans merged 14 commits intomasterfrom
extended-timestamp-checks
Mar 16, 2026
Merged

feat: improve and fix extended timestamp extra field parsing#713
Its-Just-Nans merged 14 commits intomasterfrom
extended-timestamp-checks

Conversation

@Its-Just-Nans
Copy link
Copy Markdown
Member

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the parsing of extended timestamps by introducing a more structured approach to flag handling and enhancing error detection. The changes ensure that the system gracefully handles malformed or incomplete timestamp data, preventing crashes and making the parsing logic more resilient and reliable.

Highlights

  • Improved Extended Timestamp Parsing: Introduced a dedicated ExtendedTimestampFlags enum to clearly define and manage the flags associated with extended timestamps, replacing direct bitwise comparisons.
  • Enhanced Error Handling: Implemented robust error handling using checked_sub for byte length calculations during parsing, preventing potential panics from subtraction overflows when encountering malformed or truncated extended timestamp data.
  • New Test Coverage: Added a new test case, test_extended_timestamp_overflow, to specifically validate that truncated extended timestamps correctly return an error instead of causing a panic.
Changelog
  • src/extra_fields/extended_timestamp.rs
    • Added ExtendedTimestampFlags enum and its associated impl blocks for clearer flag management.
    • Replaced direct bitwise operations for flag checking with the new ExtendedTimestampFlags::matching method.
    • Modified byte length decrement logic to use checked_sub for safer arithmetic, returning an error on underflow.
    • Included a new test test_extended_timestamp_overflow to verify the improved error handling for truncated data.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR improves extended timestamp handling by adding overflow protection and refactoring flag checks. However, there's a critical logic error in the matching method (line 26) that prevents access time and creation time from being parsed correctly. The bitwise AND comparison checks for equality with 1, but AcTime and CrTime flags have values 2 and 4 respectively, causing these fields to always be skipped.

Critical issue:

  • Line 26: Fix bitwise comparison to check != 0 instead of == 1

Once this is fixed, the overflow protection and test coverage additions are solid improvements.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment thread src/extra_fields/extended_timestamp.rs Outdated
Comment thread src/extra_fields/extended_timestamp.rs Fixed
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves robustness in parsing extended timestamps. The review identified a significant logic error in ExtendedTimestampFlags::matching that could lead to data integrity issues or security vulnerabilities due to incorrect bitmask validation. Additionally, an error message was found to be misleading, and a more accurate one is suggested. The PR also introduces ExtendedTimestampFlags for clarity and other minor improvements.

Comment thread src/extra_fields/extended_timestamp.rs
Comment thread src/extra_fields/extended_timestamp.rs Outdated
@Its-Just-Nans Its-Just-Nans self-assigned this Mar 7, 2026
@Its-Just-Nans
Copy link
Copy Markdown
Member Author

Its-Just-Nans commented Mar 7, 2026

Note

I can still improve the code

Edit: done

@Its-Just-Nans
Copy link
Copy Markdown
Member Author

Its-Just-Nans commented Mar 7, 2026

btw i think this condition (which is forcing the modTime when len == 5) was incorrect

let mod_time = if (flags & 0b0000_0001_u8 == 0b0000_0001_u8) || len == 5 {}

@Its-Just-Nans Its-Just-Nans requested a review from Pr0methean March 7, 2026 16:17
@Its-Just-Nans Its-Just-Nans mentioned this pull request Mar 8, 2026
2 tasks
Copy link
Copy Markdown
Member

@Pr0methean Pr0methean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain in the title what specific improvements this gives us from the user's perspective? Remember, a PR title is its CHANGELOG entry.

Comment thread src/extra_fields/extended_timestamp.rs
Comment thread src/extra_fields/extended_timestamp.rs Outdated
Its-Just-Nans and others added 2 commits March 10, 2026 21:34
Co-authored-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
Signed-off-by: n4n5 <git@n4n5.dev>
@Its-Just-Nans Its-Just-Nans changed the title feat: improve extended timestamp feat: improve and fix extended timestamp extra field parsing Mar 11, 2026
Copy link
Copy Markdown
Member

@Pr0methean Pr0methean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nitpick re naming convention; otherwise looks good.

Comment thread src/extra_fields/extended_timestamp.rs Fixed
@Its-Just-Nans Its-Just-Nans dismissed Pr0methean’s stale review March 15, 2026 23:26

Dismissing the review (now fixed) to be able to merge

@Its-Just-Nans Its-Just-Nans added this pull request to the merge queue Mar 15, 2026
Merged via the queue into master with commit cf3fa19 Mar 16, 2026
130 checks passed
@Its-Just-Nans Its-Just-Nans deleted the extended-timestamp-checks branch March 16, 2026 01:55
This was referenced Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants