218e99
From 24b35c7de7077b977ab71ccddbe004bfc4e28d82 Mon Sep 17 00:00:00 2001
218e99
From: Fam Zheng <famz@redhat.com>
218e99
Date: Thu, 7 Nov 2013 16:03:34 +0100
218e99
Subject: [PATCH 22/25] vmdk: Fix vmdk_parse_extents
218e99
218e99
RH-Author: Fam Zheng <famz@redhat.com>
218e99
Message-id: <1383795369-10623-2-git-send-email-famz@redhat.com>
218e99
Patchwork-id: 55585
218e99
O-Subject: [RHEL-7 qemu-kvm PATCH 1/2] vmdk: Fix vmdk_parse_extents
218e99
Bugzilla: 995866
218e99
RH-Acked-by: Amos Kong <akong@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
218e99
An extra 'p++' after while loop when *p == '\n' will move p to unknown
218e99
data position, risking parsing junk data or memory access violation.
218e99
218e99
Cc: qemu-stable@nongnu.org
218e99
Signed-off-by: Fam Zheng <famz@redhat.com>
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
(cherry picked from commit 899f1ae219d5eaa96a53c996026cb0178d62a86d)
218e99
Signed-off-by: Fam Zheng <famz@redhat.com>
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block/vmdk.c |    7 +++++--
218e99
 1 files changed, 5 insertions(+), 2 deletions(-)
218e99
218e99
diff --git a/block/vmdk.c b/block/vmdk.c
218e99
index a3267fe..f2237cf 100644
218e99
--- a/block/vmdk.c
218e99
+++ b/block/vmdk.c
218e99
@@ -782,10 +782,13 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
218e99
         extent->type = g_strdup(type);
218e99
 next_line:
218e99
         /* move to next line */
218e99
-        while (*p && *p != '\n') {
218e99
+        while (*p) {
218e99
+            if (*p == '\n') {
218e99
+                p++;
218e99
+                break;
218e99
+            }
218e99
             p++;
218e99
         }
218e99
-        p++;
218e99
     }
218e99
     return 0;
218e99
 }
218e99
-- 
218e99
1.7.1
218e99