From: Anand Avati Date: Mon, 29 Apr 2013 22:21:00 +0000 (-0700) Subject: check_parent_exists() can change errno. Ensure we preserve it across calls. X-Git-Tag: samba-3.6.16~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eb55971697731c3d6c84b2f76867a8c0d02a69fa;p=thirdparty%2Fsamba.git check_parent_exists() can change errno. Ensure we preserve it across calls. Reviewed-by: Jeremy Allison Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke 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(). (cherry picked from commit b5243a52a237b524b7afb8125c4b75378af622d1) --- diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index b2ed2397269..207b56ce772 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -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; }