]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
fix integer overflow issue for i386-pc
authorlongpanda <59477474+ventoy@users.noreply.github.com>
Sat, 6 Feb 2021 06:37:04 +0000 (14:37 +0800)
committerGitHub <noreply@github.com>
Sat, 6 Feb 2021 06:37:04 +0000 (14:37 +0800)
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c

index e9272cb52f63cd130164275087a9f38b744b97bf..4c704ee0c17de86e233dbf2ad8fbf653f22b4503 100644 (file)
@@ -541,8 +541,8 @@ static grub_err_t ventoy_cmd_incr(grub_extcmd_context_t ctxt, int argc, char **a
 
 static grub_err_t ventoy_cmd_mod(grub_extcmd_context_t ctxt, int argc, char **args)
 {
 
 static grub_err_t ventoy_cmd_mod(grub_extcmd_context_t ctxt, int argc, char **args)
 {
-    long value1 = 0;
-    long value2 = 0;
+    ulonglong value1 = 0;
+    ulonglong value2 = 0;
     char buf[32];
     
     if (argc != 3)
     char buf[32];
     
     if (argc != 3)
@@ -550,10 +550,10 @@ static grub_err_t ventoy_cmd_mod(grub_extcmd_context_t ctxt, int argc, char **ar
         return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {Int} {Int} {Variable}", cmd_raw_name);
     }
 
         return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {Int} {Int} {Variable}", cmd_raw_name);
     }
 
-    value1 = grub_strtol(args[0], NULL, 10);
-    value2 = grub_strtol(args[1], NULL, 10);
+    value1 = grub_strtoull(args[0], NULL, 10);
+    value2 = grub_strtoull(args[1], NULL, 10);
 
 
-    grub_snprintf(buf, sizeof(buf), "%ld", (value1 % value2));
+    grub_snprintf(buf, sizeof(buf), "%llu", (value1 % value2));
     grub_env_set(args[2], buf);
 
     VENTOY_CMD_RETURN(GRUB_ERR_NONE);
     grub_env_set(args[2], buf);
 
     VENTOY_CMD_RETURN(GRUB_ERR_NONE);