From: Theodore Ts'o Date: Tue, 20 Jan 2009 18:37:47 +0000 (-0500) Subject: ext2fs_get_device_size: Fix error handling X-Git-Tag: v1.41.4~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9f7a1fc936497d5ab1ebe88baa704e91880849cc;p=thirdparty%2Fe2fsprogs.git ext2fs_get_device_size: Fix error handling The previous patch would return EFBIG for any failure called from ext2fs_get_device_size2(). (I didn't merge this fix with the preceeding commit to allow merges to happen more easily.) Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/getsize.c b/lib/ext2fs/getsize.c index 79fba5964..23c8f1224 100644 --- a/lib/ext2fs/getsize.c +++ b/lib/ext2fs/getsize.c @@ -278,13 +278,14 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize, { errcode_t retval; blk64_t blocks; - retval = ext2fs_get_device_size2(file, blocksize, &blocks); - if (!retval && blocks < (1ULL << 32)) { - *retblocks = (blk_t) blocks; + retval = ext2fs_get_device_size2(file, blocksize, &blocks); + if (retval) return retval; - } - return EFBIG; + if (blocks >= (1ULL << 32)) + return EFBIG; + *retblocks = (blk_t) blocks; + return 0; } #endif /* WIN32 */