From 515a9d000cd0bbf0d14661a422ab5c9a3a20d731 Mon Sep 17 00:00:00 2001 From: "tennessee.carmelveilleux@gmail.com" Date: Tue, 29 Aug 2023 10:46:47 -0400 Subject: [PATCH] Address more review comments --- src/crypto/CHIPCryptoPAL.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/crypto/CHIPCryptoPAL.cpp b/src/crypto/CHIPCryptoPAL.cpp index d6d6199e302177..f8a611875a5667 100644 --- a/src/crypto/CHIPCryptoPAL.cpp +++ b/src/crypto/CHIPCryptoPAL.cpp @@ -209,13 +209,14 @@ CHIP_ERROR Find16BitUpperCaseHexAfterPrefix(const ByteSpan & buffer, const char cursor += prefix_span.size(); remaining -= prefix_span.size(); - if (remaining < HEX_ENCODED_LENGTH(sizeof(uint16_t))) + constexpr size_t expected_hex_len = HEX_ENCODED_LENGTH(sizeof(uint16_t)); + if (remaining < expected_hex_len) { // We can't possibly match the hex values if not enough bytes left. break; } - char hex_buf[4]; + char hex_buf[expected_hex_len]; memcpy(&hex_buf[0], cursor, sizeof(hex_buf)); if (Encoding::UppercaseHexToUint16(&hex_buf[0], sizeof(hex_buf), out_hex_value) != 0)