diff options
author | Namhyung Kim <namhyung@gmail.com> | 2010-12-16 18:40:40 +0900 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2010-12-21 20:31:26 -0500 |
commit | 9ec68af7b61bf1ac88f20ae6ed6b1d45417195aa (patch) | |
tree | 6fc3772558775bc0060867329208c7b43546b5af /misc/mke2fs.c | |
parent | 22d8ce512ffcdb9d6a16e1d34f65aa37ce1ab3d3 (diff) | |
download | e2fsprogs-9ec68af7b61bf1ac88f20ae6ed6b1d45417195aa.tar.gz |
mke2fs: add some error checks into PRS()
Check return value of some functions and exit if unhandled error occurred.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc/mke2fs.c')
-rw-r--r-- | misc/mke2fs.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/misc/mke2fs.c b/misc/mke2fs.c index fd3a780a..a4378161 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1154,6 +1154,10 @@ static void PRS(int argc, char *argv[]) if (oldpath) pathlen += strlen(oldpath); newpath = malloc(pathlen); + if (!newpath) { + fprintf(stderr, _("Couldn't allocate memory for new PATH.\n")); + exit(1); + } strcpy(newpath, PATH_SET); /* Update our PATH to include /sbin */ @@ -1184,8 +1188,17 @@ static void PRS(int argc, char *argv[]) profile_set_syntax_err_cb(syntax_err_report); retval = profile_init(config_fn, &profile); if (retval == ENOENT) { - profile_init(default_files, &profile); - profile_set_default(profile, mke2fs_default_profile); + retval = profile_init(default_files, &profile); + if (retval) + goto profile_error; + retval = profile_set_default(profile, mke2fs_default_profile); + if (retval) + goto profile_error; + } else if (retval) { +profile_error: + fprintf(stderr, _("Couldn't init profile successfully" + " (error: %ld).\n"), retval); + exit(1); } setbuf(stdout, NULL); |