From 5f6988d7946ceb0c111101304bfb012f754ee943 Mon Sep 17 00:00:00 2001 From: Aidan Garske Date: Mon, 11 May 2026 20:57:55 -0700 Subject: [PATCH] F-3918 - Use element-count form for pcrArray bounds check --- examples/boot/secret_unseal.c | 4 ++-- examples/pcr/policy_sign.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/boot/secret_unseal.c b/examples/boot/secret_unseal.c index 232c6607..83159ca3 100644 --- a/examples/boot/secret_unseal.c +++ b/examples/boot/secret_unseal.c @@ -167,9 +167,9 @@ int TPM2_Boot_SecretUnseal_Example(void* userCtx, int argc, char *argv[]) usage(); return 0; } - if (pcrArraySz >= sizeof(pcrArray)) { + if (pcrArraySz >= sizeof(pcrArray) / sizeof(pcrArray[0])) { printf("Too many -pcr= arguments (max %zu)\n", - sizeof(pcrArray)); + sizeof(pcrArray) / sizeof(pcrArray[0])); usage(); return 0; } diff --git a/examples/pcr/policy_sign.c b/examples/pcr/policy_sign.c index cf92a5fc..e75a33b3 100644 --- a/examples/pcr/policy_sign.c +++ b/examples/pcr/policy_sign.c @@ -274,9 +274,9 @@ int TPM2_PCR_PolicySign_Example(void* userCtx, int argc, char *argv[]) usage(); return 0; } - if (pcrArraySz >= sizeof(pcrArray)) { + if (pcrArraySz >= sizeof(pcrArray) / sizeof(pcrArray[0])) { printf("Too many -pcr= arguments (max %zu)\n", - sizeof(pcrArray)); + sizeof(pcrArray) / sizeof(pcrArray[0])); usage(); return 0; }