vmdk: Fix vmdk_parse_extents
PATCH 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
@@ -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) { p++; +if (*p =='\n' ) { + p++; +break ; + } } - p++; }return 0 ; }
Signature · 1 line
1.8.3.1
Am 11.10.2013 um 08:04 hat Fam Zheng geschrieben:
Quoted 14 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.
Signed-off-by Fam Zheng <[email protected]>--- block/vmdk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)block/vmdk.c +0
-0
block/vmdk.c static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, · line 764
Quoted 6 lines
block/vmdk.c +1
-1@@ -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) { p++;
If the first not yet parsed character is \n, you're missing a line break now, aren't you?
block/vmdk.c static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, · line 772
Quoted 9 lines
block/vmdk.c +4
-1+if (*p =='\n' ) { + p++; +break ; + } } - p++; }return 0 ; }
Kevin
Quoted 10 lines · Kevin Wolf
Am 11.10.2013 um 08:04 hat Fam Zheng geschrieben:
Quoted 9 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.
Signed-off-by Fam Zheng <[email protected]>--- block/vmdk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 15 lines
block/vmdk.c static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, · line 764
Quoted 11 lines
block/vmdk.c +1
-1@@ -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) { p++;If the first not yet parsed character is \n, you're missing a line break now, aren't you?
Yes. This case it can miss a whole line following an empty line. Will fix. Thanks.
Fam