Skip to contentSkip to conversation

master - lvrename: fix name length validation

PATCH Zdenek Kabelac 1 participant 1 message Mar 31, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d3e4934a153a3113038d8458fb62781b234287ea
Commit:        d3e4934a153a3113038d8458fb62781b234287ea
Parent:        caa429da2e58ad65ecfc8836f5f64c54395a8793
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Mon Mar 31 11:40:52 2014 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Mar 31 12:02:18 2014 +0200

lvrename: fix name length validation

This test for LV name restriction check name of device is below 128 chars (which is enforced by dm target).
Thus it should not count with device name.
(Though the test for PATH_MAX size should be probably also added, but this is runtime test, since theoretically devpath might differ in cluster)

---
 WHATS_NEW        |    1 +
 tools/lvrename.c |    6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
WHATS_NEW +1 -0
index b5ee541..1760a6b 100644
@@ -1,5 +1,6 @@
 Version 2.02.106 - 
 ====================================
+  Validate length of new LV name in lvrename to not exceed 127 characters.
   Add explict error message when using lvdisplay -c -m.
   Update man pages for pv/vg/lvdisplay.
   Report error when running pvscan with free argument (i.e. PV name).
tools/lvrename.c +3 -3
index dd66ba4..0fea039 100644
@@ -71,10 +71,10 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
 		lv_name_new = st + 1;
 
 	/* Check sanity of new name */
-	maxlen = NAME_LEN - strlen(vg_name) - strlen(cmd->dev_dir) - 3;
+	maxlen = NAME_LEN - strlen(vg_name) - 3;
 	if (strlen(lv_name_new) > maxlen) {
-		log_error("New logical volume path exceeds maximum length "
-			  "of %" PRIsize_t "!", maxlen);
+		log_error("New logical volume name \"%s\" may not exceed %"
+			  PRIsize_t " characters.", lv_name_new, maxlen);
 		return EINVALID_CMD_LINE;
 	}