From 1a2aba39e4ffc35928e013bceaeae063ac930e2e Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Mon, 29 Apr 2013 15:21:00 -0700 Subject: [PATCH] check_parent_exists() can change errno. Ensure we preserve it across calls. Reviewed-by: Jeremy Allison --- source3/smbd/filename.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index efa39f4..03e1d2d 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -450,13 +450,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; } @@ -529,13 +533,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; } -- 1.8.2.1