[Bug 6228] SMBC_open_ctx failure due to path resolve failure doesn't set errno
authorDerrell Lipman <derrell@dworkin.(none)>
Fri, 27 Mar 2009 22:02:46 +0000 (18:02 -0400)
committerDerrell Lipman <derrell@dworkin.(none)>
Fri, 27 Mar 2009 22:02:46 +0000 (18:02 -0400)
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

source3/libsmb/libsmb_dir.c
source3/libsmb/libsmb_file.c
source3/libsmb/libsmb_stat.c

index 2255db66170fe872886d0ec9e57658fc4ef74fe2..219bbe64e120bf369174fcfe75ef6e170157de7f 100644 (file)
@@ -1171,7 +1171,8 @@ SMBC_mkdir_ctx(SMBCCTX *context,
                                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);*/
@@ -1278,6 +1279,7 @@ SMBC_rmdir_ctx(SMBCCTX *context,
                                srv->cli, path,
                                &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1561,6 +1563,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
                                srv->cli, path,
                                &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1753,6 +1756,7 @@ SMBC_unlink_ctx(SMBCCTX *context,
                                srv->cli, path,
                                &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1927,6 +1931,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
                                path1,
                                &targetcli1, &targetpath1)) {
                d_printf("Could not resolve %s\n", path1);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1944,6 +1949,7 @@ SMBC_rename_ctx(SMBCCTX *ocontext,
                                path2,
                                &targetcli2, &targetpath2)) {
                d_printf("Could not resolve %s\n", path2);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
index 06e41ad21eda75b8cd6f2a2b96e35b3cfad65c2b..aa02807092fedcae9e943bf931c2e34b18632617 100644 (file)
@@ -119,6 +119,7 @@ SMBC_open_ctx(SMBCCTX *context,
                                srv->cli, path,
                                &targetcli, &targetpath)) {
                        d_printf("Could not resolve %s\n", path);
+                        errno = ENOENT;
                        SAFE_FREE(file);
                        TALLOC_FREE(frame);
                        return NULL;
@@ -300,6 +301,7 @@ SMBC_read_ctx(SMBCCTX *context,
                        file->srv->cli, path,
                        &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -390,6 +392,7 @@ SMBC_write_ctx(SMBCCTX *context,
                        file->srv->cli, path,
                        &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -466,6 +469,7 @@ SMBC_close_ctx(SMBCCTX *context,
                        file->srv->cli, path,
                        &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -549,6 +553,7 @@ SMBC_getatr(SMBCCTX * context,
                        srv->cli, fixedpath,
                        &targetcli, &targetpath)) {
                d_printf("Couldn't resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return False;
        }
@@ -762,6 +767,7 @@ SMBC_lseek_ctx(SMBCCTX *context,
                                file->srv->cli, path,
                                &targetcli, &targetpath)) {
                        d_printf("Could not resolve %s\n", path);
+                        errno = ENOENT;
                        TALLOC_FREE(frame);
                        return -1;
                }
@@ -854,6 +860,7 @@ SMBC_ftruncate_ctx(SMBCCTX *context,
                        file->srv->cli, path,
                        &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }
index dc904d2753892a15e52d5a7a83fe1cc4e374cf16..c2806daddb9294d6f8fdc653abbbd8248cdcebdc 100644 (file)
@@ -261,6 +261,7 @@ SMBC_fstat_ctx(SMBCCTX *context,
                        file->srv->cli, path,
                        &targetcli, &targetpath)) {
                d_printf("Could not resolve %s\n", path);
+                errno = ENOENT;
                TALLOC_FREE(frame);
                return -1;
        }