From cc7cb89c11c1bec2f5445aeee38695db06be513f Mon Sep 17 00:00:00 2001 From: Aidan Garske Date: Thu, 6 Aug 2026 12:59:09 -0700 Subject: [PATCH] F-7590 - Reserve the NUL terminator when clamping -secrethex= input --- examples/boot/secret_seal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/boot/secret_seal.c b/examples/boot/secret_seal.c index 94266847..93d3e3d4 100644 --- a/examples/boot/secret_seal.c +++ b/examples/boot/secret_seal.c @@ -152,8 +152,8 @@ int TPM2_Boot_SecretSeal_Example(void* userCtx, int argc, char *argv[]) const char* secretStr = argv[argc-1] + XSTRLEN("-secrethex="); word32 secretStrSz = (word32)XSTRLEN(secretStr); int secretHexSz; - if (secretStrSz > (word32)(sizeof(secret)*2-1)) - secretStrSz = (word32)(sizeof(secret)*2-1); + if (secretStrSz > (word32)((sizeof(secret)-1)*2)) + secretStrSz = (word32)((sizeof(secret)-1)*2); secretHexSz = hexToByte(secretStr, secret, secretStrSz); if (secretHexSz < 0) { printf("Invalid secret hex string\n");