From b54bed9f082b4cca9078c6a329f1157faeffc7b7 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 12 Mar 2007 14:58:40 +0100 Subject: [PATCH] hfs.c: Detect write failure. * libparted/fs/hfs/hfs.c (hfs_extract_file, hfs_extract_bitmap): (hfs_extract_mdb, hfsplus_extract_file, hfsplus_extract_vh): Fail when fclose fails for a written-to file handle. --- libparted/fs/hfs/hfs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libparted/fs/hfs/hfs.c b/libparted/fs/hfs/hfs.c index 4824a2e..3323cc0 100644 --- a/libparted/fs/hfs/hfs.c +++ b/libparted/fs/hfs/hfs.c @@ -1037,8 +1037,8 @@ hfs_extract_file(const char* filename, HfsPrivateFile* hfs_file) goto err_close; } - fclose(fout); - return 1; + return (fclose(fout) == 0 ? 1 : 0); + err_close: fclose(fout); return 0; @@ -1070,8 +1070,8 @@ hfs_extract_bitmap(const char* filename, PedFileSystem* fs) goto err_close; } - fclose(fout); - return 1; + return (fclose(fout) == 0 ? 1 : 0); + err_close: fclose(fout); return 0; @@ -1090,8 +1090,8 @@ hfs_extract_mdb (const char* filename, PedFileSystem* fs) if (!fwrite(extract_buffer, PED_SECTOR_SIZE_DEFAULT, 1, fout)) goto err_close; - fclose(fout); - return 1; + return (fclose(fout) == 0 ? 1 : 0); + err_close: fclose(fout); return 0; @@ -1142,8 +1142,8 @@ hfsplus_extract_file(const char* filename, HfsPPrivateFile* hfsp_file) goto err_close; } - fclose(fout); - return 1; + return (fclose(fout) == 0 ? 1 : 0); + err_close: fclose(fout); return 0; @@ -1166,8 +1166,8 @@ hfsplus_extract_vh (const char* filename, PedFileSystem* fs) if (!fwrite(extract_buffer, PED_SECTOR_SIZE_DEFAULT, 1, fout)) goto err_close; - fclose(fout); - return 1; + return (fclose(fout) == 0 ? 1 : 0); + err_close: fclose(fout); return 0; -- 2.11.0