Skip to content

cast to unsigned char before std::isprint in jsonParseStrict#16785

Open
metsw24-max wants to merge 1 commit into
argotorg:developfrom
metsw24-max:isprint-unsigned-char
Open

cast to unsigned char before std::isprint in jsonParseStrict#16785
metsw24-max wants to merge 1 commit into
argotorg:developfrom
metsw24-max:isprint-unsigned-char

Conversation

@metsw24-max

Copy link
Copy Markdown

Signed char passed to std::isprint in jsonParseStrict

The formatter walks the nlohmann error string a char at a time and hands each value to std::isprint. Because the message echoes the offending input bytes, anything from 0x80 upward arrives as a negative int on signed-char builds, which falls outside the range the <cctype> overload is defined for. Casting to unsigned char first keeps the argument valid and lines up with the isPrint helper already used elsewhere in the tree.

The path is reachable from untrusted input via the standard-JSON interface and the LSP transport, so it seemed worth tidying even though most libc builds happen to tolerate it.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant