summaryrefslogtreecommitdiff
path: root/source3/lib/errmap_unix.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-08-10 10:43:36 +1000
committerMichael Adam <obnox@samba.org>2008-08-12 21:37:16 +0200
commit8b25ce06ceb4ad57fa585e76c1a6be12a4c7d3d2 (patch)
tree76caaaa23ec9a1978ed8e6bfabad1bd055c963a0 /source3/lib/errmap_unix.c
parent89dc729443fad26da346b8ef8d3ce596449ab7f9 (diff)
downloadsamba-8b25ce06ceb4ad57fa585e76c1a6be12a4c7d3d2.tar.gz
samba-8b25ce06ceb4ad57fa585e76c1a6be12a4c7d3d2.tar.bz2
samba-8b25ce06ceb4ad57fa585e76c1a6be12a4c7d3d2.zip
I found lots of places where we assume error will be set when calling
one of our virtualised functions, such as db_open(), but error is only set when a system call fails, and it is not uncommon for us to fail a function internally without ever making a system call. That led to us passing back success when a function had in fact failed. I found two places where we relied on map_nt_error_from_unix() returning success when errno==0, but lots and lots of places where we relied on the reverse, so I fixed those two places. map_nt_error_from_unix() will now always return an error, returning NT_STATUS_UNSUCCESSFUL if errno is 0 (cherry picked from commit 69d40ca4c1af925d4b0e59ddc69ef8c26e6501d1) (This used to be commit 834684a524a24bb4eb46b4af583d39947dc87d95)
Diffstat (limited to 'source3/lib/errmap_unix.c')
-rw-r--r--source3/lib/errmap_unix.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/source3/lib/errmap_unix.c b/source3/lib/errmap_unix.c
index 8194cf80cc..2cd2386c5c 100644
--- a/source3/lib/errmap_unix.c
+++ b/source3/lib/errmap_unix.c
@@ -107,8 +107,16 @@ NTSTATUS map_nt_error_from_unix(int unix_error)
{
int i = 0;
- if (unix_error == 0)
- return NT_STATUS_OK;
+ if (unix_error == 0) {
+ /* we map this to an error, not success, as this
+ function is only called in an error path. Lots of
+ our virtualised functions may fail without making a
+ unix system call that fails (such as when they are
+ checking for some handle existing), so unix_error
+ may be unset
+ */
+ return NT_STATUS_UNSUCCESSFUL;
+ }
/* Look through list */
while(unix_dos_nt_errmap[i].unix_error != 0) {