[PATCH] From the attic

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] From the attic

Samba - samba-technical mailing list
Hi!

Some small cleanups from the attic.

Review appreciated!

Thanks, Volker

--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:[hidden email]

patch.txt (15K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] From the attic

Samba - samba-technical mailing list
On Mon, Nov 13, 2017 at 01:28:29PM +0100, Volker Lendecke via samba-technical wrote:
> Hi!
>
> Some small cleanups from the attic.
>
> Review appreciated!

LGTM. Pushed !

Jeremy.

> --
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
> http://www.sernet.de, mailto:[hidden email]

> From 25af6d06187284eef2a4c828d475639e1c000fea Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <[hidden email]>
> Date: Thu, 3 Aug 2017 17:03:26 +0200
> Subject: [PATCH 01/10] netsamlogon_cache: Use ndr_pull_struct_blob_all
>
> Be a bit more strict for error checking
>
> Signed-off-by: Volker Lendecke <[hidden email]>
> ---
>  source3/libsmb/samlogon_cache.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c
> index 0a2890e4231..70645f2dc40 100644
> --- a/source3/libsmb/samlogon_cache.c
> +++ b/source3/libsmb/samlogon_cache.c
> @@ -253,8 +253,9 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
>  
>   blob = data_blob_const(data.dptr, data.dsize);
>  
> - ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r,
> -      (ndr_pull_flags_fn_t)ndr_pull_netsamlogoncache_entry);
> + ndr_err = ndr_pull_struct_blob_all(
> + &blob, mem_ctx, &r,
> + (ndr_pull_flags_fn_t)ndr_pull_netsamlogoncache_entry);
>  
>   if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
>   DEBUG(0,("netsamlogon_cache_get: failed to pull entry from cache\n"));
> --
> 2.11.0
>
>
> From 7df607cc535ff26aa200f6c69b244d9fb5229fc4 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <[hidden email]>
> Date: Mon, 13 Nov 2017 08:53:04 +0100
> Subject: [PATCH 02/10] libcli: Fix a signed/unsigned hickup
>
> Signed-off-by: Volker Lendecke <[hidden email]>
> ---
>  libcli/security/util_sid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libcli/security/util_sid.c b/libcli/security/util_sid.c
> index 0709a7a69e3..50133a14075 100644
> --- a/libcli/security/util_sid.c
> +++ b/libcli/security/util_sid.c
> @@ -195,7 +195,7 @@ static const struct {
>  
>  const char *sid_type_lookup(uint32_t sid_type)
>  {
> - int i;
> + size_t i;
>  
>   /* Look through list */
>   for (i=0; i < ARRAY_SIZE(sid_name_type); i++) {
> --
> 2.11.0
>
>
> From 600109877b38ccede4b47c980b849602e9728762 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <[hidden email]>
> Date: Fri, 4 Aug 2017 14:47:17 +0200
> Subject: [PATCH 03/10] passdb: Fix a typo
>
> Signed-off-by: Volker Lendecke <[hidden email]>
> ---
>  source3/passdb/lookup_sid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
> index b06dd1b6f72..eeaf2b720a7 100644
> --- a/source3/passdb/lookup_sid.c
> +++ b/source3/passdb/lookup_sid.c
> @@ -178,7 +178,7 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
>  
>   /*
>   * Finally check for a well known domain name ("NT Authority"),
> - * this is taken care if in lookup_wellknown_name().
> + * this is being taken care of in lookup_wellknown_name().
>   */
>   if ((domain[0] != '\0') &&
>      (flags & LOOKUP_NAME_WKN) &&
> --
> 2.11.0
>
>
> From afe66baba6cd388f7a31208c821eb8dc6e0ff3f6 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <[hidden email]>
> Date: Thu, 3 Aug 2017 17:08:48 +0200
> Subject: [PATCH 04/10] util_tdb: Make a few functions static
>
> Signed-off-by: Volker Lendecke <[hidden email]>
> ---
>  lib/util/util_tdb.c | 11 +++++++----
>  lib/util/util_tdb.h | 24 ------------------------
>  2 files changed, 7 insertions(+), 28 deletions(-)
>
> diff --git a/lib/util/util_tdb.c b/lib/util/util_tdb.c
> index e3eefdac2b1..24fb6584899 100644
> --- a/lib/util/util_tdb.c
> +++ b/lib/util/util_tdb.c
> @@ -132,7 +132,7 @@ void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval)
>   Output is int32_t in native byte order.
>  ****************************************************************************/
>  
> -int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key)
> +static int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key)
>  {
>   TDB_DATA data;
>   int32_t ret;
> @@ -163,7 +163,8 @@ int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr)
>   Input is int32_t in native byte order. Output in tdb is in little-endian.
>  ****************************************************************************/
>  
> -int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v)
> +static int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key,
> +  int32_t v)
>  {
>   TDB_DATA data;
>   int32_t v_store;
> @@ -190,7 +191,8 @@ int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v)
>   Output is uint32_t in native byte order.
>  ****************************************************************************/
>  
> -bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t *value)
> +static bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key,
> +    uint32_t *value)
>  {
>   TDB_DATA data;
>  
> @@ -220,7 +222,8 @@ bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *val
>   Input is uint32_t in native byte order. Output in tdb is in little-endian.
>  ****************************************************************************/
>  
> -bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t value)
> +static bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key,
> +    uint32_t value)
>  {
>   TDB_DATA data;
>   uint32_t v_store;
> diff --git a/lib/util/util_tdb.h b/lib/util/util_tdb.h
> index 63d80d1fb58..de82660f6ea 100644
> --- a/lib/util/util_tdb.h
> +++ b/lib/util/util_tdb.h
> @@ -55,48 +55,24 @@ int tdb_read_lock_bystring(struct tdb_context *tdb, const char *keyval);
>  void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval);
>  
>  /****************************************************************************
> - Fetch a int32_t value by a arbitrary blob key, return -1 if not found.
> - Output is int32_t in native byte order.
> -****************************************************************************/
> -int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key);
> -
> -/****************************************************************************
>   Fetch a int32_t value by string key, return -1 if not found.
>   Output is int32_t in native byte order.
>  ****************************************************************************/
>  int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr);
>  
>  /****************************************************************************
> - Store a int32_t value by an arbitrary blob key, return 0 on success, -ve on failure.
> - Input is int32_t in native byte order. Output in tdb is in little-endian.
> -****************************************************************************/
> -int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v);
> -
> -/****************************************************************************
>   Store a int32_t value by string key, return 0 on success, -ve on failure.
>   Input is int32_t in native byte order. Output in tdb is in little-endian.
>  ****************************************************************************/
>  int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v);
>  
>  /****************************************************************************
> - Fetch a uint32_t value by a arbitrary blob key, return -1 if not found.
> - Output is uint32_t in native byte order.
> -****************************************************************************/
> -bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t *value);
> -
> -/****************************************************************************
>   Fetch a uint32_t value by string key, return -1 if not found.
>   Output is uint32_t in native byte order.
>  ****************************************************************************/
>  bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value);
>  
>  /****************************************************************************
> - Store a uint32_t value by an arbitrary blob key, return true on success, false on failure.
> - Input is uint32_t in native byte order. Output in tdb is in little-endian.
> -****************************************************************************/
> -bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t value);
> -
> -/****************************************************************************
>   Store a uint32_t value by string key, return true on success, false on failure.
>   Input is uint32_t in native byte order. Output in tdb is in little-endian.
>  ****************************************************************************/
> --
> 2.11.0
>
>
> From 4adf154324b44d8a853b5f9efc107ec2123fb63e Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <[hidden email]>
> Date: Fri, 4 Aug 2017 10:44:59 +0200
> Subject: [PATCH 05/10] smbd: Avoid an "else"
>
> We always return in the if-branch before. The else is redundant
>
> Signed-off-by: Volker Lendecke <[hidden email]>
> ---
>  source3/smbd/process.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/source3/smbd/process.c b/source3/smbd/process.c
> index b65ae2c1b1c..11a5ae8314c 100644
> --- a/source3/smbd/process.c
> +++ b/source3/smbd/process.c
> @@ -1973,7 +1973,8 @@ static void process_smb(struct smbXsrv_connection *xconn,
>   size_t pdulen = nread - NBT_HDR_SIZE;
>   smbd_smb2_process_negprot(xconn, 0, inpdu, pdulen);
>   return;
> - } else if (nread >= smb_size && valid_smb_header(inbuf)
> + }
> + if (nread >= smb_size && valid_smb_header(inbuf)
>   && CVAL(inbuf, smb_com) != 0x72) {
>   /* This is a non-negprot SMB1 packet.
>     Disable SMB2 from now on. */
> --
> 2.11.0
>
>
> From 1ea18ad646c135efd0f44b06fd78090fa4ec106e Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <[hidden email]>
> Date: Sun, 12 Nov 2017 14:48:24 +0100
> Subject: [PATCH 06/10] lib: Avoid a ZERO_STRUCT, save a few bytes .text
>
> Signed-off-by: Volker Lendecke <[hidden email]>
> ---
>  source3/libnet/libnet_dssync.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/source3/libnet/libnet_dssync.c b/source3/libnet/libnet_dssync.c
> index 267709e3c11..e593ae8536c 100644
> --- a/source3/libnet/libnet_dssync.c
> +++ b/source3/libnet/libnet_dssync.c
> @@ -337,7 +337,6 @@ static NTSTATUS libnet_dssync_build_request(TALLOC_CTX *mem_ctx,
>   uint32_t count;
>   uint32_t level;
>   union drsuapi_DsGetNCChangesRequest req;
> - struct dom_sid null_sid;
>   enum drsuapi_DsExtendedOperation extended_op;
>   struct drsuapi_DsReplicaObjectIdentifier *nc = NULL;
>   struct drsuapi_DsReplicaCursorCtrEx *cursors = NULL;
> @@ -348,7 +347,6 @@ static NTSTATUS libnet_dssync_build_request(TALLOC_CTX *mem_ctx,
>    DRSUAPI_DRS_GET_ANC |
>    DRSUAPI_DRS_NEVER_SYNCED;
>  
> - ZERO_STRUCT(null_sid);
>   ZERO_STRUCT(req);
>  
>   if (ctx->remote_info28.supported_extensions
> @@ -366,7 +364,7 @@ static NTSTATUS libnet_dssync_build_request(TALLOC_CTX *mem_ctx,
>   }
>   nc->dn = dn;
>   nc->guid = GUID_zero();
> - nc->sid = null_sid;
> + nc->sid = (struct dom_sid) {0};
>  
>   if (!ctx->single_object_replication &&
>      !ctx->force_full_replication && utdv)
> --
> 2.11.0
>
>
> From 666246f70707b1ab51f23b314e72f2a6a29f19dc Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <[hidden email]>
> Date: Sun, 12 Nov 2017 14:48:24 +0100
> Subject: [PATCH 07/10] rpcclient: Avoid a ZERO_STRUCT, save a few bytes .text
>
> Signed-off-by: Volker Lendecke <[hidden email]>
> ---
>  source3/rpcclient/cmd_drsuapi.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/source3/rpcclient/cmd_drsuapi.c b/source3/rpcclient/cmd_drsuapi.c
> index 6a1fac7bfad..b2221a713dd 100644
> --- a/source3/rpcclient/cmd_drsuapi.c
> +++ b/source3/rpcclient/cmd_drsuapi.c
> @@ -328,7 +328,6 @@ static WERROR cmd_drsuapi_getncchanges(struct rpc_pipe_client *cli,
>   union drsuapi_DsGetNCChangesRequest req;
>   union drsuapi_DsGetNCChangesCtr ctr;
>   struct drsuapi_DsReplicaObjectIdentifier nc;
> - struct dom_sid null_sid;
>  
>   struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL;
>   struct drsuapi_DsGetNCChangesCtr6 *ctr6 = NULL;
> @@ -362,7 +361,6 @@ static WERROR cmd_drsuapi_getncchanges(struct rpc_pipe_client *cli,
>  
>   ZERO_STRUCT(info28);
>  
> - ZERO_STRUCT(null_sid);
>   ZERO_STRUCT(req);
>  
>   GUID_from_string(DRSUAPI_DS_BIND_GUID, &bind_guid);
> @@ -463,7 +461,7 @@ static WERROR cmd_drsuapi_getncchanges(struct rpc_pipe_client *cli,
>  
>   nc.dn = nc_dn;
>   nc.guid = GUID_zero();
> - nc.sid = null_sid;
> + nc.sid = (struct dom_sid) {0};
>  
>   if (supported_extensions & DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8) {
>   level = 8;
> --
> 2.11.0
>
>
> From d3b036ca0fe02ea1ed4bee161237ec0b51326a94 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <[hidden email]>
> Date: Sun, 12 Nov 2017 14:55:40 +0100
> Subject: [PATCH 08/10] lib: Save a few bytes of .text
>
> Looks surprising, but this does save bytes if you look at the object with
> "size".
>
> Signed-off-by: Volker Lendecke <[hidden email]>
> ---
>  libcli/security/util_sid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libcli/security/util_sid.c b/libcli/security/util_sid.c
> index 50133a14075..e84cfb48265 100644
> --- a/libcli/security/util_sid.c
> +++ b/libcli/security/util_sid.c
> @@ -431,6 +431,6 @@ bool add_rid_to_array_unique(TALLOC_CTX *mem_ctx,
>  
>  bool is_null_sid(const struct dom_sid *sid)
>  {
> - static const struct dom_sid null_sid = {0};
> + const struct dom_sid null_sid = {0};
>   return dom_sid_equal(sid, &null_sid);
>  }
> --
> 2.11.0
>
>
> From 9f9bad08589a7ef183ba35ddee0dec9eb53170e8 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <[hidden email]>
> Date: Sun, 12 Nov 2017 16:07:48 +0100
> Subject: [PATCH 09/10] dreplsrv: Use is_null_sid
>
> Signed-off-by: Volker Lendecke <[hidden email]>
> ---
>  source4/dsdb/repl/drepl_partitions.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/source4/dsdb/repl/drepl_partitions.c b/source4/dsdb/repl/drepl_partitions.c
> index 586da1983dc..83ea3586415 100644
> --- a/source4/dsdb/repl/drepl_partitions.c
> +++ b/source4/dsdb/repl/drepl_partitions.c
> @@ -445,12 +445,10 @@ WERROR dreplsrv_partition_find_for_nc(struct dreplsrv_service *s,
>  {
>   struct dreplsrv_partition *p;
>   bool valid_sid, valid_guid;
> - struct dom_sid null_sid;
> - ZERO_STRUCT(null_sid);
>  
>   SMB_ASSERT(_p);
>  
> - valid_sid  = nc_sid && !dom_sid_equal(&null_sid, nc_sid);
> + valid_sid  = nc_sid && !is_null_sid(nc_sid);
>   valid_guid = nc_guid && !GUID_all_zero(nc_guid);
>  
>   if (!valid_sid && !valid_guid && (!nc_dn_str)) {
> --
> 2.11.0
>
>
> From 0fb33b4c51a99739d80f3fa5e68f7445cc01be62 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <[hidden email]>
> Date: Sun, 12 Nov 2017 16:09:35 +0100
> Subject: [PATCH 10/10] smbtorture: Remove an unused variable
>
> Signed-off-by: Volker Lendecke <[hidden email]>
> ---
>  source4/torture/drs/rpc/dssync.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/source4/torture/drs/rpc/dssync.c b/source4/torture/drs/rpc/dssync.c
> index 27cc72f5613..67fde7c2b61 100644
> --- a/source4/torture/drs/rpc/dssync.c
> +++ b/source4/torture/drs/rpc/dssync.c
> @@ -935,11 +935,9 @@ static bool test_FetchNT4Data(struct torture_context *tctx,
>   union drsuapi_DsGetNT4ChangeLogInfo info;
>   uint32_t level_out = 0;
>   struct GUID null_guid;
> - struct dom_sid null_sid;
>   DATA_BLOB cookie;
>  
>   ZERO_STRUCT(null_guid);
> - ZERO_STRUCT(null_sid);
>   ZERO_STRUCT(cookie);
>  
>   ZERO_STRUCT(r);
> --
> 2.11.0
>