linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ima-evm-utils 1/3] Fix out-of-bounds read
@ 2021-07-16 14:05 Mimi Zohar
  2021-07-16 14:05 ` [PATCH ima-evm-utils 2/3] Address "ignoring number of bytes read" messages Mimi Zohar
  2021-07-16 14:05 ` [PATCH ima-evm-utils 3/3] Remove unnecessary NULL pointer test Mimi Zohar
  0 siblings, 2 replies; 3+ messages in thread
From: Mimi Zohar @ 2021-07-16 14:05 UTC (permalink / raw)
  To: linux-integrity; +Cc: Mimi Zohar

Coverity reported "overrunning an array".  Properly clear only the
remaining unused buffer memory.

Fixes: 874c0fd45cab ("EVM hmac calculation")
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
 src/evmctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/evmctl.c b/src/evmctl.c
index 04f14af9ab29..e1464ade4837 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -1108,7 +1108,8 @@ static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *h
 
 	/* EVM key is 128 bytes */
 	memcpy(evmkey, key, keylen);
-	memset(evmkey + keylen, 0, sizeof(evmkey) - keylen);
+	if (keylen < sizeof(evmkey))
+		memset(evmkey + keylen, 0, sizeof(evmkey) - keylen);
 
 	if (lstat(file, &st)) {
 		log_err("Failed to stat: %s\n", file);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-16 14:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 14:05 [PATCH ima-evm-utils 1/3] Fix out-of-bounds read Mimi Zohar
2021-07-16 14:05 ` [PATCH ima-evm-utils 2/3] Address "ignoring number of bytes read" messages Mimi Zohar
2021-07-16 14:05 ` [PATCH ima-evm-utils 3/3] Remove unnecessary NULL pointer test Mimi Zohar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).