vmdk: Check VMFS extent line field number

VMFS extent line in description file should be with 4 fields:

    RW <size> VMFS "file-name.vmdk"

Check the number explicitly and report error if offset is appended as
FLAT, which should be invalid format.

Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Fam Zheng 2013-12-09 13:24:36 +08:00 committed by Stefan Hajnoczi
parent 8282db1b2e
commit b47053bd03
3 changed files with 26 additions and 2 deletions

View file

@ -749,9 +749,14 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
return -EINVAL;
}
} else if (!strcmp(type, "VMFS")) {
flat_offset = 0;
if (ret == 4) {
flat_offset = 0;
} else {
error_setg(errp, "Invalid extent lines:\n%s", p);
return -EINVAL;
}
} else if (ret != 4) {
error_setg(errp, "Invalid extent lines: \n%s", p);
error_setg(errp, "Invalid extent lines:\n%s", p);
return -EINVAL;
}