Skip to contentSkip to conversation

vmdk: Fix vmdk_parse_extents

PATCH Applied Fam Zheng 2 participants 3 messages Oct 11, 2013 – Oct 14, 2013 Block layer

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH v2 1/1 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.

---
 block/vmdk.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
block/vmdk.c +5 -2
index 5d56e31..21f0fa7 100644
@@ -760,10 +760,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;
 }
Signature · 1 line
1.8.3.1
Applied
#1 lore raw

Am 11.10.2013 um 13:48 hat Fam Zheng geschrieben:

Quoted 5 lines

An extra 'p++' after while loop when *p == '\n' will move p to unknown data position, risking parsing junk data or memory access violation.

Thanks, applied to the block branch.

Kevin

author
#2 lore raw
In reply to Fam Zheng

Cc'ing [email protected].

Quoted 33 lines · Fam Zheng

An extra 'p++' after while loop when *p == '\n' will move p to unknown data position, risking parsing junk data or memory access violation.

---
 block/vmdk.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
block/vmdk.c +5 -2
index 5d56e31..21f0fa7 100644
@@ -760,10 +760,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;
 }
Signature · 1 line
1.8.3.1