From c1b558f59e38c05dc7b625107c38a48082be0728 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 24 Apr 2025 23:24:29 +0100 Subject: [PATCH] [cmdline] Remove userptr_t from "digest" command Simplify the implementation of the "digest" command by assuming that the entire image data can be passed directly to digest_update(). Signed-off-by: Michael Brown --- src/hci/commands/digest_cmd.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/hci/commands/digest_cmd.c b/src/hci/commands/digest_cmd.c index 71308064f..55039bb79 100644 --- a/src/hci/commands/digest_cmd.c +++ b/src/hci/commands/digest_cmd.c @@ -62,10 +62,6 @@ static int digest_exec ( int argc, char **argv, struct image *image; uint8_t digest_ctx[digest->ctxsize]; uint8_t digest_out[digest->digestsize]; - uint8_t buf[128]; - size_t offset; - size_t len; - size_t frag_len; int i; unsigned j; int rc; @@ -79,20 +75,10 @@ static int digest_exec ( int argc, char **argv, /* Acquire image */ if ( ( rc = imgacquire ( argv[i], 0, &image ) ) != 0 ) continue; - offset = 0; - len = image->len; - /* calculate digest */ + /* Calculate digest */ digest_init ( digest, digest_ctx ); - while ( len ) { - frag_len = len; - if ( frag_len > sizeof ( buf ) ) - frag_len = sizeof ( buf ); - copy_from_user ( buf, image->data, offset, frag_len ); - digest_update ( digest, digest_ctx, buf, frag_len ); - len -= frag_len; - offset += frag_len; - } + digest_update ( digest, digest_ctx, image->data, image->len ); digest_final ( digest, digest_ctx, digest_out ); for ( j = 0 ; j < sizeof ( digest_out ) ; j++ ) -- 2.47.2