AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 37 Bitcoin

avoid UB when calling ctype functions

Public commit record

What the developer wrote

Authored by Matt Whitlock

68/100 · Adequate
avoid UB when calling ctype functions

The character classification functions in <ctype.h> are designed to
classify characters returned by <stdio.h> getchar() and friends, which
return characters as signed integers in the range 0 to 255 or EOF. The
behavior of the ctype functions is undefined if they are passed a value
outside of that range, which may happen if they are passed a char-typed
value and the system's char type is signed.

<ccan/str/str.h> defines some inline utility functions that perform the
necessary cast to coerce a char-typed argument into the allowed value
range. Call these wrappers instead of the bare ctype functions when
classifying char-typed characters.

Changelog-None
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a low-level programming bug in four source files. The standard C library functions used to check whether a character is a digit or whitespace (like isdigit and isspace) can misbehave or crash when given a character whose numeric value is negative on systems where the char type is signed. The patch replaces those direct calls with safer project-specific wrappers that cast the value to an unsigned type first. This is a defensive hardening change rather than a fix for a known exploitable vulnerability.

Recommended action

Treat as a defensive hardening patch. Apply it to reduce undefined-behavior surface, especially on platforms with signed char. No immediate incident response is warranted unless additional evidence shows a reproducible crash or exploit path.

Security signals we found

01

Undefined-behavior mitigation in character classification

02

Use of project-specific ctype wrappers (cisdigit, cisspace)

03

Signed char promotion risk on affected platforms

04

Potential denial-of-service or crash vector from out-of-range ctype input

05

No explicit security advisory or CVE referenced in commit

Risk score

Why this scored 37/100

Our methodology →
Potential impact 8/30
Exploitability 5/25
Stealth signal 6/15
Affected reach 7/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.