summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/sgi.c
diff options
context:
space:
mode:
authorKarel Zak2014-07-14 14:53:41 +0200
committerKarel Zak2014-07-14 15:05:22 +0200
commit7c2cfb18964b00881e65c461742af9038bd5b287 (patch)
tree03881cd0a38bab944fd9d84df86ce62f90dc1162 /libfdisk/src/sgi.c
parentbuild-sys: release++ (v2.25-rc2) (diff)
downloadkernel-qcow2-util-linux-7c2cfb18964b00881e65c461742af9038bd5b287.tar.gz
kernel-qcow2-util-linux-7c2cfb18964b00881e65c461742af9038bd5b287.tar.xz
kernel-qcow2-util-linux-7c2cfb18964b00881e65c461742af9038bd5b287.zip
libfdisk: make first sector buffer usage more robust
$ ~/util-linux/fdisk -b 4096 xxx .. Segmentation fault The buffer has to be reinitialized always when we apply a new device properties (e.g. sector size). Reported-by: Bernhard Voelker <mail@bernhard-voelker.de> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/sgi.c')
-rw-r--r--libfdisk/src/sgi.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c
index cd12d8049..cf1354132 100644
--- a/libfdisk/src/sgi.c
+++ b/libfdisk/src/sgi.c
@@ -908,6 +908,7 @@ static int sgi_create_disklabel(struct fdisk_context *cxt)
{
struct fdisk_sgi_label *sgi;
struct sgi_disklabel *sgilabel;
+ int rc;
assert(cxt);
assert(cxt->label);
@@ -936,7 +937,10 @@ static int sgi_create_disklabel(struct fdisk_context *cxt)
}
}
#endif
- fdisk_zeroize_firstsector(cxt);
+ rc = fdisk_init_firstsector_buffer(cxt);
+ if (rc)
+ return rc;
+
sgi = (struct fdisk_sgi_label *) cxt->label;
sgi->header = (struct sgi_disklabel *) cxt->firstsector;