All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH ima-evm-utils 1/3] ima-evm-utils: Fix mismatched type checking
@ 2020-07-07  3:35 Tianjia Zhang
  2020-07-07  3:35 ` [PATCH ima-evm-utils 2/3] ima-evm-utils: beautify the code to make it more readable Tianjia Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Tianjia Zhang @ 2020-07-07  3:35 UTC (permalink / raw)
  To: zohar, vt, linux-kernel; +Cc: tianjia.zhang

Even if imaevm_get_hash_algo() returns an error value of -1, it is
forced to be converted to uint8_t type here, resulting in this error
not being checked by the if condition. This patch fixes this error.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 src/libimaevm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libimaevm.c b/src/libimaevm.c
index e6947d7..a9419ee 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -922,7 +922,7 @@ static int sign_hash_v2(const char *algo, const unsigned char *hash,
 	hdr->version = (uint8_t) DIGSIG_VERSION_2;
 
 	hdr->hash_algo = imaevm_get_hash_algo(algo);
-	if (hdr->hash_algo == -1) {
+	if (hdr->hash_algo == (uint8_t)-1) {
 		log_err("sign_hash_v2: hash algo is unknown: %s\n", algo);
 		return -1;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH ima-evm-utils 1/3] ima-evm-utils: Fix mismatched type checking
@ 2020-07-08  6:07 Tianjia Zhang
  0 siblings, 0 replies; 7+ messages in thread
From: Tianjia Zhang @ 2020-07-08  6:07 UTC (permalink / raw)
  To: zohar, vt, linux-integrity; +Cc: tianjia.zhang

Even if imaevm_get_hash_algo() returns an error value of -1, it is
forced to be converted to uint8_t type here, resulting in this error
not being checked by the if condition. This patch fixes this error.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 src/libimaevm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libimaevm.c b/src/libimaevm.c
index e6947d7..a9419ee 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -922,7 +922,7 @@ static int sign_hash_v2(const char *algo, const unsigned char *hash,
 	hdr->version = (uint8_t) DIGSIG_VERSION_2;
 
 	hdr->hash_algo = imaevm_get_hash_algo(algo);
-	if (hdr->hash_algo == -1) {
+	if (hdr->hash_algo == (uint8_t)-1) {
 		log_err("sign_hash_v2: hash algo is unknown: %s\n", algo);
 		return -1;
 	}
-- 
2.17.1


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

end of thread, other threads:[~2020-07-08 16:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-07  3:35 [PATCH ima-evm-utils 1/3] ima-evm-utils: Fix mismatched type checking Tianjia Zhang
2020-07-07  3:35 ` [PATCH ima-evm-utils 2/3] ima-evm-utils: beautify the code to make it more readable Tianjia Zhang
2020-07-08 16:28   ` Mimi Zohar
2020-07-07  3:35 ` [PATCH ima-evm-utils 3/3] ima-evm-utils: ima_sign supports sm3 algorithm Tianjia Zhang
2020-07-08 16:37   ` Mimi Zohar
2020-07-08 14:01 ` [PATCH ima-evm-utils 1/3] ima-evm-utils: Fix mismatched type checking Mimi Zohar
  -- strict thread matches above, loose matches on Subject: below --
2020-07-08  6:07 Tianjia Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.