summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2012-09-25 14:28:22 +0200
committerKarolin Seeger <kseeger@samba.org>2012-09-28 11:02:16 +0200
commitc10debda1ed4d9b71238829656fc9f78eb75317d (patch)
tree786eb0b16a5c58fecfe8b33786a0d3a4f62a6682
parentd5f5a6a37c0c06c7e5b783da8636f0bcd23d6c07 (diff)
downloadsamba-c10debda1ed4d9b71238829656fc9f78eb75317d.tar.gz
s3-smbd: Don't segfault if user specified ports out for range.
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Wed Sep 26 16:28:44 CEST 2012 on sn-devel-104 (cherry picked from commit 50d324b7e070de4672eff3fb6231923e6dca807a) Signed-off-by: Andreas Schneider <asn@samba.org> Fix bug #9218 - Samba panics if a user specifies an invalid port number. Autobuild-User(v4-0-test): Karolin Seeger <kseeger@samba.org> Autobuild-Date(v4-0-test): Fri Sep 28 11:02:16 CEST 2012 on sn-devel-104
-rw-r--r--source3/smbd/server.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 15762d84e9d..90bbb62ef7f 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -752,6 +752,15 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
ports = (const char **)str_list_make_v3(talloc_tos(), smb_ports, NULL);
}
+ for (j = 0; ports && ports[j]; j++) {
+ unsigned port = atoi(ports[j]);
+
+ if (port == 0 || port > 0xffff) {
+ exit_server_cleanly("Invalid port in the config or on "
+ "the commandline specified!");
+ }
+ }
+
if (lp_interfaces() && lp_bind_interfaces_only()) {
/* We have been given an interfaces line, and been
told to only bind to those interfaces. Create a
@@ -772,9 +781,6 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
for (j = 0; ports && ports[j]; j++) {
unsigned port = atoi(ports[j]);
- if (port == 0 || port > 0xffff) {
- continue;
- }
/* Keep the first port for mDNS service
* registration.
@@ -810,11 +816,7 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
next_token_talloc(talloc_tos(), &sock_ptr, &sock_tok, " \t,"); ) {
for (j = 0; ports && ports[j]; j++) {
struct sockaddr_storage ss;
-
unsigned port = atoi(ports[j]);
- if (port == 0 || port > 0xffff) {
- continue;
- }
/* Keep the first port for mDNS service
* registration.