Skip to content

BUG: fix heap buffer overflow in timedelta to string casts#31110

Merged
charris merged 1 commit into
numpy:mainfrom
ngoldbaum:fix-datetime-to-string-overflow
Apr 1, 2026
Merged

BUG: fix heap buffer overflow in timedelta to string casts#31110
charris merged 1 commit into
numpy:mainfrom
ngoldbaum:fix-datetime-to-string-overflow

Conversation

@ngoldbaum

Copy link
Copy Markdown
Member

PR summary

Fixes #31109.

The resolve_descriptors implementation doesn't account for cases where the output string isn't large enough to hold the entire converted string.

The fix is to clamp the output dtype size to the input dtype size, if there's an explicit size.

AI Disclosure

No AI used.

@ngoldbaum ngoldbaum added 09 - Backport-Candidate PRs tagged should be backported 00 - Bug labels Mar 31, 2026
@ngoldbaum ngoldbaum added this to the 2.4.5 release milestone Mar 31, 2026
@charris charris merged commit 25b0d33 into numpy:main Apr 1, 2026
85 checks passed
@charris

charris commented Apr 1, 2026

Copy link
Copy Markdown
Member

Thanks Nathan.

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Apr 10, 2026
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.

BUG: timedelta64 to string conversion writes out-of-bounds

2 participants