summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2016-12-17 03:00:12 +0100
committerPali Rohár <pali.rohar@gmail.com>2016-12-17 03:00:12 +0100
commitbc0f663e927f5f8667fcbfa48bd948eb2640ee07 (patch)
tree3e30db8eb8f4e0ce243d98ebf869ca03bd15cdd0
parentb8fb95b2aab338830357db86c7c8f7f85a545eb5 (diff)
download0xFFFF-bc0f663e927f5f8667fcbfa48bd948eb2640ee07.tar.bz2
cal: Fix check for lseek errors
-rw-r--r--src/cal.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/cal.c b/src/cal.c
index c6af8e2..2edd0b5 100644
--- a/src/cal.c
+++ b/src/cal.c
@@ -73,6 +73,8 @@ int cal_init_file(const char * file, struct cal ** cal_out) {
struct stat st;
#ifdef __linux__
mtd_info_t mtd_info;
+#else
+ off_t lsize = 0;
#endif
if ( stat(file, &st) != 0 )
@@ -90,11 +92,12 @@ int cal_init_file(const char * file, struct cal ** cal_out) {
if ( ioctl(fd, BLKGETSIZE64, &blksize) != 0 )
goto err;
#else
- blksize = lseek(fd, 0, SEEK_END);
- if ( blksize == (off_t)-1 )
+ lsize = lseek(fd, 0, SEEK_END);
+ if ( lsize == (off_t)-1 )
goto err;
if ( lseek(fd, 0, SEEK_SET) == (off_t)-1 )
goto err;
+ blksize = lsize;
#endif
if ( blksize > SSIZE_MAX )
goto err;