Merge pull request #1693 from Doridian/fix/x_to_buffer2

Partial revert of previous change, hex_max_len is bytes
This commit is contained in:
Iceman 2022-06-15 17:20:30 +02:00 committed by GitHub
commit a919886826
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -187,11 +187,10 @@ void hex_to_buffer(uint8_t *buf, const uint8_t *hex_data, const size_t hex_len,
char *tmp = tmp_base;
size_t max_len = (hex_len > hex_max_len) ? hex_max_len : hex_len;
size_t str_max_len = hex_max_len * (2 + spaces_between);
size_t i;
for (i = 0; i < max_len; ++i, tmp += 2 + spaces_between) {
snprintf(tmp, str_max_len - (tmp - tmp_base), (uppercase) ? "%02X" : "%02x", (unsigned int) hex_data[i]);
snprintf(tmp, hex_max_len - (tmp - tmp_base), (uppercase) ? "%02X" : "%02x", (unsigned int) hex_data[i]);
for (size_t j = 0; j < spaces_between; j++)
*(tmp + 2 + j) = ' ';