[SLOF] [PATCH 1/2] lib/libtpm: Silence compiler warnings about bad zero-length array access

Thomas Huth thuth at redhat.com
Mon Sep 18 22:26:58 AEST 2023


GCC v13.2.1 complains:

tcgbios.c: In function ‘tpm20_write_EfiSpecIdEventStruct’:
tcgbios.c:708:38: warning: array subscript ‘numAlgs’ is outside the
 bounds of an interior zero-length array ‘struct
 TCG_EfiSpecIdEventAlgorithmSize[0]’ [-Wzero-length-bounds]
  708 |                 event.hdr.digestSizes[numAlgs].algorithmId =
      |                 ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~

Let's use the undefined array length declaration instead to
make GCC here happy again.

Signed-off-by: Thomas Huth <thuth at redhat.com>
---
 lib/libtpm/tcgbios_int.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libtpm/tcgbios_int.h b/lib/libtpm/tcgbios_int.h
index 22df31d..cc38455 100644
--- a/lib/libtpm/tcgbios_int.h
+++ b/lib/libtpm/tcgbios_int.h
@@ -89,7 +89,7 @@ struct TCG_EfiSpecIdEventStruct {
 	struct TCG_EfiSpecIdEventAlgorithmSize {
 		uint16_t algorithmId;
 		uint16_t digestSize;
-	} digestSizes[0];
+	} digestSizes[];
 	/*
 	uint8_t vendorInfoSize;
 	uint8_t vendorInfo[0];
-- 
2.41.0



More information about the SLOF mailing list