]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fundamental: Fix buffer size in get_chid 35056/head
authoranonymix007 <48598263+anonymix007@users.noreply.github.com>
Wed, 6 Nov 2024 20:12:07 +0000 (23:12 +0300)
committeranonymix007 <48598263+anonymix007@users.noreply.github.com>
Thu, 7 Nov 2024 21:53:26 +0000 (00:53 +0300)
NUL byte should not be hashed

src/fundamental/chid-fundamental.c

index 3aa444ab8872ab2d2d8d8781d605c3136f61b2a6..01045176f5227913d6cca10c2af48bd0a95b0e62 100644 (file)
@@ -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];