The branch, master has been updated
       via  5d68404dc0b auth: Direct variable initialization
       via  8a9011350cf auth: Remove unused session_info_set_session_key()
       via  e19e6ad0031 libsmb: Slightly simplify cli_tcon_andx_done()
       via  994e5778f5d libsmb: Move cli_smb() to source3/torture
       via  51b39cf457f libsmb: Move cli_smbwrite() to source3/torture
       via  30cedb1a5e1 tevent: Fix 1649525 Use of 32-bit time_t
       via  e9402516758 tevent: Fix Coverity ID 1649524 Dereference before null 
check
       via  b7a27ffe400 tevent: Fix Coverity ID 1649526 Dereference before null 
check
      from  da985349114 librpc/idl: Add idl for msDS-KeyCredentialLink

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5d68404dc0b1031f40d3a9016ccdddc23a95a870
Author: Volker Lendecke <[email protected]>
Date:   Thu Jun 19 17:44:31 2025 +0200

    auth: Direct variable initialization
    
    talloc_stackframe() panics on failure
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Anoop C S <[email protected]>
    
    Autobuild-User(master): Anoop C S <[email protected]>
    Autobuild-Date(master): Fri Jun 20 11:12:14 UTC 2025 on atb-devel-224

commit 8a9011350cf09a599efae73376e8d962decb0c8d
Author: Volker Lendecke <[email protected]>
Date:   Thu Jun 19 17:04:35 2025 +0200

    auth: Remove unused session_info_set_session_key()
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Anoop C S <[email protected]>

commit e19e6ad0031eb811debefea3c45cc8b30230ee35
Author: Volker Lendecke <[email protected]>
Date:   Thu Jun 19 13:11:27 2025 +0200

    libsmb: Slightly simplify cli_tcon_andx_done()
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Anoop C S <[email protected]>

commit 994e5778f5d0fd21b278c527a08b607000e39502
Author: Volker Lendecke <[email protected]>
Date:   Thu Jun 19 13:02:17 2025 +0200

    libsmb: Move cli_smb() to source3/torture
    
    Only used there
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Anoop C S <[email protected]>

commit 51b39cf457f940756b72fa0d242dd8268b56878a
Author: Volker Lendecke <[email protected]>
Date:   Thu Jun 19 13:00:18 2025 +0200

    libsmb: Move cli_smbwrite() to source3/torture
    
    Only used there
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Anoop C S <[email protected]>

commit 30cedb1a5e16b46b8efa7d6a3d907a6ac3136ae2
Author: Volker Lendecke <[email protected]>
Date:   Fri Jun 20 09:27:23 2025 +0200

    tevent: Fix 1649525 Use of 32-bit time_t
    
    Coverity ID "1649525 Use of 32-bit time_t" is correct. What Coverity
    does not see is that this routine is the only one assigning to
    ev->wait_timeout. Make Coverity happy with the MIN().
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Anoop C S <[email protected]>

commit e94025167586f2c9d336419122aadda5ea9a4b80
Author: Volker Lendecke <[email protected]>
Date:   Fri Jun 20 09:15:56 2025 +0200

    tevent: Fix Coverity ID 1649524 Dereference before null check
    
    The only caller of epoll_event_loop gives a non-NULL pointer.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Anoop C S <[email protected]>

commit b7a27ffe400db5b8685e040e8b22117afb60a445
Author: Volker Lendecke <[email protected]>
Date:   Fri Jun 20 09:12:47 2025 +0200

    tevent: Fix Coverity ID 1649526 Dereference before null check
    
    The only caller of poll_event_loop_poll gives a non-NULL pointer.
    
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Anoop C S <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 lib/tevent/tevent.c           |   2 +-
 lib/tevent/tevent_epoll.c     |   2 +-
 lib/tevent/tevent_poll.c      |   2 +-
 source3/auth/auth_util.c      |  27 +----------
 source3/auth/proto.h          |   2 -
 source3/libsmb/cliconnect.c   |   2 +-
 source3/libsmb/clientgen.c    |  37 ---------------
 source3/libsmb/clireadwrite.c |  68 ---------------------------
 source3/libsmb/proto.h        |   9 ----
 source3/torture/proto.h       |  10 ++++
 source3/torture/torture.c     | 105 ++++++++++++++++++++++++++++++++++++++++++
 11 files changed, 121 insertions(+), 145 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c
index c9f57fece94..12e1f407bc6 100644
--- a/lib/tevent/tevent.c
+++ b/lib/tevent/tevent.c
@@ -611,7 +611,7 @@ uint32_t tevent_context_set_wait_timeout(struct 
tevent_context *ev,
        ev->wait_timeout = tevent_timeval_set((time_t)secs,
                                              (secs == 0) ?  INT32_MAX: 0);
 
-       return ret;
+       return MIN(ret, INT32_MAX);
 }
 
 /*
diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c
index d13641ec347..ee5c96a95a3 100644
--- a/lib/tevent/tevent_epoll.c
+++ b/lib/tevent/tevent_epoll.c
@@ -614,7 +614,7 @@ static int epoll_event_loop(struct epoll_event_context 
*epoll_ev, struct timeval
                return -1;
        }
 
-       if (ret == 0 && tvalp) {
+       if (ret == 0) {
                /*
                 * tevent_context_set_wait_timeout(0) was used.
                 */
diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c
index 1733516eb0a..5b74c67eca7 100644
--- a/lib/tevent/tevent_poll.c
+++ b/lib/tevent/tevent_poll.c
@@ -506,7 +506,7 @@ static int poll_event_loop_poll(struct tevent_context *ev,
                return 0;
        }
 
-       if (pollrtn == 0 && tvalp) {
+       if (pollrtn == 0) {
                /*
                 * tevent_context_set_wait_timeout(0) was used.
                 */
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index abc5e959aab..b7a81f09c9e 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -1399,17 +1399,10 @@ static NTSTATUS make_new_session_info_guest(TALLOC_CTX 
*mem_ctx,
        struct auth_serversupplied_info *server_info = NULL;
        const char *guest_account = lp_guest_account();
        const char *domain = lp_netbios_name();
-       struct netr_SamInfo3 info3;
-       TALLOC_CTX *tmp_ctx;
+       struct netr_SamInfo3 info3 = {};
+       TALLOC_CTX *tmp_ctx = talloc_stackframe();
        NTSTATUS status;
 
-       tmp_ctx = talloc_stackframe();
-       if (tmp_ctx == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       ZERO_STRUCT(info3);
-
        status = get_guest_info3(tmp_ctx, &info3);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("get_guest_info3 failed with %s\n",
@@ -1748,22 +1741,6 @@ static struct auth_serversupplied_info 
*copy_session_info_serverinfo_guest(TALLO
        return dst;
 }
 
-/*
- * Set a new session key. Used in the rpc server where we have to override the
- * SMB level session key with SystemLibraryDTC
- */
-
-bool session_info_set_session_key(struct auth_session_info *info,
-                                DATA_BLOB session_key)
-{
-       TALLOC_FREE(info->session_key.data);
-
-       info->session_key = data_blob_talloc(
-               info, session_key.data, session_key.length);
-
-       return (info->session_key.data != NULL);
-}
-
 static struct auth_session_info *guest_info = NULL;
 static struct auth_session_info *anonymous_info = NULL;
 
diff --git a/source3/auth/proto.h b/source3/auth/proto.h
index d40422d5187..4283656ef59 100644
--- a/source3/auth/proto.h
+++ b/source3/auth/proto.h
@@ -273,8 +273,6 @@ NTSTATUS make_session_info_from_username(TALLOC_CTX 
*mem_ctx,
 bool init_guest_session_info(TALLOC_CTX *mem_ctx);
 bool reinit_guest_session_info(TALLOC_CTX *mem_ctx);
 NTSTATUS init_system_session_info(TALLOC_CTX *mem_ctx);
-bool session_info_set_session_key(struct auth_session_info *info,
-                                DATA_BLOB session_key);
 NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
                                struct auth_serversupplied_info **server_info);
 NTSTATUS make_session_info_guest(TALLOC_CTX *mem_ctx,
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 0dd7ddea6d0..82aef739d57 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -2073,7 +2073,7 @@ static void cli_tcon_andx_done(struct tevent_req *subreq)
                smb1cli_session_protect_session_key(cli->smb1.session);
        }
 
-       smb1cli_tcon_set_values(state->cli->smb1.tcon,
+       smb1cli_tcon_set_values(cli->smb1.tcon,
                                SVAL(inhdr, HDR_TID),
                                optional_support,
                                0, /* maximal_access */
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index d07156d2295..49cef9f8a49 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -613,40 +613,3 @@ NTSTATUS cli_echo(struct cli_state *cli, uint16_t 
num_echos, DATA_BLOB data)
        TALLOC_FREE(frame);
        return status;
 }
-
-NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
-                uint8_t smb_command, uint8_t additional_flags,
-                uint8_t wct, uint16_t *vwv,
-                uint32_t num_bytes, const uint8_t *bytes,
-                struct tevent_req **result_parent,
-                uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
-                uint32_t *pnum_bytes, uint8_t **pbytes)
-{
-        struct tevent_context *ev;
-        struct tevent_req *req = NULL;
-        NTSTATUS status = NT_STATUS_NO_MEMORY;
-
-        if (smbXcli_conn_has_async_calls(cli->conn)) {
-                return NT_STATUS_INVALID_PARAMETER;
-        }
-        ev = samba_tevent_context_init(mem_ctx);
-        if (ev == NULL) {
-                goto fail;
-        }
-        req = cli_smb_send(mem_ctx, ev, cli, smb_command, additional_flags, 0,
-                          wct, vwv, num_bytes, bytes);
-        if (req == NULL) {
-                goto fail;
-        }
-        if (!tevent_req_poll_ntstatus(req, ev, &status)) {
-                goto fail;
-        }
-        status = cli_smb_recv(req, NULL, NULL, min_wct, pwct, pvwv,
-                             pnum_bytes, pbytes);
-fail:
-        TALLOC_FREE(ev);
-       if (NT_STATUS_IS_OK(status) && (result_parent != NULL)) {
-               *result_parent = req;
-       }
-        return status;
-}
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index a7bef4497e5..c4005030816 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -858,74 +858,6 @@ NTSTATUS cli_read(struct cli_state *cli, uint16_t fnum,
        return NT_STATUS_OK;
 }
 
-/****************************************************************************
-  write to a file using a SMBwrite and not bypassing 0 byte writes
-****************************************************************************/
-
-NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
-                     off_t offset, size_t size1, size_t *ptotal)
-{
-       uint8_t *bytes;
-       ssize_t total = 0;
-
-       /*
-        * 3 bytes prefix
-        */
-
-       bytes = talloc_array(talloc_tos(), uint8_t, 3);
-       if (bytes == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
-       bytes[0] = 1;
-
-       do {
-               uint32_t usable_space = cli_state_available_size(cli, 48);
-               size_t size = MIN(size1, usable_space);
-               struct tevent_req *req;
-               uint16_t vwv[5];
-               uint16_t *ret_vwv;
-               NTSTATUS status;
-
-               SSVAL(vwv+0, 0, fnum);
-               SSVAL(vwv+1, 0, size);
-               SIVAL(vwv+2, 0, offset);
-               SSVAL(vwv+4, 0, 0);
-
-               bytes = talloc_realloc(talloc_tos(), bytes, uint8_t,
-                                            size+3);
-               if (bytes == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
-               SSVAL(bytes, 1, size);
-               memcpy(bytes + 3, buf + total, size);
-
-               status = cli_smb(talloc_tos(), cli, SMBwrite, 0, 5, vwv,
-                                size+3, bytes, &req, 1, NULL, &ret_vwv,
-                                NULL, NULL);
-               if (!NT_STATUS_IS_OK(status)) {
-                       TALLOC_FREE(bytes);
-                       return status;
-               }
-
-               size = SVAL(ret_vwv+0, 0);
-               TALLOC_FREE(req);
-               if (size == 0) {
-                       break;
-               }
-               size1 -= size;
-               total += size;
-               offset += size;
-
-       } while (size1);
-
-       TALLOC_FREE(bytes);
-
-       if (ptotal != NULL) {
-               *ptotal = total;
-       }
-       return NT_STATUS_OK;
-}
-
 /*
  * Send a write&x request
  */
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 97a83e46cb9..0163a1f883d 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -222,13 +222,6 @@ struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, 
struct tevent_context *ev,
                                 DATA_BLOB data);
 NTSTATUS cli_echo_recv(struct tevent_req *req);
 NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
-NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
-                uint8_t smb_command, uint8_t additional_flags,
-                uint8_t wct, uint16_t *vwv,
-                uint32_t num_bytes, const uint8_t *bytes,
-                struct tevent_req **result_parent,
-                uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
-                uint32_t *pnum_bytes, uint8_t **pbytes);
 
 /* The following definitions come from libsmb/clierror.c  */
 
@@ -917,8 +910,6 @@ NTSTATUS cli_read_recv(struct tevent_req *req, size_t 
*received);
 NTSTATUS cli_read(struct cli_state *cli, uint16_t fnum,
                  char *buf, off_t offset, size_t size,
                  size_t *nread);
-NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
-                     off_t offset, size_t size1, size_t *ptotal);
 struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
                                         struct tevent_context *ev,
                                         struct cli_state *cli, uint16_t fnum,
diff --git a/source3/torture/proto.h b/source3/torture/proto.h
index 8783776a2c3..2e29308e7f8 100644
--- a/source3/torture/proto.h
+++ b/source3/torture/proto.h
@@ -77,6 +77,16 @@ NTSTATUS torture_setup_unix_extensions(struct cli_state 
*cli);
 void torture_conn_set_sockopt(struct cli_state *cli);
 void torture_deltree(struct cli_state *cli, const char *dname);
 
+NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+                uint8_t smb_command, uint8_t additional_flags,
+                uint8_t wct, uint16_t *vwv,
+                uint32_t num_bytes, const uint8_t *bytes,
+                struct tevent_req **result_parent,
+                uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
+                uint32_t *pnum_bytes, uint8_t **pbytes);
+NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
+                     off_t offset, size_t size1, size_t *ptotal);
+
 NTSTATUS cli_qpathinfo1(struct cli_state *cli,
                        const char *fname,
                        time_t *change_time,
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index e735eb8247d..3d592429390 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -477,6 +477,111 @@ void torture_conn_set_sockopt(struct cli_state *cli)
        smbXcli_conn_set_sockopt(cli->conn, sockops);
 }
 
+/****************************************************************************
+  write to a file using a SMBwrite and not bypassing 0 byte writes
+****************************************************************************/
+
+NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
+                     off_t offset, size_t size1, size_t *ptotal)
+{
+       uint8_t *bytes;
+       ssize_t total = 0;
+
+       /*
+        * 3 bytes prefix
+        */
+
+       bytes = talloc_array(talloc_tos(), uint8_t, 3);
+       if (bytes == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       bytes[0] = 1;
+
+       do {
+               uint32_t usable_space = cli_state_available_size(cli, 48);
+               size_t size = MIN(size1, usable_space);
+               struct tevent_req *req;
+               uint16_t vwv[5];
+               uint16_t *ret_vwv;
+               NTSTATUS status;
+
+               SSVAL(vwv+0, 0, fnum);
+               SSVAL(vwv+1, 0, size);
+               SIVAL(vwv+2, 0, offset);
+               SSVAL(vwv+4, 0, 0);
+
+               bytes = talloc_realloc(talloc_tos(), bytes, uint8_t,
+                                            size+3);
+               if (bytes == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+               SSVAL(bytes, 1, size);
+               memcpy(bytes + 3, buf + total, size);
+
+               status = cli_smb(talloc_tos(), cli, SMBwrite, 0, 5, vwv,
+                                size+3, bytes, &req, 1, NULL, &ret_vwv,
+                                NULL, NULL);
+               if (!NT_STATUS_IS_OK(status)) {
+                       TALLOC_FREE(bytes);
+                       return status;
+               }
+
+               size = SVAL(ret_vwv+0, 0);
+               TALLOC_FREE(req);
+               if (size == 0) {
+                       break;
+               }
+               size1 -= size;
+               total += size;
+               offset += size;
+
+       } while (size1);
+
+       TALLOC_FREE(bytes);
+
+       if (ptotal != NULL) {
+               *ptotal = total;
+       }
+       return NT_STATUS_OK;
+}
+
+NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+                uint8_t smb_command, uint8_t additional_flags,
+                uint8_t wct, uint16_t *vwv,
+                uint32_t num_bytes, const uint8_t *bytes,
+                struct tevent_req **result_parent,
+                uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
+                uint32_t *pnum_bytes, uint8_t **pbytes)
+{
+        struct tevent_context *ev;
+        struct tevent_req *req = NULL;
+        NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+        if (smbXcli_conn_has_async_calls(cli->conn)) {
+                return NT_STATUS_INVALID_PARAMETER;
+        }
+        ev = samba_tevent_context_init(mem_ctx);
+        if (ev == NULL) {
+                goto fail;
+        }
+        req = cli_smb_send(mem_ctx, ev, cli, smb_command, additional_flags, 0,
+                          wct, vwv, num_bytes, bytes);
+        if (req == NULL) {
+                goto fail;
+        }
+        if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+                goto fail;
+        }
+        status = cli_smb_recv(req, NULL, NULL, min_wct, pwct, pvwv,
+                             pnum_bytes, pbytes);
+fail:
+        TALLOC_FREE(ev);
+       if (NT_STATUS_IS_OK(status) && (result_parent != NULL)) {
+               *result_parent = req;
+       }
+        return status;
+}
+
 static NTSTATUS torture_delete_fn(struct file_info *finfo,
                                  const char *pattern,
                                  void *state)


-- 
Samba Shared Repository

Reply via email to