From: Geoff Hickey Date: Mon, 14 Oct 2013 22:14:33 +0000 (-0400) Subject: esx: Fix floppy.fileName handling in the vmx file parser X-Git-Tag: CVE-2013-4401~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=842f6fd3384d58c7b1cc6b56ddb9f0eeab9a99a3;p=thirdparty%2Flibvirt.git esx: Fix floppy.fileName handling in the vmx file parser The vmx file parsing code was reporting errors when parsing floppy.fileName entries if the filename didn't end in .flp. There is no such restriction in ESX; even using the GUI to configure floppy filenames you can specify any arbitrary file with any extension. Fix by changing the vmx parsing code so that it uses the floppy.fileType value to determine whether floppy.fileName refers to a block device or a regular file. Also remove code that would have generated an error if no floppy.fileName was specified. This is not an error either. Updated the floppy tests in vmx2xmltest.c and xml2vmxtest.c. --- diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 36bc33886b..48487f832f 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2250,27 +2250,14 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con goto cleanup; } } else if (device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) { - if (virFileHasSuffix(fileName, ".flp")) { - if (fileType != NULL) { - if (STRCASENEQ(fileType, "file")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Expecting VMX entry '%s' to be 'file' but " - "found '%s'"), fileType_name, fileType); - goto cleanup; - } - } - - (*def)->type = VIR_DOMAIN_DISK_TYPE_FILE; - (*def)->src = ctx->parseFileName(fileName, ctx->opaque); - - if ((*def)->src == NULL) { - goto cleanup; - } - } else if (fileType != NULL && STRCASEEQ(fileType, "device")) { + if (fileType != NULL && STRCASEEQ(fileType, "device")) { (*def)->type = VIR_DOMAIN_DISK_TYPE_BLOCK; (*def)->src = fileName; fileName = NULL; + } else if (fileType != NULL && STRCASEEQ(fileType, "file")) { + (*def)->type = VIR_DOMAIN_DISK_TYPE_FILE; + (*def)->src = ctx->parseFileName(fileName, ctx->opaque); } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid or not yet handled value '%s' " @@ -3538,13 +3525,6 @@ virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def, virBufferAsprintf(buffer, "floppy%d.fileType = \"file\"\n", unit); if (def->src != NULL) { - if (! virFileHasSuffix(def->src, ".flp")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Image file for floppy '%s' has unsupported " - "suffix, expecting '.flp'"), def->dst); - return -1; - } - fileName = ctx->formatFileName(def->src, ctx->opaque); if (fileName == NULL) { diff --git a/tests/vmx2xmldata/vmx2xml-floppy-file.vmx b/tests/vmx2xmldata/vmx2xml-floppy-file.vmx index b9ee81baf4..ff50117d16 100644 --- a/tests/vmx2xmldata/vmx2xml-floppy-file.vmx +++ b/tests/vmx2xmldata/vmx2xml-floppy-file.vmx @@ -3,3 +3,6 @@ virtualHW.version = "4" floppy0.present = "true" floppy0.fileType = "file" floppy0.fileName = "floppy.flp" +floppy1.present = "true" +floppy1.fileType = "file" +floppy1.fileName = "floppy" diff --git a/tests/vmx2xmldata/vmx2xml-floppy-file.xml b/tests/vmx2xmldata/vmx2xml-floppy-file.xml index f62320f832..40f70d3052 100644 --- a/tests/vmx2xmldata/vmx2xml-floppy-file.xml +++ b/tests/vmx2xmldata/vmx2xml-floppy-file.xml @@ -16,6 +16,11 @@
+ + + +
+