From 0ccb6b3cf0c95d7895f6666700f99842af3d4496 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 22 Feb 2012 05:04:54 +0100 Subject: [PATCH] * grub-core/commands/testload.c (grub_cmd_testload): Fix overflow if the size isn't divisible by 512. --- ChangeLog | 5 +++++ grub-core/commands/testload.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3347d73e0..cabf12c31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-02-22 Vladimir Serbinenko + + * grub-core/commands/testload.c (grub_cmd_testload): Fix overflow + if the size isn't divisible by 512. + 2012-02-22 Vladimir Serbinenko Make list_push and list_remove functions rather than inline functions diff --git a/grub-core/commands/testload.c b/grub-core/commands/testload.c index ef68ad141..f67abadda 100644 --- a/grub-core/commands/testload.c +++ b/grub-core/commands/testload.c @@ -100,7 +100,10 @@ grub_cmd_testload (struct grub_command *cmd __attribute__ ((unused)), { char sector[GRUB_DISK_SECTOR_SIZE]; - pos -= GRUB_DISK_SECTOR_SIZE; + if (pos >= GRUB_DISK_SECTOR_SIZE) + pos -= GRUB_DISK_SECTOR_SIZE; + else + pos = 0; grub_file_seek (file, pos);