]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[cmdline] Remove userptr_t from "digest" command
authorMichael Brown <mcb30@ipxe.org>
Thu, 24 Apr 2025 22:24:29 +0000 (23:24 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 24 Apr 2025 22:24:29 +0000 (23:24 +0100)
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 <mcb30@ipxe.org>
src/hci/commands/digest_cmd.c

index 71308064fb9c7eb91497d8d7cf6627069e39b7ef..55039bb7969b26e35543056fe014886e8776403b 100644 (file)
@@ -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++ )