From b9b260119ff5d21238e6f9af7312da56aa8b2a88 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 9 Mar 2007 21:25:33 +0000 Subject: [PATCH] Add a few missing pieces of vgname command line validation. --- WHATS_NEW | 1 + tools/vgextend.c | 6 ++++++ tools/vgreduce.c | 6 ++++++ tools/vgsplit.c | 10 ++++++++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 0a8df6daa..5fdfac6ea 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.24 - ==================================== + Add a few missing pieces of vgname command line validation. Support the /dev/mapper prefix on most command lines. Version 2.02.23 - 8th March 2007 diff --git a/tools/vgextend.c b/tools/vgextend.c index e1a768fd8..8c967a4cf 100644 --- a/tools/vgextend.c +++ b/tools/vgextend.c @@ -41,6 +41,12 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) return ECMD_FAILED; } + if (!validate_name(vg_name)) { + log_error("Volume group name \"%s\" is invalid", + vg_name); + return ECMD_FAILED; + } + log_verbose("Checking for volume group \"%s\"", vg_name); if (!lock_vol(cmd, vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) { unlock_vg(cmd, ORPHAN); diff --git a/tools/vgreduce.c b/tools/vgreduce.c index fc6e390c1..c7ce77466 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -465,6 +465,12 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv) argv++; argc--; + if (!validate_name(vg_name)) { + log_error("Volume group name \"%s\" is invalid", + vg_name); + return ECMD_FAILED; + } + log_verbose("Finding volume group \"%s\"", vg_name); if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) { log_error("Can't get lock for %s", vg_name); diff --git a/tools/vgsplit.c b/tools/vgsplit.c index 1695605b0..09d58c2e3 100644 --- a/tools/vgsplit.c +++ b/tools/vgsplit.c @@ -219,11 +219,17 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv) return EINVALID_CMD_LINE; } - vg_name_from = argv[0]; - vg_name_to = argv[1]; + vg_name_from = skip_dev_dir(cmd, argv[0], NULL); + vg_name_to = skip_dev_dir(cmd, argv[1], NULL); argc -= 2; argv += 2; + if (!validate_name(vg_name_from)) { + log_error("Volume group name \"%s\" is invalid", + vg_name_from); + return ECMD_FAILED; + } + if (!strcmp(vg_name_to, vg_name_from)) { log_error("Duplicate volume group name \"%s\"", vg_name_from); return ECMD_FAILED;