diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index a1ab41a..e743a58 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -1467,7 +1467,9 @@ int lvmetad_get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids)
 				return 0;
 			}
 
-			vgnl->vgid = dm_pool_strdup(cmd->mem, (char *)&vgid);
+                        char vgid_buffer[ID_LEN+1] = {0x0};
+                        memcpy(vgid_buffer, vgid.uuid, ID_LEN);
+                        vgnl->vgid = dm_pool_strdup(cmd->mem, vgid_buffer);
 			vgnl->vg_name = dm_pool_strdup(cmd->mem, vg_name);
 
 			if (!vgnl->vgid || !vgnl->vg_name) {
diff --git a/tools/command.c b/tools/command.c
index 377d03f..f2a2722 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1364,7 +1364,7 @@ static int _copy_line(char *line, int max_line, int *position)
 
 	memset(line, 0, max_line);
 
-	while (1) {
+	while ( p < strlen(_command_input) ) {
 		line[i] = _command_input[p];
 		i++;
 		p++;
