From: Volker Lendecke Date: Sat, 22 Feb 2020 13:55:07 +0000 (+0100) Subject: libsmb: Don't pass "sbuf" to cli_posix_stat_send() X-Git-Tag: ldb-2.2.0~1601 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15769f11a4da2f4e00dda5eac49560c91faa2ebb;p=thirdparty%2Fsamba.git libsmb: Don't pass "sbuf" to cli_posix_stat_send() Don't pass in the result buffer upon _send(), let the _recv() function fill this in. Internal API only, adapt to current conventions. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index dd08b0e30f3..0ba406a4f2a 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -741,7 +741,7 @@ NTSTATUS cli_posix_setacl(struct cli_state *cli, ****************************************************************************/ struct stat_state { - SMB_STRUCT_STAT *sbuf; + SMB_STRUCT_STAT sbuf; }; static void cli_posix_stat_done(struct tevent_req *subreq); @@ -749,8 +749,7 @@ static void cli_posix_stat_done(struct tevent_req *subreq); struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, - const char *fname, - SMB_STRUCT_STAT *sbuf) + const char *fname) { struct tevent_req *req = NULL, *subreq = NULL; struct stat_state *state = NULL; @@ -759,7 +758,6 @@ struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx, if (req == NULL) { return NULL; } - state->sbuf = sbuf; subreq = cli_qpathinfo_send(state, ev, cli, fname, SMB_QUERY_FILE_UNIX_BASIC, 100, 100); @@ -775,7 +773,7 @@ static void cli_posix_stat_done(struct tevent_req *subreq) struct tevent_req *req = tevent_req_callback_data( subreq, struct tevent_req); struct stat_state *state = tevent_req_data(req, struct stat_state); - SMB_STRUCT_STAT *sbuf = state->sbuf; + SMB_STRUCT_STAT *sbuf = &state->sbuf; uint8_t *data; uint32_t num_data = 0; NTSTATUS status; @@ -795,8 +793,6 @@ static void cli_posix_stat_done(struct tevent_req *subreq) return; } - *sbuf = (SMB_STRUCT_STAT) { 0 }; - /* total size, in bytes */ sbuf->st_ex_size = IVAL2_TO_SMB_BIG_UINT(data, 0); @@ -840,9 +836,20 @@ static void cli_posix_stat_done(struct tevent_req *subreq) tevent_req_done(req); } -NTSTATUS cli_posix_stat_recv(struct tevent_req *req) +NTSTATUS cli_posix_stat_recv(struct tevent_req *req, + SMB_STRUCT_STAT *sbuf) { - return tevent_req_simple_recv_ntstatus(req); + struct stat_state *state = tevent_req_data(req, struct stat_state); + NTSTATUS status; + + if (tevent_req_is_nterror(req, &status)) { + return status; + } + if (sbuf != NULL) { + *sbuf = state->sbuf; + } + tevent_req_received(req); + return NT_STATUS_OK; } NTSTATUS cli_posix_stat(struct cli_state *cli, @@ -868,7 +875,7 @@ NTSTATUS cli_posix_stat(struct cli_state *cli, goto fail; } - req = cli_posix_stat_send(frame, ev, cli, fname, sbuf); + req = cli_posix_stat_send(frame, ev, cli, fname); if (req == NULL) { status = NT_STATUS_NO_MEMORY; goto fail; @@ -878,7 +885,7 @@ NTSTATUS cli_posix_stat(struct cli_state *cli, goto fail; } - status = cli_posix_stat_recv(req); + status = cli_posix_stat_recv(req, sbuf); fail: TALLOC_FREE(frame); diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index 48855d7112c..12241fda798 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -310,9 +310,9 @@ NTSTATUS cli_posix_setacl(struct cli_state *cli, struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, - const char *fname, - SMB_STRUCT_STAT *sbuf); -NTSTATUS cli_posix_stat_recv(struct tevent_req *req); + const char *fname); +NTSTATUS cli_posix_stat_recv(struct tevent_req *req, + SMB_STRUCT_STAT *sbuf); NTSTATUS cli_posix_stat(struct cli_state *cli, const char *fname, SMB_STRUCT_STAT *sbuf);