lvm2/9002-bugfix-fix-the-code-maybe-lead-to-buffer-over-bound-access.patch
2020-05-12 23:01:26 +08:00

36 lines
1.2 KiB
Diff

From beb01e5eeb2c913854f9df104af089be274eff59 Mon Sep 17 00:00:00 2001
From: wangjufeng <wangjufeng@huawei.com>
Date: Wed, 15 Apr 2020 21:25:28 +0800
Subject: [PATCH] fix the code maybe lead to buffer over bound
Signed-off-by: wangjufeng<wangjufeng@huawei.com>
---
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++;