]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
fix integer overflow issue for i386-pc
[Ventoy.git] / GRUB2 / MOD_SRC / grub-2.04 / grub-core / ventoy / ventoy.c
index 4c704ee0c17de86e233dbf2ad8fbf653f22b4503..79e109d4ac4dea99bf71fee9a49923a6ceaea7e0 100644 (file)
@@ -553,7 +553,7 @@ static grub_err_t ventoy_cmd_mod(grub_extcmd_context_t ctxt, int argc, char **ar
     value1 = grub_strtoull(args[0], NULL, 10);
     value2 = grub_strtoull(args[1], NULL, 10);
 
-    grub_snprintf(buf, sizeof(buf), "%llu", (value1 % value2));
+    grub_snprintf(buf, sizeof(buf), "%llu", (value1 & (value2 - 1)));
     grub_env_set(args[2], buf);
 
     VENTOY_CMD_RETURN(GRUB_ERR_NONE);