]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - GRUB2/MOD_SRC/grub-2.04/grub-core/commands/hashsum.c
Add .md5/.sha1/.sha256/.sha512 check file feature.
[Ventoy.git] / GRUB2 / MOD_SRC / grub-2.04 / grub-core / commands / hashsum.c
index 8be3d8ac556a418ab5890d54a071d68a2627b63a..7dc63f188f682709b5602f7a598b855f1a6c2f35 100644 (file)
@@ -224,6 +224,8 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
   int keep = state[3].set;
   int uncompress = state[4].set;
   unsigned unread = 0;
+  int len = 0;
+  char hashsum[256];
 
   for (i = 0; i < ARRAY_SIZE (aliases); i++)
     if (grub_strcmp (ctxt->extcmd->cmd->name, aliases[i].name) == 0)
@@ -282,8 +284,12 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
          continue;
        }
       for (j = 0; j < hash->mdlen; j++)
-       grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
+         {
+           grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
+        len += grub_snprintf(hashsum + len, sizeof(hashsum) - len, "%02x", ((grub_uint8_t *) result)[j]);
+      }
       grub_printf ("  %s\n", args[i]);
+      grub_env_set("VT_LAST_CHECK_SUM", hashsum);
     }
 
   if (unread)