check_parent_exists() can change errno. Ensure we preserve it across calls.
authorAnand Avati <avati@redhat.com>
Mon, 29 Apr 2013 22:21:00 +0000 (15:21 -0700)
committerKarolin Seeger <kseeger@samba.org>
Thu, 6 Jun 2013 18:53:54 +0000 (20:53 +0200)
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Apr 30 11:00:11 CEST 2013 on sn-devel-104

Fix bug #9927 - errno gets overwritten in call to check_parent_exists().

source3/smbd/filename.c

index b2ed23972696109d6cfeb12faac8ff68210d2b59..207b56ce7722ca186f6f4d3715e06dde15650923 100644 (file)
@@ -445,13 +445,17 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 
                if (errno == ENOENT) {
                        /* Optimization when creating a new file - only
-                          the last component doesn't exist. */
+                          the last component doesn't exist.
+                          NOTE : check_parent_exists() doesn't preserve errno.
+                       */
+                       int saved_errno = errno;
                        status = check_parent_exists(ctx,
                                                conn,
                                                posix_pathnames,
                                                smb_fname,
                                                &dirpath,
                                                &start);
+                       errno = saved_errno;
                        if (!NT_STATUS_IS_OK(status)) {
                                goto fail;
                        }
@@ -524,13 +528,16 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                 * Optimization for common case where the wildcard
                 * is in the last component and the client already
                 * sent the correct case.
+                * NOTE : check_parent_exists() doesn't preserve errno.
                 */
+               int saved_errno = errno;
                status = check_parent_exists(ctx,
                                        conn,
                                        posix_pathnames,
                                        smb_fname,
                                        &dirpath,
                                        &start);
+               errno = saved_errno;
                if (!NT_STATUS_IS_OK(status)) {
                        goto fail;
                }