vfs: Don't mask shadow_copy2_convert()'s errno
authorVolker Lendecke <vl@samba.org>
Fri, 4 Mar 2022 15:38:34 +0000 (16:38 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 10 Mar 2022 18:23:35 +0000 (18:23 +0000)
If it's really ENOMEM, shadow_copy2_convert() did set this itself. It
might also return ENOENT for example. Found this while working on
other patches.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_shadow_copy2.c

index 8deac59c1d57f73edcb4cdacca3ba8c8887a0769..1bba9a8e2b04424f116edd70a2a48e1a36aafe24 100644 (file)
@@ -1469,12 +1469,14 @@ static int shadow_copy2_openat(vfs_handle_struct *handle,
                                               handle,
                                               stripped,
                                               timestamp);
-       TALLOC_FREE(stripped);
        if (smb_fname->base_name == NULL) {
+               int err = errno;
+               TALLOC_FREE(stripped);
                TALLOC_FREE(smb_fname);
-               errno = ENOMEM;
+               errno = err;
                return -1;
        }
+       TALLOC_FREE(stripped);
 
        /*
         * Just pave over the user requested mode and use O_RDONLY. Later