diff mbox series

[ima-evm-utils,v2,10/12] Limit the file hash algorithm name length

Message ID 20220906195021.854090-11-zohar@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series address deprecated warnings | expand

Commit Message

Mimi Zohar Sept. 6, 2022, 7:50 p.m. UTC
Instead of assuming the file hash algorithm is a properly NULL terminated
string, properly limit the "algo:<hash>" field size.

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
 src/evmctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Berger Sept. 13, 2022, 4:35 p.m. UTC | #1
On 9/6/22 15:50, Mimi Zohar wrote:
> Instead of assuming the file hash algorithm is a properly NULL terminated
> string, properly limit the "algo:<hash>" field size.
> 
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>


Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>

> ---
>   src/evmctl.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/evmctl.c b/src/evmctl.c
> index a497b1a468d6..aac669438a1c 100644
> --- a/src/evmctl.c
> +++ b/src/evmctl.c
> @@ -1602,7 +1602,7 @@ void ima_ng_show(struct template_entry *entry)
>   	total_len -= sizeof(field_len);
>   
>   	algo = (char *)fieldp;
> -	len = strlen(algo) + 1;
> +	len = strnlen(algo, field_len - 1) + 1;
>   	digest_len = field_len - len;
>   	digest = fieldp + len;
>
diff mbox series

Patch

diff --git a/src/evmctl.c b/src/evmctl.c
index a497b1a468d6..aac669438a1c 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -1602,7 +1602,7 @@  void ima_ng_show(struct template_entry *entry)
 	total_len -= sizeof(field_len);
 
 	algo = (char *)fieldp;
-	len = strlen(algo) + 1;
+	len = strnlen(algo, field_len - 1) + 1;
 	digest_len = field_len - len;
 	digest = fieldp + len;