From 74ddf11d55df692584b9dd964283d572153997f9 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 5 Oct 2023 10:42:18 +0200 Subject: [PATCH] Fix compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` src/encauth/ccm/ccm_memory.c: In function ‘ccm_memory’: src/encauth/ccm/ccm_memory.c:164:17: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 164 | PAD[x++] = (unsigned char)((len >> 24) & 255); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/encauth/ccm/ccm_memory.c:43:19: note: at offset 16 into destination object ‘PAD’ of size 16 43 | unsigned char PAD[16], ctr[16], CTRPAD[16], ptTag[16], b, *pt_real; | ^~~ ``` Multiple reviews and tests determined that this can't happen, but most likely computers are better in finding out such stuff (or it was a false positive). Signed-off-by: Steffen Jaeckel --- src/encauth/ccm/ccm_memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/encauth/ccm/ccm_memory.c b/src/encauth/ccm/ccm_memory.c index fdb5172e..45951ff9 100644 --- a/src/encauth/ccm/ccm_memory.c +++ b/src/encauth/ccm/ccm_memory.c @@ -161,6 +161,9 @@ int ccm_memory(int cipher, PAD[x++] = 0; } for (; y < L; y++) { + if (x >= sizeof(PAD)) { + return CRYPT_INVALID_ARG; + } PAD[x++] = (unsigned char)((len >> 24) & 255); len <<= 8; }