Skip to content

cast char to unsigned char before ctype calls in cctz parser#2099

Closed
nabhan06 wants to merge 1 commit into
abseil:masterfrom
nabhan06:cctz-ctype-unsigned-char
Closed

cast char to unsigned char before ctype calls in cctz parser#2099
nabhan06 wants to merge 1 commit into
abseil:masterfrom
nabhan06:cctz-ctype-unsigned-char

Conversation

@nabhan06

@nabhan06 nabhan06 commented Jul 2, 2026

Copy link
Copy Markdown

The parse() and format() helpers in time_zone_format.cc feed a raw char straight into std::isspace() and std::isdigit() while scanning the input and format strings. When char is signed and a byte is 0x80 or higher the value is negative, which is undefined behavior for the ctype functions since the argument has to be representable as unsigned char or equal to EOF, and it can index outside the classification table on some libc implementations. This is reachable from ParseTime with any input or format containing a high-bit byte. Casting each argument to unsigned char fixes every site, the same guard already used for the ctype calls in absl/strings/escaping.cc.

@derekmauro

Copy link
Copy Markdown
Member

Please send this fix to https://github.com/google/cctz. We only import this code directly from this repository.

@derekmauro derekmauro closed this Jul 2, 2026
@nabhan06

nabhan06 commented Jul 2, 2026

Copy link
Copy Markdown
Author

Got it, didn't realize this was a straight import. I'll send the patch to google/cctz instead. Thanks for the pointer.

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.

2 participants