libsmb: Don't pass "sbuf" to cli_posix_stat_send()
authorVolker Lendecke <vl@samba.org>
Sat, 22 Feb 2020 13:55:07 +0000 (14:55 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 25 Feb 2020 17:44:45 +0000 (17:44 +0000)
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 <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/clifile.c
source3/libsmb/proto.h

index dd08b0e30f35fa3fe8347c4f7d0ce026a51ac900..0ba406a4f2af6896904bf7c3eb9e7a023b744323 100644 (file)
@@ -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);
index 48855d7112cf4ea6227ed9e475f080041638e562..12241fda79825d87bf74d27c1b711a994e981ac6 100644 (file)
@@ -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);