From 568101f774f9ad61d475969e91dc90da359b5a85 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Sat, 13 Oct 2001 01:22:25 -0600 Subject: [PATCH] mke2fs.c(main): Always exit with non-zero code in case of error. mke2fs.c(zap_sector): Check that buffer allocation succeeded. --- misc/ChangeLog | 6 ++++++ misc/mke2fs.c | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/misc/ChangeLog b/misc/ChangeLog index a59c83c..b82a707 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,9 @@ +2001-10-07 Andreas Dilger + + * mke2fs.c (main): Always exit with non-zero code in case of error. + + * mke2fs.c (zap_sector): Check that buffer allocation succeeded. + 2001-09-20 Theodore Tso * Release of E2fsprogs 1.25 diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 1d9f7ff..f7e4832 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -554,6 +554,11 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect) int retval; buf = malloc(512*nsect); + if (!buf) { + printf(_("Warning: out of memory erasing sectors %d-%d: %s\n"), + sect, sect + nsect - 1, error_message(retval)); + exit(1); + } memset(buf, 0, 512*nsect); io_channel_set_blksize(fs->io, 512); @@ -1199,8 +1204,7 @@ int main (int argc, char *argv[]) if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) { create_journal_dev(fs); - ext2fs_close(fs); - exit(0); + exit(ext2fs_close(fs) ? 1 : 0); } if (bad_blocks_filename) @@ -1323,6 +1327,6 @@ no_journal: printf(_("done\n\n")); print_check_message(fs); } - ext2fs_close(fs); - return 0; + val = ext2fs_close(fs); + return (retval || val) ? 1 : 0; } -- 1.8.3.1