diff --git a/proj/intercept/src/intercept.c b/proj/intercept/src/intercept.c index 9e01b87..d666055 100644 --- a/proj/intercept/src/intercept.c +++ b/proj/intercept/src/intercept.c @@ -546,10 +546,10 @@ static uint8_t func_flags[256]; static size_t msg_bytes(char *buf, size_t maxlen, size_t len, const char *str, int flags) { size_t offset = flags & 1 ? snprintf(buf, maxlen, "\"") : snprintf(buf, maxlen, "%p:\"", str); for (int i = 0; i < len && offset <= maxlen - 2; i++) { - char ch = str[i]; + const uint8_t ch = str[i]; if (ch == '\\' || ch == '"') { buf[offset++] = '\\'; - buf[offset++] = ch; + buf[offset++] = (char)ch; } else if (ch == '\t') { buf[offset++] = '\\'; buf[offset++] = 't'; @@ -559,10 +559,10 @@ static size_t msg_bytes(char *buf, size_t maxlen, size_t len, const char *str, i } else if (ch == '\r') { buf[offset++] = '\\'; buf[offset++] = 'r'; - } else if ((ch >= 0 && ch < 0x20) || ch == 0x7F) { + } else if (ch < 0x20 || ch >= 0x7F) { offset += snprintf(buf + offset, maxlen - offset, "\\x%02x", ch); } else { - buf[offset++] = ch; + buf[offset++] = (char)ch; } } if (offset <= maxlen - 2) {