mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
vmdk: Allow space in file name
The previous scanf() format string stopped parsing the file name on the first white white space, which seems to be allowed at least by VMware Workstation. Change the format string to collect everything between the first and second quote as the file name, disallowing line breaks. Signed-off-by: Philipp Hahn <hahn@univention.de> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
46536235d8
commit
cd92347575
1 changed files with 1 additions and 9 deletions
10
block/vmdk.c
10
block/vmdk.c
|
@ -641,7 +641,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
|
|||
* RW [size in sectors] SPARSE "file-name.vmdk"
|
||||
*/
|
||||
flat_offset = -1;
|
||||
ret = sscanf(p, "%10s %" SCNd64 " %10s %511s %" SCNd64,
|
||||
ret = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64,
|
||||
access, §ors, type, fname, &flat_offset);
|
||||
if (ret < 4 || strcmp(access, "RW")) {
|
||||
goto next_line;
|
||||
|
@ -653,14 +653,6 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* trim the quotation marks around */
|
||||
if (fname[0] == '"') {
|
||||
memmove(fname, fname + 1, strlen(fname));
|
||||
if (strlen(fname) <= 1 || fname[strlen(fname) - 1] != '"') {
|
||||
return -EINVAL;
|
||||
}
|
||||
fname[strlen(fname) - 1] = '\0';
|
||||
}
|
||||
if (sectors <= 0 ||
|
||||
(strcmp(type, "FLAT") && strcmp(type, "SPARSE")) ||
|
||||
(strcmp(access, "RW"))) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue