[Bug 6228] SMBC_open_ctx failure due to path resolve failure doesn't set errno
authorDerrell Lipman <derrell@dworkin.(none)>
Fri, 27 Mar 2009 21:10:04 +0000 (17:10 -0400)
committerKarolin Seeger <kseeger@samba.org>
Mon, 30 Mar 2009 10:02:45 +0000 (12:02 +0200)
Fixed.

It turns out there were a number of places where cli_resolve_path() was called
and the error path upon that function failing did not set errno. There were a
couple of places the failure handling code did set errno to ENOENT, so I made
them all consistent, although I think better errno choices for this condition
exist, e.g.  EHOSTUNREACH.

Derrell
(cherry picked from commit f4e68b09a6ba30d968bccfad8bf6b67b4456b111)

source/libsmb/libsmb_dir.c
source/libsmb/libsmb_file.c
source/libsmb/libsmb_stat.c

index b0762e89a34824a225070c52526718486be2d591..8ce660a7b6c79c848c65becec15552d01f2f146b 100644 (file)
@@ -1168,7 +1168,8 @@ SMBC_mkdir_ctx(SMBCCTX *context,
        if (!cli_resolve_path(frame, "", srv->cli, path,
                               &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
-               TALLOC_FREE(frame);
+                errno = ENOENT;
+                TALLOC_FREE(frame);
                return -1;
        }
        /*d_printf(">>>mkdir: resolved path as %s\n", targetpath);*/
@@ -1275,6 +1276,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
        if (!cli_resolve_path(frame, "", srv->cli, path,
                               &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1738,6 +1740,8 @@ SMBC_unlink_ctx(SMBCCTX *context,
        if (!cli_resolve_path(frame, "", srv->cli, path,
                               &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1904,6 +1908,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
        if (!cli_resolve_path(frame, "", srv->cli, path1,
                               &targetcli1, &targetpath1)) {
                d_printf("Could not resolve %s\n", path1);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1912,6 +1917,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
        if (!cli_resolve_path(frame, "", srv->cli, path2,
                               &targetcli2, &targetpath2)) {
                d_printf("Could not resolve %s\n", path2);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
index 27b7e4f823b6bfc23d95902db66519cd15635368..a8c26291ce6fec115231246f62faef1427b2dfb4 100644 (file)
@@ -118,6 +118,7 @@ SMBC_open_ctx(SMBCCTX *context,
                if (!cli_resolve_path(frame, "", srv->cli, path,
                                       &targetcli, &targetpath)) {
                        d_printf("Could not resolve %s\n", path);
+                        errno = ENOENT;
                        SAFE_FREE(file);
                        TALLOC_FREE(frame);
                        return NULL;
@@ -298,6 +299,7 @@ SMBC_read_ctx(SMBCCTX *context,
        if (!cli_resolve_path(frame, "", file->srv->cli, path,
                               &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -387,6 +389,7 @@ SMBC_write_ctx(SMBCCTX *context,
        if (!cli_resolve_path(frame, "", file->srv->cli, path,
                               &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -462,6 +465,7 @@ SMBC_close_ctx(SMBCCTX *context,
        if (!cli_resolve_path(frame, "", file->srv->cli, path,
                               &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -544,6 +548,7 @@ SMBC_getatr(SMBCCTX * context,
        if (!cli_resolve_path(frame, "", srv->cli, fixedpath,
                               &targetcli, &targetpath)) {
                d_printf("Couldn't resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return False;
        }
@@ -756,6 +761,7 @@ SMBC_lseek_ctx(SMBCCTX *context,
                if (!cli_resolve_path(frame, "", file->srv->cli, path,
                                       &targetcli, &targetpath)) {
                        d_printf("Could not resolve %s\n", path);
+                        errno = ENOENT;
                        TALLOC_FREE(frame);
                        return -1;
                }
@@ -847,6 +853,7 @@ SMBC_ftruncate_ctx(SMBCCTX *context,
        if (!cli_resolve_path(frame, "", file->srv->cli, path,
                               &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
index 27546f687ed3f1343f1713464673af9a398bbcbf..2aa4cffc5551e10cf213a7c88ed7142dc2a65878 100644 (file)
@@ -260,6 +260,7 @@ SMBC_fstat_ctx(SMBCCTX *context,
        if (!cli_resolve_path(frame, "", file->srv->cli, path,
                               &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }