1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

Add a few missing pieces of vgname command line validation.

This commit is contained in:
Alasdair Kergon 2007-03-09 21:25:33 +00:00
parent 9397354a33
commit b9b260119f
4 changed files with 21 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.24 - Version 2.02.24 -
==================================== ====================================
Add a few missing pieces of vgname command line validation.
Support the /dev/mapper prefix on most command lines. Support the /dev/mapper prefix on most command lines.
Version 2.02.23 - 8th March 2007 Version 2.02.23 - 8th March 2007

View File

@ -41,6 +41,12 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED; 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); log_verbose("Checking for volume group \"%s\"", vg_name);
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) { if (!lock_vol(cmd, vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) {
unlock_vg(cmd, ORPHAN); unlock_vg(cmd, ORPHAN);

View File

@ -465,6 +465,12 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
argv++; argv++;
argc--; 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); log_verbose("Finding volume group \"%s\"", vg_name);
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) { if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
log_error("Can't get lock for %s", vg_name); log_error("Can't get lock for %s", vg_name);

View File

@ -219,11 +219,17 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
vg_name_from = argv[0]; vg_name_from = skip_dev_dir(cmd, argv[0], NULL);
vg_name_to = argv[1]; vg_name_to = skip_dev_dir(cmd, argv[1], NULL);
argc -= 2; argc -= 2;
argv += 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)) { if (!strcmp(vg_name_to, vg_name_from)) {
log_error("Duplicate volume group name \"%s\"", vg_name_from); log_error("Duplicate volume group name \"%s\"", vg_name_from);
return ECMD_FAILED; return ECMD_FAILED;