The Samba-Bugzilla – Attachment 7950 Details for
Bug 9218
Samba panics if a user specifies an invalid port number
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
v3-6-test patch
0001-s3-smbd-Don-t-segfault-if-user-specified-ports-out-f.patch (text/plain), 2.70 KB, created by
Andreas Schneider
on 2012-09-27 08:00:52 UTC
(
hide
)
Description:
v3-6-test patch
Filename:
MIME Type:
Creator:
Andreas Schneider
Created:
2012-09-27 08:00:52 UTC
Size:
2.70 KB
patch
obsolete
>From 16a6e6125a4f7067722318b5bb35b93a666dce14 Mon Sep 17 00:00:00 2001 >From: Andreas Schneider <asn@samba.org> >Date: Tue, 25 Sep 2012 14:28:22 +0200 >Subject: [PATCH] s3-smbd: Don't segfault if user specified ports out for > range. > >(cherry picked from commit 50d324b7e070de4672eff3fb6231923e6dca807a) > >Signed-off-by: Andreas Schneider <asn@samba.org> >--- > source3/smbd/server.c | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-) > >diff --git a/source3/smbd/server.c b/source3/smbd/server.c >index 2400ce4..c699d3b 100644 >--- a/source3/smbd/server.c >+++ b/source3/smbd/server.c >@@ -650,6 +650,8 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, > int num_interfaces = iface_count(); > int i; > char *ports; >+ char *tok; >+ const char *ptr; > unsigned dns_port = 0; > > #ifdef HAVE_ATEXIT >@@ -671,6 +673,16 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, > ports = talloc_strdup(talloc_tos(), smb_ports); > } > >+ for (ptr = ports; >+ next_token_talloc(talloc_tos(),&ptr, &tok, " \t,");) { >+ unsigned port = atoi(tok); >+ >+ 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 >@@ -682,8 +694,6 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, > for(i = 0; i < num_interfaces; i++) { > const struct sockaddr_storage *ifss = > iface_n_sockaddr_storage(i); >- char *tok; >- const char *ptr; > > if (ifss == NULL) { > DEBUG(0,("open_sockets_smbd: " >@@ -695,9 +705,6 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, > for (ptr=ports; > next_token_talloc(talloc_tos(),&ptr, &tok, " \t,");) { > unsigned port = atoi(tok); >- if (port == 0 || port > 0xffff) { >- continue; >- } > > /* Keep the first port for mDNS service > * registration. >@@ -715,8 +722,6 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, > /* Just bind to 0.0.0.0 - accept connections > from anywhere. */ > >- char *tok; >- const char *ptr; > const char *sock_addr = lp_socket_address(); > char *sock_tok; > const char *sock_ptr; >@@ -734,11 +739,7 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, > next_token_talloc(talloc_tos(), &sock_ptr, &sock_tok, " \t,"); ) { > for (ptr=ports; next_token_talloc(talloc_tos(), &ptr, &tok, " \t,"); ) { > struct sockaddr_storage ss; >- > unsigned port = atoi(tok); >- if (port == 0 || port > 0xffff) { >- continue; >- } > > /* Keep the first port for mDNS service > * registration. >-- >1.7.12 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
jra
:
review+
Actions:
View
Attachments on
bug 9218
:
7949
| 7950 |
7951