OSDN Git Service

libparted: gpt: avoid heap-read-overrun when rewriting 9-PTE table
authorJim Meyering <meyering@redhat.com>
Mon, 6 Feb 2012 14:00:53 +0000 (15:00 +0100)
committerJim Meyering <meyering@redhat.com>
Tue, 7 Feb 2012 10:49:36 +0000 (11:49 +0100)
commit905811b14ae10a0d292b9da58469ff788e1cdd73
tree09b8ba3763ded7fc236bec1626f5bb8743861b76
parent7be12a2568c57355a800752abfefdf7e55c9cbfe
libparted: gpt: avoid heap-read-overrun when rewriting 9-PTE table

Now that parted can rewrite a corrupt-or-misaligned 9-PTE table,
we have to be careful to allocate space for slightly more data
when the byte-count required for a PTE table is smaller than
the whole number of sectors would imply.  I.e., when the PTE table
size is not a multiple of the sector size, there is a fraction of
that final sector for which we do not read data, but we do write.
Ensure we have space for the buffer we'll write and that it is
initialized (to 0's).
* libparted/labels/gpt.c (gpt_write): Allocate the right amount of
space.  Use calloc, not malloc+memset.
libparted/labels/gpt.c