From: Karel Zak Date: Wed, 27 Mar 2013 13:12:47 +0000 (+0100) Subject: libfdisk: check returns [coverity scan] X-Git-Tag: v2.23-rc2~109 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bbe8e6a98e0bdecc6f8143a692b625594c22f50d;p=thirdparty%2Futil-linux.git libfdisk: check returns [coverity scan] Signed-off-by: Karel Zak --- diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index 58ebdc6884..f300d3a1bc 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))