summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranonymix007 <48598263+anonymix007@users.noreply.github.com>2024-11-06 21:12:07 +0100
committeranonymix007 <48598263+anonymix007@users.noreply.github.com>2024-11-07 22:53:26 +0100
commit310997d5b4415f88e7a640eb5d1099012b531911 (patch)
tree3cd1b1077b8159e6acb2417657e715cda7e5b5f4
parentfundamental: Fix iteration count in chid_calculate (diff)
downloadsystemd-310997d5b4415f88e7a640eb5d1099012b531911.tar.xz
systemd-310997d5b4415f88e7a640eb5d1099012b531911.zip
fundamental: Fix buffer size in get_chid
NUL byte should not be hashed
-rw-r--r--src/fundamental/chid-fundamental.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/fundamental/chid-fundamental.c b/src/fundamental/chid-fundamental.c
index 3aa444ab88..01045176f5 100644
--- a/src/fundamental/chid-fundamental.c
+++ b/src/fundamental/chid-fundamental.c
@@ -20,7 +20,7 @@
# include <byteswap.h>
# include <string.h>
# include <utf8.h>
-#define strsize16(str) ((char16_strlen(str) + 1) * sizeof(char16_t))
+#define strlen16 char16_strlen
#endif
#include "chid-fundamental.h"
@@ -42,7 +42,7 @@ static void get_chid(const char16_t *const smbios_fields[static _CHID_SMBIOS_FIE
if ((mask >> i) & 1) {
if (i > 0)
sha1_process_bytes(L"&", 2, &ctx);
- sha1_process_bytes(smbios_fields[i], strsize16(smbios_fields[i]), &ctx);
+ sha1_process_bytes(smbios_fields[i], strlen16(smbios_fields[i]) * sizeof(char16_t), &ctx);
}
uint8_t hash[SHA1_DIGEST_SIZE];