The branch, master has been updated
       via  8ee20346745 smbd: Use an idtree for local IDs
       via  b73ecb28a7a lib: Remove idtree from samba_util.h
       via  743df9009b4 smbd: Simplify smbXsrv_open_set_replay_cache() with 
dbwrap_store_bystring()
       via  bac265689ac smbd: Simplify smbXsrv_open_set_replay_cache() with a 
struct assignment
       via  43f041de656 lib: Add "starting_id" to idr_get_new_random()
       via  a71288e86bd smbd: Remove smbXsrv_open->db_rec
       via  fdca0558efa smbd: Remove a "can't happen" NULL check
       via  0c709cb6b70 smbd: Use talloc_tos() for pushing smbXsrv_open_globalB
       via  88191630d20 lib: Use tdb_data_dbg() where appropriate
       via  9d7c7357a41 lib: Add tdb_data_dbg()
       via  ea7abdc1308 smbd: Avoid explicit ZERO_STRUCT()
       via  db25f0a07cf smbd: Move bytes from r/w data to r/o text section
       via  e0fc84668ba lib: Move 16 bytes to readonly .text segment
       via  14f761ec7dd lib: Remove unused smb_mkstemp prototype
       via  7ee474d9fd1 lib: Move tab_depth() to reg_parse_prs.c
       via  6907db5cf0a lib: Make map_share_mode_to_deny_mode() static to 
smbstatus
       via  158314e0b1d smbd: Make get_safe_[[SI]VAL|ptr] static to 
smb1_lanman.c
      from  56837f3d316 CVE-2022-38023 s3:rpc_server/netlogon: Avoid 
unnecessary loadparm_context allocations

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


- Log -----------------------------------------------------------------
commit 8ee203467455da0b9f774acbcc44e9b58570d811
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 12:18:44 2023 +0100

    smbd: Use an idtree for local IDs
    
    Volatile file handle IDs are purely per-process, in fact we used a
    dbwrap_rbt for this. To get a unique ID we however have the
    specialized idtree data structure, we don't need to repeat the
    allocation algorithm that already exists there.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Tue Jan 10 01:23:38 UTC 2023 on sn-devel-184

commit b73ecb28a7ac5996e1a8c455d15f41f59d9d8765
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Jan 5 10:04:23 2023 +0100

    lib: Remove idtree from samba_util.h
    
    No need to recompile the world when only a few files need this.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 743df9009b4b9aa9d6f85a999fa9e5237f96f2b7
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 12:34:43 2023 +0100

    smbd: Simplify smbXsrv_open_set_replay_cache() with dbwrap_store_bystring()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit bac265689acd081c264013d680219078b1ef466d
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 12:31:26 2023 +0100

    smbd: Simplify smbXsrv_open_set_replay_cache() with a struct assignment
    
    Use a direct struct assignment instead of a function call
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 43f041de6567bcb40a8e4564fce66ee08af6cc0b
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 11:43:59 2023 +0100

    lib: Add "starting_id" to idr_get_new_random()
    
    To be used in smbXsrv_open.c, for this we need a lower bound.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit a71288e86bda43caf6feaff22a36942e6595a971
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 11:29:51 2023 +0100

    smbd: Remove smbXsrv_open->db_rec
    
    This was only referenced in smbXsrv_open_close, but it was never
    assigned anything but NULL.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit fdca0558efa7a22e98b851480509d2b7f11df2e0
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 10:13:31 2023 +0100

    smbd: Remove a "can't happen" NULL check
    
    This should really not happen, crashing would be the right response.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 0c709cb6b70ed94b82a598bf3fb581ffb7c48200
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 10:12:22 2023 +0100

    smbd: Use talloc_tos() for pushing smbXsrv_open_globalB
    
    Use the toplevel talloc pool
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 88191630d2060ead9698c791e0d708d6e97ab83e
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 09:52:50 2023 +0100

    lib: Use tdb_data_dbg() where appropriate
    
    This changes the talloc hierarchy for a few callers, but as
    talloc_tos() was initially designed exactly for this purpose (printing
    SIDs in DEBUG), it should be okay.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 9d7c7357a4138989aaaa8311d0fb842968050a37
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 09:40:06 2023 +0100

    lib: Add tdb_data_dbg()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit ea7abdc1308e8a718862539b595fe1b09bc43ed9
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 08:50:28 2023 +0100

    smbd: Avoid explicit ZERO_STRUCT()
    
    Saves a few bytes of .text
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit db25f0a07cff924939914a33068d1d3e4fc1ca3c
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Jan 4 06:22:55 2023 +0100

    smbd: Move bytes from r/w data to r/o text section
    
    Even const arrays of const strings need to be relocated at startup time.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit e0fc84668ba1ec2048354fb1b674d2673454fde7
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Jan 3 19:32:41 2023 +0100

    lib: Move 16 bytes to readonly .text segment
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 14f761ec7dde9185717ef178d7fc2118d12ee49e
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Jan 3 19:27:50 2023 +0100

    lib: Remove unused smb_mkstemp prototype
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 7ee474d9fd180c43f5344b81b6ba0b2fc09f756e
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Jan 3 19:14:24 2023 +0100

    lib: Move tab_depth() to reg_parse_prs.c
    
    Wow, I did not know we still use prs_struct...
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 6907db5cf0a586db2bfe3a508c753be44bdc317f
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Jan 3 18:45:14 2023 +0100

    lib: Make map_share_mode_to_deny_mode() static to smbstatus
    
    At some point in the future this might disappear, we should really not
    show DOS share modes in smbstatus. Maybe this can't be changed though.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 158314e0b1df76e87fc3b1cd1260e703a21ce1ca
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Jan 3 18:41:04 2023 +0100

    smbd: Make get_safe_[[SI]VAL|ptr] static to smb1_lanman.c
    
    SMB1-specific, only used there.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

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

Summary of changes:
 examples/fuse/clifuse.c            |   1 +
 lib/util/idtree_random.c           |  16 +-
 lib/util/idtree_random.h           |   5 +-
 lib/util/samba_util.h              |   3 -
 lib/util/tests/idtree.c            |   1 +
 libcli/cldap/cldap.c               |   5 +-
 libcli/nbt/nbtsocket.c             |   4 +-
 librpc/rpc/dcesrv_core.c           |   1 +
 source3/auth/auth_samba4.c         |   1 +
 source3/include/proto.h            |   6 -
 source3/include/util_tdb.h         |   1 +
 source3/lib/filename_util.c        |   2 +-
 source3/lib/g_lock.c               |   8 +-
 source3/lib/util.c                 |  69 ------
 source3/lib/util_tdb.c             |   5 +
 source3/libads/kerberos.c          |   6 +-
 source3/librpc/idl/smbXsrv.idl     |   1 -
 source3/libsmb/cli_smb2_fnum.c     |   1 +
 source3/locking/share_mode_lock.c  |   2 +-
 source3/registry/reg_parse_prs.c   |   8 +
 source3/rpc_server/rpc_server.c    |   2 +
 source3/rpc_server/rpc_worker.c    |   2 +-
 source3/smbd/smb1_lanman.c         |  56 +++++
 source3/smbd/smb2_trans2.c         |  21 +-
 source3/smbd/smbXsrv_client.c      |  22 +-
 source3/smbd/smbXsrv_open.c        | 423 ++++++-------------------------------
 source3/smbd/smbXsrv_session.c     |  29 ++-
 source3/smbd/smbXsrv_tcon.c        |  29 ++-
 source3/utils/status.c             |  22 ++
 source4/lib/messaging/messaging.c  |   1 +
 source4/nbt_server/interfaces.c    |   2 +-
 source4/ntvfs/posix/pvfs_search.c  |   1 +
 source4/ntvfs/posix/vfs_posix.c    |   1 +
 source4/rpc_server/dcerpc_server.c |   4 +-
 source4/smb_server/handle.c        |   2 +-
 source4/smb_server/session.c       |   8 +-
 source4/smb_server/smb2/receive.c  |   2 +-
 source4/smb_server/tcon.c          |   4 +-
 38 files changed, 260 insertions(+), 517 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/fuse/clifuse.c b/examples/fuse/clifuse.c
index 2d9edad5f47..75cb72f7f87 100644
--- a/examples/fuse/clifuse.c
+++ b/examples/fuse/clifuse.c
@@ -31,6 +31,7 @@
 #include "libcli/smb/smbXcli_base.h"
 #include "libcli/security/security.h"
 #include "clifuse.h"
+#include "lib/util/idtree.h"
 
 struct mount_state {
        struct tevent_context *ev;
diff --git a/lib/util/idtree_random.c b/lib/util/idtree_random.c
index 80758e74d6d..d22245a7734 100644
--- a/lib/util/idtree_random.c
+++ b/lib/util/idtree_random.c
@@ -40,7 +40,10 @@
 /**
   allocate a new id randomly in the given range
 */
-_PUBLIC_ int idr_get_new_random(struct idr_context *idp, void *ptr, int limit)
+_PUBLIC_ int idr_get_new_random(struct idr_context *idp,
+                               void *ptr,
+                               int starting_id,
+                               int limit)
 {
        int id;
 
@@ -48,12 +51,17 @@ _PUBLIC_ int idr_get_new_random(struct idr_context *idp, 
void *ptr, int limit)
           then start randomly in the bottom half of the range. This can only
           fail if the range is over half full, and finally fallback to any
           free id */
-       id = idr_get_new_above(idp, ptr, 1+(generate_random() % limit), limit);
+       id = idr_get_new_above(
+               idp, ptr, starting_id+(generate_random() % limit), limit);
        if (id == -1) {
-               id = idr_get_new_above(idp, ptr, 
1+(generate_random()%(limit/2)), limit);
+               id = idr_get_new_above(
+                       idp,
+                       ptr,
+                       starting_id+(generate_random()%(limit/2)),
+                       limit);
        }
        if (id == -1) {
-               id = idr_get_new_above(idp, ptr, 1, limit);
+               id = idr_get_new_above(idp, ptr, starting_id, limit);
        }
 
        return id;
diff --git a/lib/util/idtree_random.h b/lib/util/idtree_random.h
index 4d3b61c33d5..623147c48a7 100644
--- a/lib/util/idtree_random.h
+++ b/lib/util/idtree_random.h
@@ -33,6 +33,9 @@
 /**
   allocate a new id randomly in the given range
 */
-int idr_get_new_random(struct idr_context *idp, void *ptr, int limit);
+int idr_get_new_random(struct idr_context *idp,
+                      void *ptr,
+                      int starting_id,
+                      int limit);
 
 #endif /* _SAMBA_IDTREE_RANDOM_H_ */
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index d8c8522616d..4eecfb8a583 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -589,9 +589,6 @@ int ms_fnmatch_protocol(const char *pattern, const char 
*string, int protocol,
 /** a generic fnmatch function - uses for non-CIFS pattern matching */
 int gen_fnmatch(const char *pattern, const char *string);
 
-#include "idtree.h"
-#include "idtree_random.h"
-
 #include "become_daemon.h"
 
 /**
diff --git a/lib/util/tests/idtree.c b/lib/util/tests/idtree.c
index f4f7b1130e2..d54ab2773ff 100644
--- a/lib/util/tests/idtree.c
+++ b/lib/util/tests/idtree.c
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "torture/torture.h"
 #include "torture/local/proto.h"
+#include "lib/util/idtree.h"
 
 static bool torture_local_idtree_simple(struct torture_context *tctx)
 {
diff --git a/libcli/cldap/cldap.c b/libcli/cldap/cldap.c
index 3cca85b9921..6c2bf86c111 100644
--- a/libcli/cldap/cldap.c
+++ b/libcli/cldap/cldap.c
@@ -43,6 +43,7 @@
 #include "../librpc/gen_ndr/ndr_nbt.h"
 #include "../lib/util/asn1.h"
 #include "../lib/util/tevent_ntstatus.h"
+#include "lib/util/idtree_random.h"
 
 #undef strcasecmp
 
@@ -623,8 +624,8 @@ struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
                state->request.dest = NULL;
        }
 
-       state->message_id = idr_get_new_random(cldap->searches.idr,
-                                              state, UINT16_MAX);
+       state->message_id = idr_get_new_random(
+               cldap->searches.idr, state, 1, UINT16_MAX);
        if (state->message_id == -1) {
                tevent_req_nterror(req, NT_STATUS_INSUFFICIENT_RESOURCES);
                goto post;
diff --git a/libcli/nbt/nbtsocket.c b/libcli/nbt/nbtsocket.c
index 97b0ca34337..47e73cf2e8d 100644
--- a/libcli/nbt/nbtsocket.c
+++ b/libcli/nbt/nbtsocket.c
@@ -27,6 +27,7 @@
 #include "lib/socket/socket.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
 #include "param/param.h"
+#include "lib/util/idtree_random.h"
 
 #define NBT_MAX_REPLIES 1000
 
@@ -407,7 +408,8 @@ struct nbt_name_request *nbt_name_request_send(TALLOC_CTX 
*mem_ctx,
 
        /* we select a random transaction id unless the user supplied one */
        if (request->name_trn_id == 0) {
-               id = idr_get_new_random(req->nbtsock->idr, req, UINT16_MAX);
+               id = idr_get_new_random(
+                       req->nbtsock->idr, req, 1, UINT16_MAX);
        } else {
                if (idr_find(req->nbtsock->idr, request->name_trn_id)) goto 
failed;
                id = idr_get_new_above(req->nbtsock->idr, req, 
request->name_trn_id,
diff --git a/librpc/rpc/dcesrv_core.c b/librpc/rpc/dcesrv_core.c
index 9fd71812905..d2870046248 100644
--- a/librpc/rpc/dcesrv_core.c
+++ b/librpc/rpc/dcesrv_core.c
@@ -34,6 +34,7 @@
 #include "librpc/gen_ndr/ndr_dcerpc.h"
 #include "lib/util/tevent_ntstatus.h"
 #include "system/network.h"
+#include "lib/util/idtree_random.h"
 
 /**
  * @file
diff --git a/source3/auth/auth_samba4.c b/source3/auth/auth_samba4.c
index 6c017ef4aa3..dec67a488d7 100644
--- a/source3/auth/auth_samba4.c
+++ b/source3/auth/auth_samba4.c
@@ -29,6 +29,7 @@
 #include "auth/gensec/gensec.h"
 #include "auth/credentials/credentials.h"
 #include "lib/global_contexts.h"
+#include "lib/util/idtree.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_AUTH
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 79d424fd10d..ae2a9533f23 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -335,11 +335,9 @@ void set_remote_arch(enum remote_arch_types type);
 enum remote_arch_types get_remote_arch(void);
 bool remote_arch_cache_update(const struct GUID *client_guid);
 bool remote_arch_cache_delete(const struct GUID *client_guid);
-const char *tab_depth(int level, int depth);
 int str_checksum(const char *s);
 void zero_free(void *p, size_t size);
 int set_maxfiles(int requested_max);
-int smb_mkstemp(char *name_template);
 void *smb_xmalloc_array(size_t size, unsigned int count);
 char *myhostname(void);
 char *myhostname_upper(void);
@@ -353,16 +351,12 @@ bool mask_match_search(const char *string, const char 
*pattern, bool is_case_sen
 bool mask_match_list(const char *string, char **list, int listLen, bool 
is_case_sensitive);
 #include "lib/util/unix_match.h"
 bool name_to_fqdn(fstring fqdn, const char *name);
-uint32_t map_share_mode_to_deny_mode(uint32_t share_access, uint32_t 
private_options);
 
 #include "lib/util_procid.h"
 
 struct server_id interpret_pid(const char *pid_string);
 bool is_offset_safe(const char *buf_base, size_t buf_len, char *ptr, size_t 
off);
-char *get_safe_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t 
off);
 char *get_safe_str_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t 
off);
-int get_safe_SVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, 
int failval);
-int get_safe_IVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, 
int failval);
 bool split_domain_user(TALLOC_CTX *mem_ctx,
                       const char *full_name,
                       char **domain,
diff --git a/source3/include/util_tdb.h b/source3/include/util_tdb.h
index d4efb0c31aa..ff50918ddf8 100644
--- a/source3/include/util_tdb.h
+++ b/source3/include/util_tdb.h
@@ -41,6 +41,7 @@ NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err);
 int tdb_data_cmp(TDB_DATA t1, TDB_DATA t2);
 
 char *tdb_data_string(TALLOC_CTX *mem_ctx, TDB_DATA d);
+char *tdb_data_dbg(TDB_DATA d);
 
 /****************************************************************************
  Lock a chain, with timeout.
diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c
index 1ba8fceb6e0..3f8e9033ba5 100644
--- a/source3/lib/filename_util.c
+++ b/source3/lib/filename_util.c
@@ -337,7 +337,7 @@ bool is_ntfs_default_stream_smb_fname(const struct 
smb_filename *smb_fname)
  Filter out Windows invalid EA names (list probed from Windows 2012).
 ****************************************************************************/
 
-static char bad_ea_name_chars[] = "\"*+,/:;<=>?[\\]|";
+static const char bad_ea_name_chars[] = "\"*+,/:;<=>?[\\]|";
 
 bool is_invalid_windows_ea_name(const char *name)
 {
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 3c27a63d8d5..d3f049d43bb 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -1469,9 +1469,7 @@ static void g_lock_writev_data_fn(
        ok = g_lock_parse(value.dptr, value.dsize, &lck);
        if (!ok) {
                DBG_DEBUG("g_lock_parse for %s failed\n",
-                         hex_encode_talloc(talloc_tos(),
-                                           state->key.dptr,
-                                           state->key.dsize));
+                         tdb_data_dbg(state->key));
                state->status = NT_STATUS_INTERNAL_DB_CORRUPTION;
                return;
        }
@@ -1604,9 +1602,7 @@ static void g_lock_dump_fn(TDB_DATA key, TDB_DATA data,
        ok = g_lock_parse(data.dptr, data.dsize, &lck);
        if (!ok) {
                DBG_DEBUG("g_lock_parse failed for %s\n",
-                         hex_encode_talloc(talloc_tos(),
-                                           state->key.dptr,
-                                           state->key.dsize));
+                         tdb_data_dbg(state->key));
                state->status = NT_STATUS_INTERNAL_DB_CORRUPTION;
                return;
        }
diff --git a/source3/lib/util.c b/source3/lib/util.c
index eef76662f45..83707b31e38 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1235,13 +1235,6 @@ bool remote_arch_cache_delete(const struct GUID 
*client_guid)
        return true;
 }
 
-const char *tab_depth(int level, int depth)
-{
-       if( CHECK_DEBUGLVL(level) ) {
-               dbgtext("%*s", depth*4, "");
-       }
-       return "";
-}
 
 /*****************************************************************************
  Provide a checksum on a string
@@ -1586,27 +1579,6 @@ bool name_to_fqdn(fstring fqdn, const char *name)
        return true;
 }
 
-uint32_t map_share_mode_to_deny_mode(uint32_t share_access, uint32_t 
private_options)
-{
-       switch (share_access & ~FILE_SHARE_DELETE) {
-               case FILE_SHARE_NONE:
-                       return DENY_ALL;
-               case FILE_SHARE_READ:
-                       return DENY_WRITE;
-               case FILE_SHARE_WRITE:
-                       return DENY_READ;
-               case FILE_SHARE_READ|FILE_SHARE_WRITE:
-                       return DENY_NONE;
-       }
-       if (private_options & NTCREATEX_FLAG_DENY_DOS) {
-               return DENY_DOS;
-       } else if (private_options & NTCREATEX_FLAG_DENY_FCB) {
-               return DENY_FCB;
-       }
-
-       return (uint32_t)-1;
-}
-
 struct server_id interpret_pid(const char *pid_string)
 {
        return server_id_from_string(get_my_vnn(), pid_string);
@@ -1637,16 +1609,6 @@ bool is_offset_safe(const char *buf_base, size_t 
buf_len, char *ptr, size_t off)
        return False;
 }
 
-/****************************************************************
- Return a safe pointer into a buffer, or NULL.
-****************************************************************/
-
-char *get_safe_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off)
-{
-       return is_offset_safe(buf_base, buf_len, ptr, off) ?
-                       ptr + off : NULL;
-}
-
 /****************************************************************
  Return a safe pointer into a string within a buffer, or NULL.
 ****************************************************************/
@@ -1663,37 +1625,6 @@ char *get_safe_str_ptr(const char *buf_base, size_t 
buf_len, char *ptr, size_t o
        return ptr + off;
 }
 
-/****************************************************************
- Return an SVAL at a pointer, or failval if beyond the end.
-****************************************************************/
-
-int get_safe_SVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, 
int failval)
-{
-       /*
-        * Note we use off+1 here, not off+2 as SVAL accesses ptr[0] and ptr[1],
-        * NOT ptr[2].
-        */
-       if (!is_offset_safe(buf_base, buf_len, ptr, off+1)) {
-               return failval;
-       }
-       return SVAL(ptr,off);
-}
-
-/****************************************************************
- Return an IVAL at a pointer, or failval if beyond the end.
-****************************************************************/
-
-int get_safe_IVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, 
int failval)
-{
-       /*
-        * Note we use off+3 here, not off+4 as IVAL accesses
-        * ptr[0] ptr[1] ptr[2] ptr[3] NOT ptr[4].
-        */
-       if (!is_offset_safe(buf_base, buf_len, ptr, off+3)) {
-               return failval;
-       }
-       return IVAL(ptr,off);
-}
 
 /****************************************************************
  Split DOM\user into DOM and user. Do not mix with winbind variants of that
diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c
index 943847f04a3..d85f676fbcf 100644
--- a/source3/lib/util_tdb.c
+++ b/source3/lib/util_tdb.c
@@ -365,6 +365,11 @@ done:
        return ret;
 }
 
+char *tdb_data_dbg(TDB_DATA d)
+{
+       return hex_encode_talloc(talloc_tos(), d.dptr, d.dsize);
+}
+
 static sig_atomic_t gotalarm;
 
 /***************************************************************
diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c
index 283c2aa12d2..9a5ca567ca9 100644
--- a/source3/libads/kerberos.c
+++ b/source3/libads/kerberos.c
@@ -789,9 +789,9 @@ bool create_local_private_krb5_conf_for_domain(const char 
*realm,
        fd = mkstemp(tmpname);
        umask(mask);
        if (fd == -1) {
-               DEBUG(0,("create_local_private_krb5_conf_for_domain: 
smb_mkstemp failed,"
-                       " for file %s. Errno %s\n",
-                       tmpname, strerror(errno) ));
+               DBG_ERR("mkstemp failed, for file %s. Errno %s\n",
+                       tmpname,
+                       strerror(errno));
                goto done;
        }
 
diff --git a/source3/librpc/idl/smbXsrv.idl b/source3/librpc/idl/smbXsrv.idl
index ec65a5c1a61..e0a751f32de 100644
--- a/source3/librpc/idl/smbXsrv.idl
+++ b/source3/librpc/idl/smbXsrv.idl
@@ -514,7 +514,6 @@ interface smbXsrv
         */
        typedef struct {
                [ignore] smbXsrv_open_table             *table;
-               [ignore] db_record                      *db_rec;
                uint32                                  local_id;
                [ref] smbXsrv_open_global0              *global;
                NTSTATUS                                status;
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 734c24531d9..5852f9177fd 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -43,6 +43,7 @@
 #include "ntioctl.h"
 #include "librpc/gen_ndr/ndr_quota.h"
 #include "lib/util/string_wrappers.h"
+#include "lib/util/idtree.h"
 
 struct smb2_hnd {
        uint64_t fid_persistent;
diff --git a/source3/locking/share_mode_lock.c 
b/source3/locking/share_mode_lock.c
index e123084677d..09a02853511 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -775,7 +775,7 @@ static bool share_mode_g_lock_within_cb(TDB_DATA key)
                DBG_ERR("Can not lock two share modes "
                        "simultaneously: existing %s requested %s\n",
                        file_id_str_buf(share_mode_lock_key_id, &existing),
-                       hex_encode_talloc(talloc_tos(), key.dptr, key.dsize));
+                       tdb_data_dbg(key));
                smb_panic(__location__);
                return false;
        }
diff --git a/source3/registry/reg_parse_prs.c b/source3/registry/reg_parse_prs.c
index feec7cb2e48..b608a8d9fdc 100644
--- a/source3/registry/reg_parse_prs.c
+++ b/source3/registry/reg_parse_prs.c
@@ -27,6 +27,14 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_PARSE
 
+static const char *tab_depth(int level, int depth)
+{
+       if( CHECK_DEBUGLVL(level) ) {
+               dbgtext("%*s", depth*4, "");
+       }
+       return "";
+}
+
 /*******************************************************************
  Debug output for parsing info
 
diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c
index 32fbb78f5ff..06fb6bb4472 100644
--- a/source3/rpc_server/rpc_server.c
+++ b/source3/rpc_server/rpc_server.c
@@ -33,6 +33,7 @@
 #include "auth.h"
 #include "rpc_server/rpc_ncacn_np.h"
 #include "rpc_server/srv_pipe_hnd.h"
+#include "lib/util/idtree_random.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
@@ -161,6 +162,7 @@ static NTSTATUS dcesrv_assoc_group_new(struct 
dcesrv_call_state *call)
 
        id = idr_get_new_random(dce_ctx->assoc_groups_idr,
                                assoc_group,
+                               1,
                                UINT16_MAX);
        if (id == -1) {
                TALLOC_FREE(assoc_group);
diff --git a/source3/rpc_server/rpc_worker.c b/source3/rpc_server/rpc_worker.c
index 2d2bb35af0f..1bc84531e55 100644
--- a/source3/rpc_server/rpc_worker.c
+++ b/source3/rpc_server/rpc_worker.c
@@ -654,7 +654,7 @@ static struct dcesrv_assoc_group 
*rpc_worker_assoc_group_new(
        }
 
        id = idr_get_new_random(
-               dce_ctx->assoc_groups_idr, assoc_group, UINT16_MAX);
+               dce_ctx->assoc_groups_idr, assoc_group, 1, UINT16_MAX);
        if (id == -1) {
                talloc_free(assoc_group);
                DBG_WARNING("Out of association groups!\n");
diff --git a/source3/smbd/smb1_lanman.c b/source3/smbd/smb1_lanman.c
index eb8148753b9..65711078c89 100644
--- a/source3/smbd/smb1_lanman.c
+++ b/source3/smbd/smb1_lanman.c
@@ -187,6 +187,62 @@ static int StrlenExpanded(connection_struct *conn, int 
snum, char *s)
        return strlen(buf) + 1;
 }
 
+/****************************************************************
+ Return an SVAL at a pointer, or failval if beyond the end.
+****************************************************************/
+
+static int get_safe_SVAL(
+       const char *buf_base,
+       size_t buf_len,
+       char *ptr,
+       size_t off,
+       int failval)
+{
+       /*
+        * Note we use off+1 here, not off+2 as SVAL accesses ptr[0]
+        * and ptr[1], NOT ptr[2].
+        */
+       if (!is_offset_safe(buf_base, buf_len, ptr, off+1)) {
+               return failval;
+       }
+       return SVAL(ptr,off);
+}
+
+/****************************************************************
+ Return an IVAL at a pointer, or failval if beyond the end.
+****************************************************************/
+
+static int get_safe_IVAL(


-- 
Samba Shared Repository

Reply via email to