diff options
Diffstat (limited to 'libfdisk/src/gpt.c')
-rw-r--r-- | libfdisk/src/gpt.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index 58ebdc688..f300d3a1b 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -533,8 +533,9 @@ static ssize_t read_lba(struct fdisk_context *cxt, uint64_t lba, { off_t offset = lba * cxt->sector_size; - lseek(cxt->dev_fd, offset, SEEK_SET); - return read(cxt->dev_fd, buffer, bytes); + if (lseek(cxt->dev_fd, offset, SEEK_SET) == (off_t) -1) + return -1; + return read(cxt->dev_fd, buffer, bytes) != bytes; } @@ -720,7 +721,7 @@ static struct gpt_header *gpt_read_header(struct fdisk_context *cxt, return NULL; /* read and verify header */ - if (!read_lba(cxt, lba, header, sizeof(struct gpt_header))) + if (read_lba(cxt, lba, header, sizeof(struct gpt_header)) != 0) goto invalid; if (!gpt_check_signature(header)) |