From b7f80de25d701ebbfbcb03ac73c2bb4de0979d90 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sun, 10 Jan 2016 14:29:18 +0100 Subject: all: Check for return value of lseek --- src/fiasco.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/fiasco.c') diff --git a/src/fiasco.c b/src/fiasco.c index 7917385..ba6d262 100644 --- a/src/fiasco.c +++ b/src/fiasco.c @@ -218,6 +218,8 @@ struct fiasco * fiasco_alloc_from_file(const char * file) { READ_OR_RETURN(fiasco, buf, 1); offset = lseek(fiasco->fd, 0, SEEK_CUR); + if ( offset == (off_t)-1 ) + FIASCO_READ_ERROR(fiasco, "Cannot get offset of file"); VERBOSE(" version: %s\n", version); VERBOSE(" device: %s\n", device); @@ -231,7 +233,8 @@ struct fiasco * fiasco_alloc_from_file(const char * file) { fiasco_add_image(fiasco, image); - lseek(fiasco->fd, offset+length, SEEK_SET); + if ( lseek(fiasco->fd, offset+length, SEEK_SET) == (off_t)-1 ) + FIASCO_READ_ERROR(fiasco, "Cannot seek to next image in file"); } -- cgit v1.2.3