logging: Fix signed integer cast for isprint
Casting the value byte to char may result in it being a negative number. On some platforms this could lead to either UB, or a crash. Signed-off-by: Dennis Sitelew <dennis.sitelew@grandcentrix.net>
This commit is contained in:
parent
452592fc9a
commit
42f9b69f50
2 changed files with 2 additions and 2 deletions
|
@ -390,7 +390,7 @@ static void hexdump_line_print(const struct log_output *output,
|
|||
}
|
||||
|
||||
if (i < length) {
|
||||
char c = (char)data[i];
|
||||
unsigned char c = (unsigned char)data[i];
|
||||
|
||||
print_formatted(output, "%c",
|
||||
isprint((int)c) ? c : '.');
|
||||
|
|
|
@ -582,7 +582,7 @@ static void hexdump_line_print(const uint8_t *data, uint32_t length,
|
|||
}
|
||||
|
||||
if (i < length) {
|
||||
char c = (char)data[i];
|
||||
unsigned char c = (unsigned char)data[i];
|
||||
|
||||
*buf = isprint((int)c) ? c : '.';
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue