From 899f1ae219d5eaa96a53c996026cb0178d62a86d Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Fri, 11 Oct 2013 19:48:29 +0800 Subject: [PATCH] vmdk: Fix vmdk_parse_extents An extra 'p++' after while loop when *p == '\n' will move p to unknown data position, risking parsing junk data or memory access violation. Cc: qemu-stable@nongnu.org Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- block/vmdk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 709aa3deb0..5a9f2787f8 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -772,10 +772,13 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, } next_line: /* move to next line */ - while (*p && *p != '\n') { + while (*p) { + if (*p == '\n') { + p++; + break; + } p++; } - p++; } return 0; }