[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Jan 8 21:39:02 UTC 2021


The branch, master has been updated
       via  564b62a6f7c vfs_fruit: fix close for fake_fd
       via  c5da0842299 vfs_fruit: check fake_fd in fruit_pread_meta_stream()
       via  36eb30fd7d4 vfs_fruit: use "fake_fd" instead of "created"
       via  40e70cbd3c3 vfs_streams_xattr: make use of vfs_fake_fd_close()
       via  719c83b4dc4 vfs_fruit: make use of vfs_fake_fd_close()
       via  8f057333466 s3:smbd: add vfs_fake_fd_close() helper
       via  f9b2559c420 s4:torture/fruit: avoid sleep(10000000); if write_stream() fails
       via  21853468b8d s3: Remove "developer.c" module
       via  8323c834732 passdb: Fix a typo
       via  56737df462d lib: Initialize pointers in server_prefork.c
       via  ef7afeb3a3e lib: Fix error path memleaks in prefork_create_pool()
       via  7ed99ad1cdb rpc_server: Make default prefork configs const
       via  e7a6dba21ce lib: Make pfh_daemon_config take a const default config
       via  de9b7312f1d librpc: Fix an error path memleak
       via  d82acf7685f lib: give global_contexts.c its own header file
       via  d0eaa143251 libsmb: Use hex_byte() in urldecode_talloc()
       via  6aa672a41c3 ctdb: Use hex_byte() in hex_to_data()
       via  41e1b340265 lib: Use hex_byte() in ucs2hex_pull()
       via  2ba7fe10951 lib: Use hex_byte() in rfc1738_unescape()
       via  b6a57c49c00 ldb: Use hex_byte() in ldb_binary_decode()
       via  fd056127944 tdb: Use hex_byte() in parse_hex()
       via  ad081bf2ddb tdb: Use hex_byte() in read_data()
       via  c8d9ce3f7c8 lib: Add "hex_byte()" to replace.h
       via  dad4410c86c dsdb: Fix a typo
       via  768917f6f8c dsdb: Fix comment wording
       via  fbe6c6cd11f auth: Fix a typo
       via  04077435dcc auth: Reformat a comment
      from  2f21d1b0ac8 vfs_virusfilter: Allocate separate memory for config char*

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


- Log -----------------------------------------------------------------
commit 564b62a6f7c0a9b9712946d723118122b9c3785f
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Dec 11 12:59:28 2020 +0100

    vfs_fruit: fix close for fake_fd
    
    If the next backend doesn't use kernel fd's should not
    pass a fake_fd to the next backend.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Jan  8 21:38:18 UTC 2021 on sn-devel-184

commit c5da08422990dfc1e082bc01aa10d6e415eebe3f
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Dec 11 13:00:56 2020 +0100

    vfs_fruit: check fake_fd in fruit_pread_meta_stream()
    
    Don't call into the next VFS backend if we know we still have a fake-fd. Just
    return -1 and the caller has the logic to handle this, which results in
    returning a AFP_AfpInfo blob initialized with some defaults.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 36eb30fd7d4b82bffd0e1ab471c088f678d700a4
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Dec 11 13:00:09 2020 +0100

    vfs_fruit: use "fake_fd" instead of "created"
    
    Both have basically the same semantics.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 40e70cbd3c3a1df9205a7b18d07784c1754cc340
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Dec 18 14:36:00 2020 +0100

    vfs_streams_xattr: make use of vfs_fake_fd_close()
    
    When we used vfs_fake_fd() we should use vfs_fake_fd_close()
    in order to have things symetric.
    
    That may allows us to change vfs_fake_fd() internally if required.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 719c83b4dc4cef16429ec2803621039545f6885e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Dec 18 14:36:00 2020 +0100

    vfs_fruit: make use of vfs_fake_fd_close()
    
    When we used vfs_fake_fd() we should use vfs_fake_fd_close()
    in order to have things symetric.
    
    That may allows us to change vfs_fake_fd() internally if required.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8f057333466b2d9845cd8bc2b794d98252ade2a4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Dec 18 14:03:09 2020 +0100

    s3:smbd: add vfs_fake_fd_close() helper
    
    When we used vfs_fake_fd() we should use vfs_fake_fd_close()
    in order to have things symetric.
    
    This makes code easier to understand and may allow us to change
    vfs_fake_fd() internally if required.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f9b2559c4208d680d43fa39823b2d5eb048bcf19
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Dec 8 15:47:53 2020 +0100

    s4:torture/fruit: avoid sleep(10000000); if write_stream() fails
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 21853468b8d20dca1fdde6accaa5a9c0e72e0438
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 4 12:22:13 2021 +0100

    s3: Remove "developer.c" module
    
    This can't have been built since commit f9acf770e9c12 from 2011 when
    smb_register_charset was removed.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8323c83473238c398d82c97bd08ba5c2936c251b
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 27 11:38:45 2020 +0100

    passdb: Fix a typo
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 56737df462d70397b436e3b91f1b643f5854adf1
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 27 08:50:34 2020 +0100

    lib: Initialize pointers in server_prefork.c
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ef7afeb3a3ece53c325773c1e05fba1897875cfa
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Dec 26 18:22:23 2020 +0100

    lib: Fix error path memleaks in prefork_create_pool()
    
    A few return statements missed the "TALLOC_FREE(pfp);"
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7ed99ad1cdbf6ad98b1b97ca15811add55efd1cf
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Dec 26 10:04:42 2020 +0100

    rpc_server: Make default prefork configs const
    
    Move 24 bytes from modifyable data to .text segment
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e7a6dba21ce345195bb80810d6c3de28ed043947
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Dec 26 09:59:04 2020 +0100

    lib: Make pfh_daemon_config take a const default config
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit de9b7312f1d4ba610817ec5189ff48b63e93df95
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Dec 26 09:27:10 2020 +0100

    librpc: Fix an error path memleak
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d82acf7685fe0b02013794263df61c479162dd92
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jan 3 21:53:49 2021 +0100

    lib: give global_contexts.c its own header file
    
    It's a bit shocking how many references we have to global
    contexts. Make this a bit more obvious.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d0eaa1432513575264d1b08574c8dcd51dae5e6a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 4 14:16:32 2021 +0100

    libsmb: Use hex_byte() in urldecode_talloc()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6aa672a41c37c94afd86e4801b9c1319db0cc6f3
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 4 14:10:57 2021 +0100

    ctdb: Use hex_byte() in hex_to_data()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 41e1b340265d902b86a757cc5baea0bdc4aba748
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 4 14:03:28 2021 +0100

    lib: Use hex_byte() in ucs2hex_pull()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2ba7fe10951ddda3145316e6026ef470ad2e29d5
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 4 13:57:53 2021 +0100

    lib: Use hex_byte() in rfc1738_unescape()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b6a57c49c00a778f954aaf10db6ebe6dca8f5ae2
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 4 13:55:01 2021 +0100

    ldb: Use hex_byte() in ldb_binary_decode()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fd056127944182bf1fa96d025a4418d9c05d1982
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 4 13:52:48 2021 +0100

    tdb: Use hex_byte() in parse_hex()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ad081bf2ddb60dfd5b8f838741e9de0710598b6a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 4 13:50:23 2021 +0100

    tdb: Use hex_byte() in read_data()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c8d9ce3f7c8c486ab21e320a0adcb71311dcb453
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 4 13:12:30 2021 +0100

    lib: Add "hex_byte()" to replace.h
    
    This is required in quite a few places, and replace.h has things like
    ZERO_STRUCT already, so this is not completely outplaced.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dad4410c86c2a2988cdc301693d6be3ee9cf6253
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jan 5 15:41:45 2021 +0100

    dsdb: Fix a typo
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 768917f6f8c4a387cd527fdbf306790ea4cf0e9a
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jan 5 14:42:40 2021 +0100

    dsdb: Fix comment wording
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fbe6c6cd11f0b0e078697aa23f43a38f75d82ec5
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jan 5 14:36:45 2021 +0100

    auth: Fix a typo
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 04077435dcc5ee35ed4ace76a421dac370f8d0ae
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jan 5 14:36:23 2021 +0100

    auth: Reformat a comment
    
    Will fix a typo next
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 ctdb/tools/ctdb.c                                  |  17 +--
 lib/ldb/common/ldb_parse.c                         |  27 +----
 lib/replace/replace.h                              |  16 +++
 lib/tdb/tools/tdbrestore.c                         |  41 ++-----
 lib/tdb/tools/tdbtool.c                            |  24 +---
 lib/util/charset/iconv.c                           |  15 ++-
 lib/util/rfc1738.c                                 |  14 +--
 librpc/rpc/dcesrv_core.c                           |   5 +-
 source3/auth/auth.c                                |   1 +
 source3/auth/auth_samba4.c                         |   1 +
 source3/include/proto.h                            |   6 -
 source3/lib/cmdline_contexts.c                     |   1 +
 source3/lib/dbwrap/dbwrap_open.c                   |   2 +-
 source3/lib/global_contexts.c                      |   7 +-
 .../smb2_lock.h => source3/lib/global_contexts.h   |  21 ++--
 source3/lib/server_prefork.c                       |  55 ++++-----
 source3/lib/server_prefork_util.c                  |   2 +-
 source3/lib/server_prefork_util.h                  |   2 +-
 source3/libsmb/libsmb_path.c                       |  49 +++-----
 source3/locking/share_mode_lock.c                  |   1 +
 source3/modules/developer.c                        | 133 ---------------------
 source3/modules/vfs_aio_fork.c                     |   1 +
 source3/modules/vfs_delay_inject.c                 |   1 +
 source3/modules/vfs_fruit.c                        |  32 ++---
 source3/modules/vfs_preopen.c                      |   1 +
 source3/modules/vfs_streams_xattr.c                |   4 +-
 source3/nmbd/nmbd.c                                |   1 +
 source3/passdb/passdb.c                            |   2 +-
 source3/passdb/pdb_interface.c                     |   1 +
 source3/printing/nt_printing.c                     |   1 +
 source3/printing/printing.c                        |   1 +
 source3/printing/queue_process.c                   |   1 +
 source3/printing/spoolssd.c                        |   3 +-
 source3/rpc_server/eventlog/srv_eventlog_nt.c      |   1 +
 source3/rpc_server/fss/srv_fss_agent.c             |   1 +
 source3/rpc_server/lsasd.c                         |   3 +-
 source3/rpc_server/mdssd.c                         |   3 +-
 source3/rpc_server/mdssvc/mdssvc.c                 |   1 +
 source3/rpc_server/mdssvc/srv_mdssvc_nt.c          |   1 +
 source3/rpc_server/rpc_config.c                    |   1 +
 source3/rpc_server/samr/srv_samr_nt.c              |   1 +
 source3/rpc_server/spoolss/srv_spoolss_nt.c        |   1 +
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c          |   1 +
 source3/rpc_server/svcctl/srv_svcctl_nt.c          |   1 +
 source3/smbd/msdfs.c                               |   1 +
 source3/smbd/proto.h                               |   1 +
 source3/smbd/server.c                              |   1 +
 source3/smbd/server_exit.c                         |   1 +
 source3/smbd/smbXsrv_session.c                     |   1 +
 source3/smbd/vfs.c                                 |   9 ++
 source3/torture/test_dbwrap_ctdb.c                 |   1 +
 source3/torture/test_dbwrap_do_locked.c            |   1 +
 source3/torture/test_g_lock.c                      |   1 +
 source3/torture/vfstest.c                          |   1 +
 source3/utils/net_vfs.c                            |   1 +
 source3/utils/smbcontrol.c                         |   1 +
 source3/winbindd/idmap_ldap.c                      |   1 +
 source3/winbindd/idmap_rfc2307.c                   |   1 +
 source3/winbindd/winbindd.c                        |   1 +
 source3/winbindd/winbindd_cm.c                     |   1 +
 source3/winbindd/winbindd_cred_cache.c             |   1 +
 source3/winbindd/winbindd_domain_info.c            |   1 +
 source3/winbindd/winbindd_dual.c                   |   1 +
 source3/winbindd/winbindd_dual_srv.c               |   1 +
 source3/winbindd/winbindd_gpupdate.c               |   1 +
 source3/winbindd/winbindd_idmap.c                  |   1 +
 source3/winbindd/winbindd_irpc.c                   |   1 +
 source3/winbindd/winbindd_pam.c                    |   1 +
 source3/winbindd/winbindd_pam_auth.c               |   1 +
 source3/winbindd/winbindd_pam_auth_crap.c          |   1 +
 source3/winbindd/winbindd_pam_chauthtok.c          |   1 +
 .../winbindd/winbindd_pam_chng_pswd_auth_crap.c    |   1 +
 source3/winbindd/winbindd_pam_logoff.c             |   1 +
 source3/winbindd/winbindd_util.c                   |   1 +
 source4/auth/ntlm/auth.c                           |   9 +-
 source4/dsdb/samdb/ldb_modules/extended_dn_in.c    |   2 +-
 source4/dsdb/samdb/ldb_modules/operational.c       |   2 +-
 source4/torture/vfs/fruit.c                        |   5 +-
 78 files changed, 209 insertions(+), 351 deletions(-)
 copy libcli/smb/smb2_lock.h => source3/lib/global_contexts.h (68%)
 delete mode 100644 source3/modules/developer.c


Changeset truncated at 500 lines:

diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index e21d2d4b562..598ab4ff4b7 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -591,17 +591,6 @@ static bool db_exists(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
 	return true;
 }
 
-static int h2i(char h)
-{
-	if (h >= 'a' && h <= 'f') {
-		return h - 'a' + 10;
-	}
-	if (h >= 'A' && h <= 'F') {
-		return h - 'A' + 10;
-	}
-	return h - '0';
-}
-
 static int hex_to_data(const char *str, size_t len, TALLOC_CTX *mem_ctx,
 		       TDB_DATA *out)
 {
@@ -621,7 +610,11 @@ static int hex_to_data(const char *str, size_t len, TALLOC_CTX *mem_ctx,
 	}
 
 	for (i=0; i<data.dsize; i++) {
-		data.dptr[i] = h2i(str[i*2]) << 4 | h2i(str[i*2+1]);
+		bool ok = hex_byte(&str[i*2], &data.dptr[i]);
+		if (!ok) {
+			fprintf(stderr, "Invalid hex: %s\n", &str[i*2]);
+			return EINVAL;
+		}
 	}
 
 	*out = data;
diff --git a/lib/ldb/common/ldb_parse.c b/lib/ldb/common/ldb_parse.c
index 7e15206b168..f0045ad2093 100644
--- a/lib/ldb/common/ldb_parse.c
+++ b/lib/ldb/common/ldb_parse.c
@@ -53,26 +53,6 @@
  */
 #define LDB_MAX_PARSE_TREE_DEPTH 128
 
-static int ldb_parse_hex2char(const char *x)
-{
-	if (isxdigit(x[0]) && isxdigit(x[1])) {
-		const char h1 = x[0], h2 = x[1];
-		int c = 0;
-
-		if (h1 >= 'a') c = h1 - (int)'a' + 10;
-		else if (h1 >= 'A') c = h1 - (int)'A' + 10;
-		else if (h1 >= '0') c = h1 - (int)'0';
-		c = c << 4;
-		if (h2 >= 'a') c += h2 - (int)'a' + 10;
-		else if (h2 >= 'A') c += h2 - (int)'A' + 10;
-		else if (h2 >= '0') c += h2 - (int)'0';
-
-		return c;
-	}
-
-	return -1;
-}
-
 /*
 a filter is defined by:
                <filter> ::= '(' <filtercomp> ')'
@@ -101,10 +81,11 @@ struct ldb_val ldb_binary_decode(TALLOC_CTX *mem_ctx, const char *str)
 
 	for (i=j=0;i<slen;i++) {
 		if (str[i] == '\\') {
-			int c;
+			uint8_t c;
+			bool ok;
 
-			c = ldb_parse_hex2char(&str[i+1]);
-			if (c == -1) {
+			ok = hex_byte(&str[i+1], &c);
+			if (!ok) {
 				talloc_free(ret.data);
 				memset(&ret, 0, sizeof(ret));
 				return ret;
diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index f7f6b653869..e08bf7c2e58 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -977,6 +977,22 @@ bool nss_wrapper_hosts_enabled(void);
 bool socket_wrapper_enabled(void);
 bool uid_wrapper_enabled(void);
 
+static inline bool _hexcharval(char c, uint8_t *val)
+{
+	if ((c >= '0') && (c <= '9')) { *val = c - '0';      return true; }
+	if ((c >= 'a') && (c <= 'f')) {	*val = c - 'a' + 10; return true; }
+	if ((c >= 'A') && (c <= 'F')) { *val = c - 'A' + 10; return true; }
+	return false;
+}
+
+static inline bool hex_byte(const char *in, uint8_t *out)
+{
+	uint8_t hi=0, lo=0;
+	bool ok = _hexcharval(in[0], &hi) && _hexcharval(in[1], &lo);
+	*out = (hi<<4)+lo;
+	return ok;
+}
+
 /* Needed for Solaris atomic_add_XX functions. */
 #if defined(HAVE_SYS_ATOMIC_H)
 #include <sys/atomic.h>
diff --git a/lib/tdb/tools/tdbrestore.c b/lib/tdb/tools/tdbrestore.c
index 9d5146272cc..3312cf74d83 100644
--- a/lib/tdb/tools/tdbrestore.c
+++ b/lib/tdb/tools/tdbrestore.c
@@ -62,29 +62,7 @@ static int read_linehead(FILE *f)
 	return num_bytes;
 }
 
-static int read_hex(void) {
-	int c;
-	c = getchar();
-	if (c == EOF) {
-		fprintf(stderr, "Unexpected EOF in data\n");
-		return -1;
-	} else if (c == '"') {
-		fprintf(stderr, "Unexpected \\\" sequence\n");
-		return -1;
-	} else if ('0' <= c && c <= '9')  {
-		return c - '0';
-	} else if ('A' <= c && c <= 'F')  {
-		return c - 'A' + 10;
-	} else if ('a' <= c && c <= 'f')  {
-		return c - 'a' + 10;
-	} else {
-		fprintf(stderr, "Invalid hex: %c\n", c);
-		return -1;
-	}
-}
-
 static int read_data(FILE *f, TDB_DATA *d, size_t size) {
-	int c, low, high;
 	size_t i;
 
 	d->dptr = (unsigned char *)malloc(size);
@@ -94,25 +72,26 @@ static int read_data(FILE *f, TDB_DATA *d, size_t size) {
 	d->dsize = size;
 
 	for (i=0; i<size; i++) {
-		c = getc(f);
+		int c = getc(f);
 		if (c == EOF) {
 			fprintf(stderr, "Unexpected EOF in data\n");
 			return 1;
 		} else if (c == '"') {
 			return 0;
 		} else if (c == '\\') {
-			high = read_hex();
-			if (high < 0) {
+			char in[3] = {0};
+			size_t n;
+			bool ok;
+
+			n = fread(in, 1, 2, stdin);
+			if (n != 2) {
 				return -1;
 			}
-			high = high << 4;
-			assert(high == (high & 0xf0));
-			low = read_hex();
-			if (low < 0) {
+			ok = hex_byte(in, &d->dptr[i]);
+			if (!ok) {
+				fprintf(stderr, "Invalid hex: %s\n", in);
 				return -1;
 			}
-			assert(low == (low & 0x0f));
-			d->dptr[i] = (low|high);
 		} else {
 			d->dptr[i] = c;
 		}
diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c
index 36e480cd29c..fca28a16ba8 100644
--- a/lib/tdb/tools/tdbtool.c
+++ b/lib/tdb/tools/tdbtool.c
@@ -349,23 +349,6 @@ static void store_tdb(char *keyname, size_t keylen, char* data, size_t datalen)
 	}
 }
 
-static bool hexchar(char c, uint8_t *v)
-{
-	if ((c >= '0') && (c <= '9')) {
-		*v = (c - '0');
-		return true;
-	}
-	if ((c >= 'A') && (c <= 'F')) {
-		*v = (c - 'A' + 10);
-		return true;
-	}
-	if ((c >= 'a') && (c <= 'f')) {
-		*v = (c - 'a' + 10);
-		return true;
-	}
-	return false;
-}
-
 static bool parse_hex(const char *src, size_t srclen, uint8_t *dst)
 {
 	size_t i=0;
@@ -375,14 +358,11 @@ static bool parse_hex(const char *src, size_t srclen, uint8_t *dst)
 	}
 
 	while (i<srclen) {
-		bool ok;
-		uint8_t hi,lo;
-
-		ok = (hexchar(src[i++], &hi) && hexchar(src[i++], &lo));
+		bool ok = hex_byte(src, dst);
 		if (!ok) {
 			return false;
 		}
-		*dst = (hi<<4)|lo;
+		src += 2;
 		dst += 1;
 	}
 
diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c
index 14a1f8652e3..1f2d49c0e27 100644
--- a/lib/util/charset/iconv.c
+++ b/lib/util/charset/iconv.c
@@ -25,8 +25,6 @@
 #include "lib/util/dlinklist.h"
 #include "lib/util/charset/charset.h"
 #include "lib/util/charset/charset_proto.h"
-#include "libcli/util/ntstatus.h"
-#include "lib/util/util_str_hex.h"
 
 #ifdef HAVE_ICU_I18N
 #include <unicode/ustring.h>
@@ -675,8 +673,9 @@ static size_t ucs2hex_pull(void *cd, const char **inbuf, size_t *inbytesleft,
 			 char **outbuf, size_t *outbytesleft)
 {
 	while (*inbytesleft >= 1 && *outbytesleft >= 2) {
-		uint64_t v;
-		NTSTATUS status;
+		uint8_t hi = 0, lo = 0;
+		bool ok;
+
 		if ((*inbuf)[0] != '@') {
 			/* seven bit ascii case */
 			(*outbuf)[0] = (*inbuf)[0];
@@ -692,15 +691,15 @@ static size_t ucs2hex_pull(void *cd, const char **inbuf, size_t *inbytesleft,
 			errno = EINVAL;
 			return -1;
 		}
-		status = read_hex_bytes(&(*inbuf)[1], 4, &v);
 
-		if (!NT_STATUS_IS_OK(status)) {
+		ok = hex_byte(&(*inbuf)[1], &hi) && hex_byte(&(*inbuf)[3], &lo);
+		if (!ok) {
 			errno = EILSEQ;
 			return -1;
 		}
 
-		(*outbuf)[0] = v&0xff;
-		(*outbuf)[1] = v>>8;
+		(*outbuf)[0] = lo;
+		(*outbuf)[1] = hi;
 		(*inbytesleft)  -= 5;
 		(*outbytesleft) -= 2;
 		(*inbuf)  += 5;
diff --git a/lib/util/rfc1738.c b/lib/util/rfc1738.c
index a6c54ce61a9..82395446bc8 100644
--- a/lib/util/rfc1738.c
+++ b/lib/util/rfc1738.c
@@ -46,7 +46,6 @@
 #include "replace.h"
 #include <talloc.h>
 #include "lib/util/samba_util.h"
-#include "lib/util/util_str_hex.h"
 
 #define RFC1738_ENCODE 1
 #define RFC1738_RESERVED 2
@@ -179,16 +178,17 @@ rfc1738_escape_part(TALLOC_CTX *mem_ctx, const char *url)
 _PUBLIC_ char *rfc1738_unescape(char *s)
 {
 	size_t i, j;	    /* i is write, j is read */
-	uint64_t x;
-	NTSTATUS status;
 	for (i = 0, j = 0; s[j] != '\0'; i++, j++) {
 		if (s[j] == '%') {
-			status = read_hex_bytes(&s[j + 1], 2, &x);
-			if (! NT_STATUS_IS_OK(status)) {
+			uint8_t v;
+			bool ok;
+
+			ok = hex_byte(&s[j+1], &v);
+			if (!ok) {
 				return NULL;
 			}
-			j += 2; /* OK; read_hex_bytes() has checked ahead */
-			s[i] = (unsigned char)x;
+			j += 2; /* OK; hex_byte() has checked ahead */
+			s[i] = (unsigned char)v;
 		} else {
 			s[i] = s[j];
 		}
diff --git a/librpc/rpc/dcesrv_core.c b/librpc/rpc/dcesrv_core.c
index 064ad38b8d6..9113bf89976 100644
--- a/librpc/rpc/dcesrv_core.c
+++ b/librpc/rpc/dcesrv_core.c
@@ -2341,7 +2341,10 @@ _PUBLIC_ NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx,
 	dce_ctx->endpoint_list	= NULL;
 	dce_ctx->lp_ctx = lp_ctx;
 	dce_ctx->assoc_groups_idr = idr_init(dce_ctx);
-	NT_STATUS_HAVE_NO_MEMORY(dce_ctx->assoc_groups_idr);
+	if (dce_ctx->assoc_groups_idr == NULL) {
+		TALLOC_FREE(dce_ctx);
+		return NT_STATUS_NO_MEMORY;
+	}
 	dce_ctx->broken_connections = NULL;
 	if (cb != NULL) {
 		dce_ctx->callbacks = *cb;
diff --git a/source3/auth/auth.c b/source3/auth/auth.c
index e8bb9d7821a..fa73c4e4db2 100644
--- a/source3/auth/auth.c
+++ b/source3/auth/auth.c
@@ -23,6 +23,7 @@
 
 #include "param/param.h"
 #include "../lib/messaging/messaging.h"
+#include "lib/global_contexts.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_AUTH
diff --git a/source3/auth/auth_samba4.c b/source3/auth/auth_samba4.c
index 6dee9c6f411..0a7c67be232 100644
--- a/source3/auth/auth_samba4.c
+++ b/source3/auth/auth_samba4.c
@@ -28,6 +28,7 @@
 #include "source4/lib/messaging/messaging.h"
 #include "auth/gensec/gensec.h"
 #include "auth/credentials/credentials.h"
+#include "lib/global_contexts.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_AUTH
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 6e14ac42777..2f25778ab9f 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -708,12 +708,6 @@ NTSTATUS trust_pw_change(struct netlogon_creds_cli_context *context,
 			 const char *dcname,
 			 bool force);
 
-/* The following definitions come from lib/server_contexts.c  */
-struct tevent_context *global_event_context(void);
-void global_event_context_free(void);
-struct messaging_context *global_messaging_context(void);
-void global_messaging_context_free(void);
-
 /* The following definitions come from lib/sessionid_tdb.c  */
 struct sessionid;
 NTSTATUS sessionid_traverse_read(int (*fn)(const char *key,
diff --git a/source3/lib/cmdline_contexts.c b/source3/lib/cmdline_contexts.c
index 2bee7f38059..627ee4f3164 100644
--- a/source3/lib/cmdline_contexts.c
+++ b/source3/lib/cmdline_contexts.c
@@ -21,6 +21,7 @@
 #include "cmdline_contexts.h"
 #include "includes.h"
 #include "messages.h"
+#include "lib/global_contexts.h"
 
 struct messaging_context *cmdline_messaging_context(const char *config_file)
 {
diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
index e67341607a4..1d8c40af75e 100644
--- a/source3/lib/dbwrap/dbwrap_open.c
+++ b/source3/lib/dbwrap/dbwrap_open.c
@@ -29,7 +29,7 @@
 #include "lib/messages_ctdb.h"
 #include "util_tdb.h"
 #include "ctdbd_conn.h"
-#include "messages.h"
+#include "global_contexts.h"
 
 bool db_is_local(const char *name)
 {
diff --git a/source3/lib/global_contexts.c b/source3/lib/global_contexts.c
index 03ab8e4fd48..4e3bbabfffe 100644
--- a/source3/lib/global_contexts.c
+++ b/source3/lib/global_contexts.c
@@ -18,7 +18,12 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+
+#include "replace.h"
+#include "global_contexts.h"
+#include <tevent.h>
+#include "lib/util/fault.h"
+#include "lib/util/samba_util.h"
 #include "messages.h"
 
 static struct tevent_context *global_event_ctx = NULL;
diff --git a/libcli/smb/smb2_lock.h b/source3/lib/global_contexts.h
similarity index 68%
copy from libcli/smb/smb2_lock.h
copy to source3/lib/global_contexts.h
index f0e05355232..8c5cd096a45 100644
--- a/libcli/smb/smb2_lock.h
+++ b/source3/lib/global_contexts.h
@@ -1,7 +1,6 @@
 /*
  * Unix SMB/CIFS implementation.
- *
- * Copyright (C) Volker Lendecke 2019
+ * Global contexts
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,16 +16,16 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __LIBCLI_SMB_SMB2_LOCK_H__
-#define __LIBCLI_SMB_SMB2_LOCK_H__
+#ifndef __GLOBAL_CONTEXTS_H__
+#define __GLOBAL_CONTEXTS_H__
+
+struct tevent_context;
 
-#include "replace.h"
+struct tevent_context *global_event_context(void);
+void global_event_context_free(void);
 
-struct smb2_lock_element {
-	uint64_t offset;
-	uint64_t length;
-	uint32_t flags;
-	uint32_t reserved;
-};
+struct messaging_context;
+struct messaging_context *global_messaging_context(void);
+void global_messaging_context_free(void);
 
 #endif
diff --git a/source3/lib/server_prefork.c b/source3/lib/server_prefork.c
index d0cea7c30c0..344bff0efa2 100644
--- a/source3/lib/server_prefork.c
+++ b/source3/lib/server_prefork.c
@@ -61,7 +61,7 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx,
 			 prefork_main_fn_t *main_fn, void *private_data,
 			 struct prefork_pool **pf_pool)
 {
-	struct prefork_pool *pfp;
+	struct prefork_pool *pfp = NULL;
 	pid_t pid;
 	time_t now = time(NULL);
 	size_t data_size;
@@ -72,14 +72,14 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx,
 	pfp = talloc_zero(mem_ctx, struct prefork_pool);
 	if (!pfp) {
 		DEBUG(1, ("Out of memory!\n"));
-		return false;
+		goto fail;
 	}
 	pfp->listen_fd_size = listen_fd_size;
 	pfp->listen_fds = talloc_array(pfp, struct pf_listen_fd,
 				       listen_fd_size);
 	if (!pfp->listen_fds) {
 		DEBUG(1, ("Out of memory!\n"));
-		return false;
+		goto fail;
 	}
 	for (i = 0; i < listen_fd_size; i++) {
 		pfp->listen_fds[i] = listen_fds[i];
@@ -87,7 +87,7 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx,
 		ret = set_blocking(listen_fds[i].fd, false);
 		if (ret < 0) {
 			DBG_WARNING("Failed to set sockets to non-blocking!\n");
-			return false;
+			goto fail;
 		}
 	}
 	pfp->main_fn = main_fn;
@@ -100,8 +100,7 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx,
 		data_size);
 	if (pfp->pool == NULL) {
 		DEBUG(1, ("Failed to mmap memory for prefork pool!\n"));
-		talloc_free(pfp);
-		return false;
+		goto fail;
 	}
 	talloc_set_destructor(pfp, prefork_pool_destructor);
 
@@ -135,12 +134,14 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx,
 	ok = prefork_setup_sigchld_handler(ev_ctx, pfp);
 	if (!ok) {
 		DEBUG(1, ("Failed to setup SIGCHLD Handler!\n"));
-		talloc_free(pfp);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list