From 817e49e3ce0a70252113438440fc12607140d032 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 21 Nov 2003 09:10:29 -0500 Subject: [PATCH] Check the returned name from blkid_get_devname in tune2fs and e2fsck, and print an error if the requested LABEL/UUID does not exist (previously, we core dumped!) --- e2fsck/ChangeLog | 5 +++++ e2fsck/unix.c | 5 +++++ misc/ChangeLog | 6 ++++++ misc/tune2fs.c | 12 +++++++++++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 79a9bcd..d39d458 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,8 @@ +2003-09-12 Theodore Ts'o + + * unix.c (PRS): Check the returned name from blkid_get_devname and + print an error if the requested LABEL/UUID does not exist. + 2003-09-03 Theodore Ts'o * pass1.c (mark_table_blocks): Use the new function diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 33722e3..9109773 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -638,6 +638,11 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) !cflag && !swapfs && !(ctx->options & E2F_OPT_COMPRESS_DIRS)) ctx->options |= E2F_OPT_READONLY; ctx->filesystem_name = blkid_get_devname(ctx->blkid, argv[optind], 0); + if (!ctx->filesystem_name) { + com_err(ctx->program_name, 0, _("Unable to resolve '%s'"), + argv[optind]); + fatal_error(ctx, 0); + } if (extended_opts) parse_extended_opts(ctx, extended_opts); diff --git a/misc/ChangeLog b/misc/ChangeLog index 98ec820..03e6cc1 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,9 @@ +2003-09-13 Theodore Ts'o + + * tune2fs.c (parse_e2label_options, parse_tune2fs_options, + do_findfs): Check the returned name from blkid_get_devname and + print an error if the requested LABEL/UUID does not exist. + 2003-09-03 Theodore Ts'o * dumpe2fs.c (list_desc): Use ext2fs_super_and_bgd_loc to diff --git a/misc/tune2fs.c b/misc/tune2fs.c index a2d22b6..f95aed4 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -441,6 +441,11 @@ static void parse_e2label_options(int argc, char ** argv) exit(1); } device_name = blkid_get_devname(NULL, argv[1], NULL); + if (!device_name) { + com_err("e2label", 0, _("Unable to resolve '%s'"), + argv[1]); + exit(1); + } if (argc == 3) { open_flag = EXT2_FLAG_RW | EXT2_FLAG_JOURNAL_DEV_OK; L_flag = 1; @@ -691,6 +696,11 @@ static void parse_tune2fs_options(int argc, char **argv) if (!open_flag && !l_flag) usage(); device_name = blkid_get_devname(NULL, argv[optind], NULL); + if (!device_name) { + com_err("tune2fs", 0, _("Unable to resolve '%s'"), + argv[optind]); + exit(1); + } } void do_findfs(int argc, char **argv) @@ -704,7 +714,7 @@ void do_findfs(int argc, char **argv) } dev = blkid_get_devname(NULL, argv[1], NULL); if (!dev) { - fprintf(stderr, "Filesystem matching %s not found\n", + com_err("findfs", 0, _("Unable to resolve '%s'"), argv[1]); exit(1); } -- 1.8.3.1