diff --git a/ChangeLog b/ChangeLog index 6e9abacf6..7e0b0af5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-10-30 Vladimir Serbinenko + + * grub-core/kern/mm.c (grub_realloc): Don't copy more data than we have. + 2013-10-30 Vladimir Serbinenko * grub-core/io/gzio.c (huft_build): Use zalloc for safety. diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c index 59e45c7ae..5e53b07f4 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c @@ -483,7 +483,8 @@ grub_realloc (void *ptr, grub_size_t size) if (! q) return q; - grub_memcpy (q, ptr, size); + /* We've already checked that p->size < n. */ + grub_memcpy (q, ptr, p->size << GRUB_MM_ALIGN_LOG2); grub_free (ptr); return q; }