[sheepdog] [PATCH] collie: fix NULL dereference in find_vdi_name()

Liu Yuan namei.unix at gmail.com
Wed Feb 6 10:43:07 CET 2013


From: Liu Yuan <tailai.ly at taobao.com>

Some users pass NULL of tag to find_vdi_name, such as vdi_rollback(),
in this case we'll segfault.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 collie/vdi.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/collie/vdi.c b/collie/vdi.c
index 581dcdc..3fb7d68 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -396,7 +396,8 @@ static int find_vdi_name(const char *vdiname, uint32_t snapid, const char *tag,
 
 	memset(buf, 0, sizeof(buf));
 	pstrcpy(buf, SD_MAX_VDI_LEN, vdiname);
-	pstrcpy(buf + SD_MAX_VDI_LEN, SD_MAX_VDI_TAG_LEN, tag);
+	if (tag)
+		pstrcpy(buf + SD_MAX_VDI_LEN, SD_MAX_VDI_TAG_LEN, tag);
 
 	if (for_snapshot)
 		sd_init_req(&hdr, SD_OP_GET_VDI_INFO);
-- 
1.7.9.5




More information about the sheepdog mailing list