Skip to content

GH-54646: [C++] Reject years out of range in the strptime timestamp parser - #54658

Closed
pearu wants to merge 1 commit into
apache:mainfrom
pearu:pearu/strptime-year-range
Closed

pearu wants to merge 1 commit into
apache:mainfrom
pearu:pearu/strptime-year-range

Conversation

@pearu

@pearu pearu commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

The parser computed the year as tm_year + 1900, which can overflow int (e.g. with %s), and passed it to date::year, which holds 16 bits, so a year out of range gave a wrong timestamp.

What changes are included in this PR?

The year is computed in 64 bits and rejected if date::year cannot hold it.

Are these changes tested?

Yes, TimestampParser.StrptimeYearOutOfRange covers a year that wraps around and one where tm_year + 1900 overflows int. It needs %s and is skipped where strptime does not parse %s into 64 bits (e.g. on Windows).

Are there any user-facing changes?

Values whose year does not fit in 16 bits no longer parse with strptime formats.

AI usage disclosure

Developed with AI assistance (Claude Code): the fix, the test and this description were AI-generated under my direction and reviewed line by line by me. I own and can debug these changes. No copyrighted material is included.

…tamp parser

The year was computed as tm_year + 1900, which can overflow int (e.g. with
%s), and passed to date::year, which holds 16 bits, so out-of-range years
gave wrong timestamps. Compute the year in 64 bits and reject it if
date::year cannot hold it.

Drafted by Claude Code (an AI agent) and reviewed & approved by pearu.
@github-actions

Copy link
Copy Markdown

Thanks for opening a pull request!

This pull request has been automatically closed because you currently have 4 open pull requests, which is more than the limit of 3.

Due to the increase in pull requests opened by AI bots, and in order to keep the review queue manageable, Apache Arrow limits contributors without repository access to at most 3 concurrently open pull requests. This helps make sure each pull request gets the attention it needs and that work in progress does not go stale.

Once one of your other open pull requests has been merged or closed, you are welcome to reopen this one.

See also:

@github-actions github-actions Bot closed this Oct 19, 2026
@github-actions github-actions Bot added the awaiting review Awaiting review label Oct 19, 2026
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #54646 has been automatically assigned in GitHub to PR creator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant