]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
efi: do not memzero fields before initializing them
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 17 Oct 2023 08:55:57 +0000 (10:55 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 19 Oct 2023 10:24:53 +0000 (12:24 +0200)
In all three cases we immediately overwrite the whole field anyway,
so the call to memzero is not needed.

src/boot/efi/measure.c

index 28ec6b7d8258dbd9653f22e1624f82527b7dab56..01c97c883c0b74f4e57dc223204cbc5ff4e99261 100644 (file)
@@ -25,7 +25,7 @@ static EFI_STATUS tpm1_measure_to_pcr_and_event_log(
         assert(description);
 
         desc_len = strsize16(description);
-        tcg_event = xmalloc0(offsetof(TCG_PCR_EVENT, Event) + desc_len);
+        tcg_event = xmalloc(offsetof(TCG_PCR_EVENT, Event) + desc_len);
         *tcg_event = (TCG_PCR_EVENT) {
                 .EventSize = desc_len,
                 .PCRIndex = pcrindex,
@@ -62,8 +62,7 @@ static EFI_STATUS tpm2_measure_to_pcr_and_tagged_event_log(
         desc_len = strsize16(description);
         event_size = offsetof(EFI_TCG2_EVENT, Event) + offsetof(EFI_TCG2_TAGGED_EVENT, Event) + desc_len;
 
-        event = xmalloc0(event_size);
-
+        event = xmalloc(event_size);
         *event = (struct event) {
                 .tcg_event = (EFI_TCG2_EVENT) {
                         .Size = event_size,
@@ -106,7 +105,7 @@ static EFI_STATUS tpm2_measure_to_pcr_and_event_log(
          * here. */
 
         desc_len = strsize16(description);
-        tcg_event = xmalloc0(offsetof(EFI_TCG2_EVENT, Event) + desc_len);
+        tcg_event = xmalloc(offsetof(EFI_TCG2_EVENT, Event) + desc_len);
         *tcg_event = (EFI_TCG2_EVENT) {
                 .Size = offsetof(EFI_TCG2_EVENT, Event) + desc_len,
                 .Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER),