From 0558b1a0869f9a68d78e80140500874756c70e4d Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 16 Jun 2014 12:39:32 +0200 Subject: [PATCH] cleanup: we already know max device name size Use NAME_LEN constant to simplify creation of device name. Since the max size should be already tested in validation, throw INTERNAL_ERROR if the size of vg/lv is bigger then NAME_LEN. --- tools/lvconvert.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 731d4c812..75eb56510 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -884,15 +884,13 @@ int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv, * the polldaemon, lvconvert, pvmove code that a comprehensive * audit/rework is needed */ - int len = strlen(lv->vg->name) + strlen(lv->name) + 2; - char *uuid = alloca(sizeof(lv->lvid)); - char *lv_full_name = alloca(len); + char uuid[sizeof(lv->lvid)]; + char lv_full_name[NAME_LEN]; - if (!uuid || !lv_full_name) - return_0; - - if (dm_snprintf(lv_full_name, len, "%s/%s", lv->vg->name, lv->name) < 0) - return_0; + if (dm_snprintf(lv_full_name, sizeof(lv_full_name), "%s/%s", lv->vg->name, lv->name) < 0) { + log_error(INTERNAL_ERROR "Name \"%s/%s\" is too long.", lv->vg->name, lv->name); + return 0; + } memcpy(uuid, &lv->lvid, sizeof(lv->lvid));