mirror of
https://github.com/wownero/wownero.git
synced 2026-11-11 10:53:54 +01:00
The <cctype> functions require their argument to be representable as unsigned char or to equal EOF. char is signed on the platforms Monero targets, so every byte >= 0x80 reaches them negative, which is undefined behaviour. All six call sites take bytes that come from outside the process: hex_to_dec_2bytes() percent-escapes in a payment URI http_client.h the status line of an HTTP response updates.cpp the hash field of a DNS update record glibc and the macOS libc happen to tolerate -128..-1 because their tables carry padding below zero, so this is quiet in practice on those, but it is still out of contract and other libcs index without that cushion. Cast to unsigned char at each call. The conversion is behaviour-preserving for the ASCII these actually test: for a byte such as 0xC3, toupper() returns it unchanged in the C locale, it narrows back to char, memchr() misses it in the hex table, and hex_to_dec_2bytes() falls through to the existing literal "%XY" output exactly as before. epee::misc_utils::parse::isdigit/isalpha/isspace are separate char-taking helpers and are already well defined, so they are untouched, as is is_base64(), which already takes unsigned char.