Skip to content

Commit 8215433

Browse files
committed
Cryptlib/OpenSSL/crypto/cmac/cmac.c: fix overflow
Check that bl - 1 is not negative to fix the following k1 stringop-overflow: In function 'make_kn', inlined from 'make_kn' at crypto/cmac/cmac.c:81:13, inlined from 'CMAC_Init' at crypto/cmac/cmac.c:205:9: crypto/cmac/cmac.c:92:20: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] 92 | k1[bl - 1] ^= bl == 16 ? 0x87 : 0x1b; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ crypto/cmac/cmac.c: In function 'CMAC_Init': crypto/cmac/cmac.c:69:19: note: at offset [-2147483649, -1] into destination object 'k1' of size 32 69 | unsigned char k1[EVP_MAX_BLOCK_LENGTH]; | ^~ Fixes: - http://autobuild.buildroot.org/results/97b6333cdc7bad24aba7af1b04890679e0058299 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
1 parent 126a07e commit 8215433

File tree

1 file changed

+1
-1
lines changed
  • Cryptlib/OpenSSL/crypto/cmac

1 file changed

+1
-1
lines changed

Cryptlib/OpenSSL/crypto/cmac/cmac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void make_kn(unsigned char *k1, unsigned char *l, int bl)
8888
k1[i] |= 1;
8989
}
9090
/* If MSB set fixup with R */
91-
if (l[0] & 0x80)
91+
if (((bl - 1) >= 0) && (l[0] & 0x80))
9292
k1[bl - 1] ^= bl == 16 ? 0x87 : 0x1b;
9393
}
9494

0 commit comments

Comments
 (0)