]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
[Bug 6228] SMBC_open_ctx failure due to path resolve failure doesn't set errno
authorDerrell Lipman <derrell@dworkin.(none)>
Fri, 27 Mar 2009 20:56:33 +0000 (16:56 -0400)
committerDerrell Lipman <derrell@dworkin.(none)>
Fri, 27 Mar 2009 20:56:33 +0000 (16:56 -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

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

index 89782ce2a1dcb7d17114c63eef1ce8c91fa40ca7..8846abb9f6b38e9ea61b6722d8251d2bfe19dda3 100644 (file)
@@ -1169,7 +1169,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);*/
@@ -1276,6 +1277,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;
        }
@@ -1558,6 +1560,7 @@ SMBC_chmod_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;
        }
@@ -1749,6 +1752,7 @@ 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;
                TALLOC_FREE(frame);
                return -1;
        }
@@ -1921,6 +1925,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;
        }
@@ -1936,6 +1941,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 1bbb47daebec1f330f98fe2e57cba3dfa5373b65..8741ed6c6eb7aa83d5008df98974dff602670974 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 64ddc780a8d4fce11d1aa8ad466ed9a65a69e9b1..9e081afa8f824ffc8f643e4745a0f7793580d51c 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;
        }