summaryrefslogtreecommitdiffstats
path: root/fdisks/fdiskdoslabel.c
diff options
context:
space:
mode:
authorKarel Zak2012-11-30 11:54:10 +0100
committerKarel Zak2012-11-30 11:54:10 +0100
commit21770662c3ddc0655831312067e2d2b9e5281eec (patch)
tree9d179379dda5ae27ebde76d1a03f1ba1cae3b90e /fdisks/fdiskdoslabel.c
parentlibblkid: cleanup blkid_strconcat (diff)
downloadkernel-qcow2-util-linux-21770662c3ddc0655831312067e2d2b9e5281eec.tar.gz
kernel-qcow2-util-linux-21770662c3ddc0655831312067e2d2b9e5281eec.tar.xz
kernel-qcow2-util-linux-21770662c3ddc0655831312067e2d2b9e5281eec.zip
fdisk: don't fails silently if EBR is outside of disk
Reported-by: Phillip Susi <psusi@ubuntu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdiskdoslabel.c')
-rw-r--r--fdisks/fdiskdoslabel.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/fdisks/fdiskdoslabel.c b/fdisks/fdiskdoslabel.c
index 3e56e3885..0ace7f846 100644
--- a/fdisks/fdiskdoslabel.c
+++ b/fdisks/fdiskdoslabel.c
@@ -69,7 +69,10 @@ static void read_pte(struct fdisk_context *cxt, int pno, sector_t offset)
pe->offset = offset;
pe->sectorbuffer = xmalloc(cxt->sector_size);
- read_sector(cxt, offset, pe->sectorbuffer);
+
+ if (read_sector(cxt, offset, pe->sectorbuffer) != 0)
+ fprintf(stderr, _("Failed to read extended partition table (offset=%jd)\n"),
+ (uintmax_t) offset);
pe->changed = 0;
pe->part_table = pe->ext_pointer = NULL;
}
@@ -790,7 +793,14 @@ static void dos_add_partition(
static int write_sector(struct fdisk_context *cxt, sector_t secno,
unsigned char *buf)
{
- seek_sector(cxt, secno);
+ int rc;
+
+ rc = seek_sector(cxt, secno);
+ if (rc != 0) {
+ fprintf(stderr, _("write sector %jd failed: seek failed"),
+ (uintmax_t) secno);
+ return rc;
+ }
if (write(cxt->dev_fd, buf, cxt->sector_size) != (ssize_t) cxt->sector_size)
return -errno;
return 0;