]> sourceware.org Git - lvm2.git/commitdiff
lvconvert: validate name before prompt
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 24 Feb 2017 11:56:40 +0000 (12:56 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 10 Mar 2017 18:33:00 +0000 (19:33 +0100)
Before prompting make sure name fits.

tools/lvconvert.c

index 4e8dbc8689d21bd31c25606f66b540e3331812f3..3d7259e4ec13fcc0f7f934b9b1f372a5155f5e41 100644 (file)
@@ -2718,6 +2718,16 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
                memcpy(&lockd_data_id, &lv->lvid.id[1], sizeof(struct id));
        }
 
+       /*
+        * The internal LV names for pool data/meta LVs.
+        */
+
+       if ((dm_snprintf(meta_name, sizeof(meta_name), "%s%s", lv->name, to_cachepool ? "_cmeta" : "_tmeta") < 0) ||
+           (dm_snprintf(data_name, sizeof(data_name), "%s%s", lv->name, to_cachepool ? "_cdata" : "_tdata") < 0)) {
+               log_error("Failed to create internal lv names, pool name is too long.");
+               return 0;
+       }
+
        /*
         * If an existing LV is to be used as the metadata LV,
         * verify that it's in a usable state.  These checks are
@@ -2842,7 +2852,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
 
        log_verbose("Pool metadata extents %u chunk_size %u", meta_extents, chunk_size);
 
-
        /*
         * Verify that user wants to use these LVs.
         */
@@ -2869,16 +2878,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
                return 0;
        }
 
-       /*
-        * The internal LV names for pool data/meta LVs.
-        */
-
-       if ((dm_snprintf(meta_name, sizeof(meta_name), "%s%s", lv->name, to_cachepool ? "_cmeta" : "_tmeta") < 0) ||
-           (dm_snprintf(data_name, sizeof(data_name), "%s%s", lv->name, to_cachepool ? "_cdata" : "_tdata") < 0)) {
-               log_error("Failed to create internal lv names, pool name is too long.");
-               return 0;
-       }
-
        /*
         * If a new metadata LV needs to be created, collect the settings for
         * the new LV and create it.
This page took 0.035584 seconds and 5 git commands to generate.