[PATCH] Some small ones around name lookup
Volker Lendecke
Volker.Lendecke at SerNet.DE
Wed Feb 7 08:11:54 UTC 2018
Hi!
Review appreciated!
Thanks, Volker
--
Besuchen Sie die verinice.XP 2018 in Berlin,
Anwenderkonferenz für Informationssicherheit
vom 21.-23.03.2018 im Sofitel Kurfürstendamm
Info & Anmeldung hier: http://veriniceXP.org
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:kontakt at sernet.de
-------------- next part --------------
From b0500387085c6b01293643b1fc55ad594c723fc2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 3 Feb 2018 12:48:35 +0000
Subject: [PATCH 01/10] libnbt: Use TALLOC_FREE
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/nbt/nbtsocket.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/libcli/nbt/nbtsocket.c b/libcli/nbt/nbtsocket.c
index dacacae9f50..d7abb1bf30b 100644
--- a/libcli/nbt/nbtsocket.c
+++ b/libcli/nbt/nbtsocket.c
@@ -45,10 +45,7 @@ static int nbt_name_request_destructor(struct nbt_name_request *req)
idr_remove(req->nbtsock->idr, req->name_trn_id);
req->name_trn_id = 0;
}
- if (req->te) {
- talloc_free(req->te);
- req->te = NULL;
- }
+ TALLOC_FREE(req->te);
if (req->nbtsock->send_queue == NULL) {
TEVENT_FD_NOT_WRITEABLE(req->nbtsock->fde);
}
--
2.11.0
From 4bda94902bd24aa6fd201822b673638fd0fcadb9 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Feb 2018 13:13:31 +0100
Subject: [PATCH 02/10] libnbt: Apply some const
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/nbt/libnbt.h | 4 +++-
libcli/nbt/nbtname.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/libcli/nbt/libnbt.h b/libcli/nbt/libnbt.h
index d4813b96165..f7212789897 100644
--- a/libcli/nbt/libnbt.h
+++ b/libcli/nbt/libnbt.h
@@ -291,7 +291,9 @@ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_status *io);
-NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname);
+NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx,
+ const struct nbt_name *name,
+ struct nbt_name *newname);
NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name);
NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name);
void nbt_choose_called_name(TALLOC_CTX *mem_ctx, struct nbt_name *n, const char *name, int type);
diff --git a/libcli/nbt/nbtname.c b/libcli/nbt/nbtname.c
index d73dde1da59..ec2b395d681 100644
--- a/libcli/nbt/nbtname.c
+++ b/libcli/nbt/nbtname.c
@@ -190,7 +190,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags
/**
copy a nbt name structure
*/
-_PUBLIC_ NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname)
+_PUBLIC_ NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx,
+ const struct nbt_name *name,
+ struct nbt_name *newname)
{
*newname = *name;
newname->name = talloc_strdup(mem_ctx, newname->name);
--
2.11.0
From b231f857983fe4a6a6033895d7d9f0a84e8b6bc2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 29 Jan 2018 10:17:11 +0100
Subject: [PATCH 03/10] nbt_server: Fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/nbt_server/interfaces.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c
index ccbc89accf1..beafec6e6af 100644
--- a/source4/nbt_server/interfaces.c
+++ b/source4/nbt_server/interfaces.c
@@ -45,7 +45,7 @@ static void nbtd_request_handler(struct nbt_name_socket *nbtsock,
nbtsrv->stats.total_received++;
- /* see if its from one of our own interfaces - if so, then ignore it */
+ /* see if it's from one of our own interfaces - if so, then ignore it */
if (nbtd_self_packet_and_bcast(nbtsock, packet, src)) {
DEBUG(10,("Ignoring bcast self packet from %s:%d\n", src->addr, src->port));
return;
--
2.11.0
From 75baff76ae3268c562ee4809ce4fa99f566aa336 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 4 Feb 2018 15:45:57 +0000
Subject: [PATCH 04/10] net: Add some {}
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/utils/net_lookup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c
index 0c019e6e4d4..5ac1ddaaef0 100644
--- a/source3/utils/net_lookup.c
+++ b/source3/utils/net_lookup.c
@@ -405,8 +405,9 @@ static int net_lookup_dsgetdcname(struct net_context *c, int argc, const char **
domain_name = argv[0];
- if (argc >= 2)
+ if (argc >= 2) {
sscanf(argv[1], "%x", &flags);
+ }
if (!flags) {
flags |= DS_DIRECTORY_SERVICE_REQUIRED;
--
2.11.0
From f0f66150cbc82fa502dde50951ad718820c500b9 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 4 Feb 2018 16:41:04 +0000
Subject: [PATCH 05/10] libcli: Fix a cut&paste typo
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/libcli/dgram/netlogon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c
index 0aa68642487..a16a3b96624 100644
--- a/source4/libcli/dgram/netlogon.c
+++ b/source4/libcli/dgram/netlogon.c
@@ -97,7 +97,7 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
/*
- parse a netlogon response. The packet must be a valid mailslot packet
+ parse a netlogon request. The packet must be a valid mailslot packet
*/
NTSTATUS dgram_mailslot_netlogon_parse_request(struct dgram_mailslot_handler *dgmslot,
TALLOC_CTX *mem_ctx,
--
2.11.0
From f3eaa79a4e7d8d42ff9b687060f212a979fae216 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 7 Feb 2018 08:55:03 +0100
Subject: [PATCH 06/10] libsmb: Fix destructor setup in unexpected.c
The destructor does DLIST_REMOVE, so better make sure "client" is in fact
member of that list when the destructor fires
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/libsmb/unexpected.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source3/libsmb/unexpected.c b/source3/libsmb/unexpected.c
index ac6c1cf313c..496bba226d8 100644
--- a/source3/libsmb/unexpected.c
+++ b/source3/libsmb/unexpected.c
@@ -175,7 +175,6 @@ static void nb_packet_server_listener(struct tevent_context *ev,
}
client->server = server;
- talloc_set_destructor(client, nb_packet_client_destructor);
client->out_queue = tevent_queue_create(
client, "unexpected packet output");
@@ -198,6 +197,8 @@ static void nb_packet_server_listener(struct tevent_context *ev,
DLIST_ADD(server->clients, client);
server->num_clients += 1;
+ talloc_set_destructor(client, nb_packet_client_destructor);
+
if (server->num_clients > server->max_clients) {
DEBUG(10, ("Too many clients, dropping oldest\n"));
--
2.11.0
From 3abbf0c2796f1f46fb3676ecff75e963288c2a27 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 30 Jan 2018 13:47:35 +0100
Subject: [PATCH 07/10] libsmb: Fix an error path memleak
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/libsmb/unexpected.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/source3/libsmb/unexpected.c b/source3/libsmb/unexpected.c
index 496bba226d8..ced46969b88 100644
--- a/source3/libsmb/unexpected.c
+++ b/source3/libsmb/unexpected.c
@@ -170,6 +170,7 @@ static void nb_packet_server_listener(struct tevent_context *ev,
ret = tstream_bsd_existing_socket(client, sock, &client->sock);
if (ret != 0) {
DEBUG(10, ("tstream_bsd_existing_socket failed\n"));
+ TALLOC_FREE(client);
close(sock);
return;
}
--
2.11.0
From b02e453afc26132f5ad8ef22d1be7ee6a3cab96d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 12 Jan 2018 22:16:39 +0100
Subject: [PATCH 08/10] dsgetdcname: Add some const
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/libsmb/dsgetdcname.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index f15456a8f4a..2fb9842a893 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -35,11 +35,12 @@ struct ip_service_name {
const char *hostname;
};
-static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
- uint32_t flags,
- struct sockaddr_storage *ss,
- struct NETLOGON_SAM_LOGON_RESPONSE_EX *r,
- struct netr_DsRGetDCNameInfo **info);
+static NTSTATUS make_dc_info_from_cldap_reply(
+ TALLOC_CTX *mem_ctx,
+ uint32_t flags,
+ const struct sockaddr_storage *ss,
+ struct NETLOGON_SAM_LOGON_RESPONSE_EX *r,
+ struct netr_DsRGetDCNameInfo **info);
/****************************************************************
****************************************************************/
@@ -735,11 +736,12 @@ static void map_dc_and_domain_names(uint32_t flags,
/****************************************************************
****************************************************************/
-static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
- uint32_t flags,
- struct sockaddr_storage *ss,
- struct NETLOGON_SAM_LOGON_RESPONSE_EX *r,
- struct netr_DsRGetDCNameInfo **info)
+static NTSTATUS make_dc_info_from_cldap_reply(
+ TALLOC_CTX *mem_ctx,
+ uint32_t flags,
+ const struct sockaddr_storage *ss,
+ struct NETLOGON_SAM_LOGON_RESPONSE_EX *r,
+ struct netr_DsRGetDCNameInfo **info)
{
const char *dc_hostname = NULL;
const char *dc_domain_name = NULL;
--
2.11.0
From 318f5baf02e89b342da5d28132cb4c18e1d3153d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 4 Feb 2018 15:48:23 +0000
Subject: [PATCH 09/10] net: Slightly simplify net_lookup_dsgetdcname()
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/utils/net_lookup.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c
index 5ac1ddaaef0..597e098e2e1 100644
--- a/source3/utils/net_lookup.c
+++ b/source3/utils/net_lookup.c
@@ -409,8 +409,8 @@ static int net_lookup_dsgetdcname(struct net_context *c, int argc, const char **
sscanf(argv[1], "%x", &flags);
}
- if (!flags) {
- flags |= DS_DIRECTORY_SERVICE_REQUIRED;
+ if (flags == 0) {
+ flags = DS_DIRECTORY_SERVICE_REQUIRED;
}
if (argc == 3) {
--
2.11.0
From 2df8497b6bcf159f586d693046e21cbcac7de62d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 4 Feb 2018 15:13:43 +0000
Subject: [PATCH 10/10] libsocket: Avoid an unnecessary else branch
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/lib/socket/socket_ip.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c
index 87b7bf4911d..e0aa5da07cb 100644
--- a/source4/lib/socket/socket_ip.c
+++ b/source4/lib/socket/socket_ip.c
@@ -316,7 +316,8 @@ static NTSTATUS ipv4_recvfrom(struct socket_context *sock, void *buf,
if (gotlen == 0) {
talloc_free(src);
return NT_STATUS_END_OF_FILE;
- } else if (gotlen == -1) {
+ }
+ if (gotlen == -1) {
talloc_free(src);
return map_nt_error_from_unix_common(errno);
}
--
2.11.0
More information about the samba-technical
mailing list