diff options
author | Volker Lendecke <vl@samba.org> | 2021-10-25 15:23:43 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2022-11-22 18:27:33 +0000 |
commit | 0c419b8a204bd21e8991356ac88188c98bcfbb79 (patch) | |
tree | 43e657ffe1809c2ef0132df0d53c88c97c41183b /libcli | |
parent | 218baae2d364dff581bb88ccd2a773e617ec8be8 (diff) | |
download | samba-0c419b8a204bd21e8991356ac88188c98bcfbb79.tar.gz |
libsmb: Return symlink error struct from smb2cli_create_recv()
Looks larger than it is, this just adds a parameter and while there
adapts long lines to README.Coding
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'libcli')
-rw-r--r-- | libcli/smb/smb2cli_create.c | 36 | ||||
-rw-r--r-- | libcli/smb/smbXcli_base.h | 8 | ||||
-rw-r--r-- | libcli/smb/tstream_smbXcli_np.c | 12 |
3 files changed, 36 insertions, 20 deletions
diff --git a/libcli/smb/smb2cli_create.c b/libcli/smb/smb2cli_create.c index 6417de6332d..596acb3d9a7 100644 --- a/libcli/smb/smb2cli_create.c +++ b/libcli/smb/smb2cli_create.c @@ -336,6 +336,11 @@ static NTSTATUS smb2cli_create_unparsed_unix_len( return NT_STATUS_INVALID_NETWORK_RESPONSE; } + if (unparsed_utf16_len == 0) { + *_unparsed_unix_len = 0; + return NT_STATUS_OK; + } + unparsed_utf16 = name_utf16 + name_utf16_len - unparsed_utf16_len; ok = convert_string_talloc( @@ -352,16 +357,7 @@ static NTSTATUS smb2cli_create_unparsed_unix_len( strerror(errno)); return status; } - - /* - * convert_string_talloc() returns a 0-terminated string - */ - SMB_ASSERT(unparsed_unix_len > 0); - SMB_ASSERT(unparsed_unix[unparsed_unix_len-1] == '\0'); - - TALLOC_FREE(unparsed_unix); - - *_unparsed_unix_len = (unparsed_unix_len-1); + *_unparsed_unix_len = unparsed_unix_len; return NT_STATUS_OK; } @@ -469,7 +465,8 @@ NTSTATUS smb2cli_create_recv(struct tevent_req *req, uint64_t *fid_volatile, struct smb_create_returns *cr, TALLOC_CTX *mem_ctx, - struct smb2_create_blobs *blobs) + struct smb2_create_blobs *blobs, + struct symlink_reparse_struct **psymlink) { struct smb2cli_create_state *state = tevent_req_data(req, @@ -477,6 +474,10 @@ NTSTATUS smb2cli_create_recv(struct tevent_req *req, NTSTATUS status; if (tevent_req_is_nterror(req, &status)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK) && + (psymlink != NULL)) { + *psymlink = talloc_move(mem_ctx, &state->symlink); + } tevent_req_received(req); return status; } @@ -510,7 +511,8 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn, uint64_t *fid_volatile, struct smb_create_returns *cr, TALLOC_CTX *mem_ctx, - struct smb2_create_blobs *ret_blobs) + struct smb2_create_blobs *ret_blobs, + struct symlink_reparse_struct **psymlink) { TALLOC_CTX *frame = talloc_stackframe(); struct tevent_context *ev; @@ -541,8 +543,14 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn, if (!tevent_req_poll_ntstatus(req, ev, &status)) { goto fail; } - status = smb2cli_create_recv(req, fid_persistent, fid_volatile, cr, - mem_ctx, ret_blobs); + status = smb2cli_create_recv( + req, + fid_persistent, + fid_volatile, + cr, + mem_ctx, + ret_blobs, + psymlink); fail: TALLOC_FREE(frame); return status; diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h index 8d2e6b3e204..bf8638711ba 100644 --- a/libcli/smb/smbXcli_base.h +++ b/libcli/smb/smbXcli_base.h @@ -647,6 +647,8 @@ NTSTATUS smb2cli_tdis(struct smbXcli_conn *conn, struct smbXcli_session *session, struct smbXcli_tcon *tcon); +struct symlink_reparse_struct; + struct tevent_req *smb2cli_create_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, @@ -668,7 +670,8 @@ NTSTATUS smb2cli_create_recv(struct tevent_req *req, uint64_t *fid_volatile, struct smb_create_returns *cr, TALLOC_CTX *mem_ctx, - struct smb2_create_blobs *blobs); + struct smb2_create_blobs *blobs, + struct symlink_reparse_struct **psymlink); NTSTATUS smb2cli_create(struct smbXcli_conn *conn, uint32_t timeout_msec, struct smbXcli_session *session, @@ -686,7 +689,8 @@ NTSTATUS smb2cli_create(struct smbXcli_conn *conn, uint64_t *fid_volatile, struct smb_create_returns *cr, TALLOC_CTX *mem_ctx, - struct smb2_create_blobs *ret_blobs); + struct smb2_create_blobs *ret_blobs, + struct symlink_reparse_struct **psymlink); struct tevent_req *smb2cli_close_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/libcli/smb/tstream_smbXcli_np.c b/libcli/smb/tstream_smbXcli_np.c index 8dfc4fb2466..ef685e16f4f 100644 --- a/libcli/smb/tstream_smbXcli_np.c +++ b/libcli/smb/tstream_smbXcli_np.c @@ -280,10 +280,14 @@ static void tstream_smbXcli_np_open_done(struct tevent_req *subreq) if (state->is_smb1) { status = smb1cli_ntcreatex_recv(subreq, &state->fnum); } else { - status = smb2cli_create_recv(subreq, - &state->fid_persistent, - &state->fid_volatile, - NULL, NULL, NULL); + status = smb2cli_create_recv( + subreq, + &state->fid_persistent, + &state->fid_volatile, + NULL, + NULL, + NULL, + NULL); } TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { |