On Thu, Nov 20, 2025 at 09:32:53AM +0100, Michal Privoznik via Devel wrote:
From: Michal Privoznik <[email protected]>

The esxParseVMXFileName() function parses path to a disk image
trying to replace some "known" patterns (e.g. datastore paths).
A simple filename is treated as a path relative to .vmx file. But
disk images (and thus filenames) can be in a subdirectory,
relative to the .vmx file. For instance:

 subfolder/disk.vmdk

Adapt our parser to this fact.

Resolves: https://issues.redhat.com/browse/RHEL-122751
Signed-off-by: Michal Privoznik <[email protected]>
---
src/esx/esx_driver.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 6452a33b7c..9f965811b1 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -138,7 +141,7 @@ esxParseVMXFileName(const char *fileName,

    *out = NULL;

-    if (!strchr(fileName, '/') && !strchr(fileName, '\\')) {
+    if (*fileName != '/' && !strchr(fileName, '\\')) {
        /* Plain file name, use same directory as for the .vmx file */
        *out = g_strdup_printf("%s/%s", data->datastorePathWithoutFileName,
                               fileName);

Now when I'm thinking about it, there probably should be some check that
it's not referring to too many parent directories?  Although once we get
it from the VMX it means it's already there...  And we probably leave
the checking to the server in the other (xml2vmx) case since we happily
forward any subdir/../../../../filename.vmdk there.  So I guess it's
fine.

Reviewed-by: Martin Kletzander <[email protected]>

Attachment: signature.asc
Description: PGP signature

Reply via email to