cal: Fix check for lseek errors
This commit is contained in:
1 parent
b8fb95b2aa
commit
bc0f663e92
1 file changed
+5
-2
@@ -73,6 +73,8 @@ int cal_init_file(const char * file, struct cal ** cal_out) {
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
mtd_info_t mtd_info;
|
mtd_info_t mtd_info;
|
||||||
|
#else
|
||||||
|
off_t lsize = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( stat(file, &st) != 0 )
|
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 )
|
if ( ioctl(fd, BLKGETSIZE64, &blksize) != 0 )
|
||||||
goto err;
|
goto err;
|
||||||
#else
|
#else
|
||||||
blksize = lseek(fd, 0, SEEK_END);
|
lsize = lseek(fd, 0, SEEK_END);
|
||||||
if ( blksize == (off_t)-1 )
|
if ( lsize == (off_t)-1 )
|
||||||
goto err;
|
goto err;
|
||||||
if ( lseek(fd, 0, SEEK_SET) == (off_t)-1 )
|
if ( lseek(fd, 0, SEEK_SET) == (off_t)-1 )
|
||||||
goto err;
|
goto err;
|
||||||
|
blksize = lsize;
|
||||||
#endif
|
#endif
|
||||||
if ( blksize > SSIZE_MAX )
|
if ( blksize > SSIZE_MAX )
|
||||||
goto err;
|
goto err;
|
||||||
|
|||||||
Reference in new issue
Block a user