From a835ee6789abbf2c1c760e0f14fc7d3b1d427998 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Sat, 11 Feb 2023 18:55:55 +0100 Subject: [PATCH] fix (kernel): fixed bug with smaller num_bits values in binary to alpha conversion --- kernel/src/utils/string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/src/utils/string.c b/kernel/src/utils/string.c index 384453f..9a28855 100644 --- a/kernel/src/utils/string.c +++ b/kernel/src/utils/string.c @@ -112,7 +112,8 @@ void string_hex_64bit_to_alpha(string_t string, uint64_t value) { void string_bin_to_alpha(string_t string, uint8_t num_bits, uint64_t value) { char* buffer = (char*)string; - num_bits = MIN(num_bits, 64); + num_bits = MIN(num_bits, 64); + value <<= 64 - num_bits; for (uint8_t i = 0; i < num_bits; i++) { buffer[i] = ((value & (0x8000000000000000 >> i)) > 0) ? '1' : '0'; }