[Pkg-samba-maint] r3688 - in trunk/samba: . lib/tevent nsswitch nsswitch/libwbclient packaging/RHEL packaging/RHEL-CTDB source3 source3/client source3/include source3/lib source3/libaddns source3/libsmb source3/nmbd source3/utils source3/winbindd

bubulle at alioth.debian.org bubulle at alioth.debian.org
Tue Mar 1 19:57:42 UTC 2011


Author: bubulle
Date: 2011-03-01 19:57:41 +0000 (Tue, 01 Mar 2011)
New Revision: 3688

Modified:
   trunk/samba/WHATSNEW.txt
   trunk/samba/lib/tevent/tevent_select.c
   trunk/samba/lib/tevent/tevent_standard.c
   trunk/samba/nsswitch/libwbclient/wbc_async.c
   trunk/samba/nsswitch/wb_common.c
   trunk/samba/packaging/RHEL-CTDB/samba.spec
   trunk/samba/packaging/RHEL/makerpms.sh
   trunk/samba/packaging/RHEL/samba.spec
   trunk/samba/source3/VERSION
   trunk/samba/source3/client/client.c
   trunk/samba/source3/client/dnsbrowse.c
   trunk/samba/source3/include/version.h
   trunk/samba/source3/lib/events.c
   trunk/samba/source3/lib/g_lock.c
   trunk/samba/source3/lib/packet.c
   trunk/samba/source3/lib/readline.c
   trunk/samba/source3/lib/select.c
   trunk/samba/source3/lib/util_sock.c
   trunk/samba/source3/libaddns/dnssock.c
   trunk/samba/source3/libsmb/nmblib.c
   trunk/samba/source3/nmbd/nmbd_packets.c
   trunk/samba/source3/utils/smbfilter.c
   trunk/samba/source3/winbindd/winbindd_dual.c
Log:
merge upstream 3.5.7

Modified: trunk/samba/WHATSNEW.txt
===================================================================
--- trunk/samba/WHATSNEW.txt	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/WHATSNEW.txt	2011-03-01 19:57:41 UTC (rev 3688)
@@ -1,4 +1,53 @@
                    =============================
+                   Release Notes for Samba 3.5.7
+			  February 28, 2011
+                   =============================
+
+
+This is a security release in order to address CVE-2011-0719.
+
+
+o  CVE-2011-0719:
+   All current released versions of Samba are vulnerable to
+   a denial of service caused by memory corruption. Range
+   checks on file descriptors being used in the FD_SET macro
+   were not present allowing stack corruption. This can cause
+   the Samba code to crash or to loop attempting to select
+   on a bad file descriptor set.
+
+
+Changes since 3.5.6:
+--------------------
+
+
+o   Jeremy Allison <jra at samba.org>
+    * BUG 7949: Fix DoS in Winbind and smbd with many file descriptors open.
+
+
+######################################################################
+Reporting bugs & Development Discussion
+#######################################
+
+Please discuss this release on the samba-technical mailing list or by
+joining the #samba-technical IRC channel on irc.freenode.net.
+
+If you do report problems then please try to send high quality
+feedback. If you don't provide vital information to help us track down
+the problem then you will probably be ignored.  All bug reports should
+be filed under the Samba 3.5 product in the project's Bugzilla
+database (https://bugzilla.samba.org/).
+
+
+======================================================================
+== Our Code, Our Bugs, Our Responsibility.
+== The Samba Team
+======================================================================
+
+
+Release notes for older releases follow:
+----------------------------------------
+
+                   =============================
                    Release Notes for Samba 3.5.6
 			  October 8, 2010
                    =============================
@@ -94,9 +143,9 @@
 ======================================================================
 
 
-Release notes for older releases follow:
-----------------------------------------
+----------------------------------------------------------------------
 
+
                    =============================
                    Release Notes for Samba 3.5.5
 			 September 14, 2010

Modified: trunk/samba/lib/tevent/tevent_select.c
===================================================================
--- trunk/samba/lib/tevent/tevent_select.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/lib/tevent/tevent_select.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -111,6 +111,11 @@
 							   struct select_event_context);
 	struct tevent_fd *fde;
 
+	if (fd < 0 || fd >= FD_SETSIZE) {
+		errno = EBADF;
+		return NULL;
+	}
+
 	fde = tevent_common_add_fd(ev, mem_ctx, fd, flags,
 				   handler, private_data,
 				   handler_name, location);
@@ -143,6 +148,11 @@
 
 	/* setup any fd events */
 	for (fde = select_ev->ev->fd_events; fde; fde = fde->next) {
+		if (fde->fd < 0 || fde->fd >= FD_SETSIZE) {
+			errno = EBADF;
+			return -1;
+		}
+
 		if (fde->flags & TEVENT_FD_READ) {
 			FD_SET(fde->fd, &r_fds);
 		}

Modified: trunk/samba/lib/tevent/tevent_standard.c
===================================================================
--- trunk/samba/lib/tevent/tevent_standard.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/lib/tevent/tevent_standard.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -457,6 +457,11 @@
 
 	/* setup any fd events */
 	for (fde = std_ev->ev->fd_events; fde; fde = fde->next) {
+		if (fde->fd < 0 || fde->fd >= FD_SETSIZE) {
+			std_ev->exit_code = EBADF;
+			return -1;
+		}
+
 		if (fde->flags & TEVENT_FD_READ) {
 			FD_SET(fde->fd, &r_fds);
 		}

Modified: trunk/samba/nsswitch/libwbclient/wbc_async.c
===================================================================
--- trunk/samba/nsswitch/libwbclient/wbc_async.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/nsswitch/libwbclient/wbc_async.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -509,7 +509,7 @@
 	fd_set r_fds;
 	int selret;
 
-	if (fd == -1) {
+	if (fd < 0 || fd >= FD_SETSIZE) {
 		return true;
 	}
 

Modified: trunk/samba/nsswitch/wb_common.c
===================================================================
--- trunk/samba/nsswitch/wb_common.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/nsswitch/wb_common.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -244,6 +244,10 @@
 		switch (errno) {
 			case EINPROGRESS:
 				FD_ZERO(&w_fds);
+				if (fd < 0 || fd >= FD_SETSIZE) {
+					errno = EBADF;
+					goto error_out;
+				}
 				FD_SET(fd, &w_fds);
 				tv.tv_sec = CONNECT_TIMEOUT - wait_time;
 				tv.tv_usec = 0;
@@ -391,6 +395,11 @@
 		   call would not block by calling select(). */
 
 		FD_ZERO(&r_fds);
+		if (winbindd_fd < 0 || winbindd_fd >= FD_SETSIZE) {
+			errno = EBADF;
+			winbind_close_sock();
+			return -1;
+		}
 		FD_SET(winbindd_fd, &r_fds);
 		ZERO_STRUCT(tv);
 
@@ -451,6 +460,11 @@
 		   call would not block by calling select(). */
 
 		FD_ZERO(&r_fds);
+		if (winbindd_fd < 0 || winbindd_fd >= FD_SETSIZE) {
+			errno = EBADF;
+			winbind_close_sock();
+			return -1;
+		}
 		FD_SET(winbindd_fd, &r_fds);
 		ZERO_STRUCT(tv);
 		/* Wait for 5 seconds for a reply. May need to parameterise this... */

Modified: trunk/samba/packaging/RHEL/makerpms.sh
===================================================================
--- trunk/samba/packaging/RHEL/makerpms.sh	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/packaging/RHEL/makerpms.sh	2011-03-01 19:57:41 UTC (rev 3688)
@@ -20,7 +20,7 @@
 
 USERID=`id -u`
 GRPID=`id -g`
-VERSION='3.5.6'
+VERSION='3.5.7'
 REVISION=''
 SPECFILE="samba.spec"
 RPMVER=`rpm --version | awk '{print $3}'`

Modified: trunk/samba/packaging/RHEL/samba.spec
===================================================================
--- trunk/samba/packaging/RHEL/samba.spec	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/packaging/RHEL/samba.spec	2011-03-01 19:57:41 UTC (rev 3688)
@@ -5,7 +5,7 @@
 Vendor: Samba Team
 Packager: Samba Team <samba at samba.org>
 Name:         samba
-Version:      3.5.6
+Version:      3.5.7
 Release:      1
 Epoch:        0
 License: GNU GPL version 3

Modified: trunk/samba/packaging/RHEL-CTDB/samba.spec
===================================================================
--- trunk/samba/packaging/RHEL-CTDB/samba.spec	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/packaging/RHEL-CTDB/samba.spec	2011-03-01 19:57:41 UTC (rev 3688)
@@ -5,7 +5,7 @@
 Vendor: Samba Team
 Packager: Samba Team <samba at samba.org>
 Name:         samba
-Version:      3.5.6
+Version:      3.5.7
 Release:      1GITHASH
 Epoch:        0
 License: GNU GPL version 3

Modified: trunk/samba/source3/VERSION
===================================================================
--- trunk/samba/source3/VERSION	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/VERSION	2011-03-01 19:57:41 UTC (rev 3688)
@@ -25,7 +25,7 @@
 ########################################################
 SAMBA_VERSION_MAJOR=3
 SAMBA_VERSION_MINOR=5
-SAMBA_VERSION_RELEASE=6
+SAMBA_VERSION_RELEASE=7
 
 ########################################################
 # Bug fix releases use a letter for the patch revision #

Modified: trunk/samba/source3/client/client.c
===================================================================
--- trunk/samba/source3/client/client.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/client/client.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -4420,8 +4420,10 @@
 
  again:
 
-	if (cli->fd == -1)
+	if (cli->fd < 0 || cli->fd >= FD_SETSIZE) {
+		errno = EBADF;
 		return;
+	}
 
 	FD_ZERO(&fds);
 	FD_SET(cli->fd,&fds);

Modified: trunk/samba/source3/client/dnsbrowse.c
===================================================================
--- trunk/samba/source3/client/dnsbrowse.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/client/dnsbrowse.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -81,6 +81,11 @@
 			TALLOC_FREE(fdset);
 		}
 
+		if (mdnsfd < 0 || mdnsfd >= FD_SETSIZE) {
+			errno = EBADF;
+			break;
+		}
+
 		fdsetsz = howmany(mdnsfd + 1, NFDBITS) * sizeof(fd_mask);
 		fdset = TALLOC_ZERO(ctx, fdsetsz);
 		FD_SET(mdnsfd, fdset);
@@ -181,6 +186,12 @@
 			TALLOC_FREE(fdset);
 		}
 
+		if (mdnsfd < 0 || mdnsfd >= FD_SETSIZE) {
+			errno = EBADF;
+			TALLOC_FREE(ctx);
+			return 1;
+		}
+
 		fdsetsz = howmany(mdnsfd + 1, NFDBITS) * sizeof(fd_mask);
 		fdset = TALLOC_ZERO(ctx, fdsetsz);
 		FD_SET(mdnsfd, fdset);

Modified: trunk/samba/source3/include/version.h
===================================================================
--- trunk/samba/source3/include/version.h	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/include/version.h	2011-03-01 19:57:41 UTC (rev 3688)
@@ -1,8 +1,8 @@
 /* Autogenerated by script/mkversion.sh */
 #define SAMBA_VERSION_MAJOR 3
 #define SAMBA_VERSION_MINOR 5
-#define SAMBA_VERSION_RELEASE 6
-#define SAMBA_VERSION_OFFICIAL_STRING "3.5.6"
+#define SAMBA_VERSION_RELEASE 7
+#define SAMBA_VERSION_OFFICIAL_STRING "3.5.7"
 #ifdef SAMBA_VERSION_VENDOR_FUNCTION
 #  define SAMBA_VERSION_STRING SAMBA_VERSION_VENDOR_FUNCTION
 #else /* SAMBA_VERSION_VENDOR_FUNCTION */

Modified: trunk/samba/source3/lib/events.c
===================================================================
--- trunk/samba/source3/lib/events.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/lib/events.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -55,6 +55,14 @@
 	bool ret = false;
 
 	for (fde = ev->fd_events; fde; fde = fde->next) {
+		if (fde->fd < 0 || fde->fd >= FD_SETSIZE) {
+			/* We ignore here, as it shouldn't be
+			   possible to add an invalid fde->fd
+			   but we don't want FD_SET to see an
+			   invalid fd. */
+			continue;
+		}
+
 		if (fde->flags & EVENT_FD_READ) {
 			FD_SET(fde->fd, read_fds);
 			ret = true;

Modified: trunk/samba/source3/lib/g_lock.c
===================================================================
--- trunk/samba/source3/lib/g_lock.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/lib/g_lock.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -391,7 +391,9 @@
 			r_fds = &_r_fds;
 			FD_ZERO(r_fds);
 			max_fd = ctdbd_conn_get_fd(conn);
-			FD_SET(max_fd, r_fds);
+			if (max_fd >= 0 && max_fd < FD_SETSIZE) {
+				FD_SET(max_fd, r_fds);
+			}
 		}
 #endif
 

Modified: trunk/samba/source3/lib/packet.c
===================================================================
--- trunk/samba/source3/lib/packet.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/lib/packet.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -107,6 +107,11 @@
 	int res;
 	fd_set r_fds;
 
+	if (ctx->fd < 0 || ctx->fd >= FD_SETSIZE) {
+		errno = EBADF;
+		return map_nt_error_from_unix(errno);
+	}
+
 	FD_ZERO(&r_fds);
 	FD_SET(ctx->fd, &r_fds);
 

Modified: trunk/samba/source3/lib/readline.c
===================================================================
--- trunk/samba/source3/lib/readline.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/lib/readline.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -91,6 +91,11 @@
 		timeout.tv_sec = 5;
 		timeout.tv_usec = 0;
 
+		if (fd < 0 || fd >= FD_SETSIZE) {
+			errno = EBADF;
+			break;
+		}
+
 		FD_ZERO(&fds);
 		FD_SET(fd,&fds);
 

Modified: trunk/samba/source3/lib/select.c
===================================================================
--- trunk/samba/source3/lib/select.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/lib/select.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -75,6 +75,17 @@
 			return -1;
 		}
 
+		if (select_pipe[0] < 0 || select_pipe[0] >= FD_SETSIZE) {
+			DEBUG(0, ("sys_select: bad fd\n"));
+			if (readfds != NULL)
+				FD_ZERO(readfds);
+			if (writefds != NULL)
+				FD_ZERO(writefds);
+			if (errorfds != NULL)
+				FD_ZERO(errorfds);
+			errno = EBADF;
+			return -1;
+		}
 		/*
 		 * These next two lines seem to fix a bug with the Linux
 		 * 2.0.x kernel (and probably other UNIXes as well) where
@@ -101,6 +112,7 @@
 		readfds2 = &readfds_buf;
 		FD_ZERO(readfds2);
 	}
+
 	FD_SET(select_pipe[0], readfds2);
 
 	errno = 0;

Modified: trunk/samba/source3/lib/util_sock.c
===================================================================
--- trunk/samba/source3/lib/util_sock.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/lib/util_sock.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -495,6 +495,11 @@
 	timeout.tv_usec = (long)(1000 * (time_out % 1000));
 
 	for (nread=0; nread < mincnt; ) {
+		if (fd < 0 || fd >= FD_SETSIZE) {
+			errno = EBADF;
+			return map_nt_error_from_unix(EBADF);
+		}
+
 		FD_ZERO(&fds);
 		FD_SET(fd,&fds);
 
@@ -1235,7 +1240,7 @@
 
 	for (i=0; i<num_addrs; i++) {
 		sockets[i] = socket(addrs[i].ss_family, SOCK_STREAM, 0);
-		if (sockets[i] < 0)
+		if (sockets[i] < 0 || sockets[i] >= FD_SETSIZE)
 			goto done;
 		set_blocking(sockets[i], false);
 	}
@@ -1284,8 +1289,10 @@
 	FD_ZERO(&r_fds);
 
 	for (i=0; i<num_addrs; i++) {
-		if (sockets[i] == -1)
+		if (sockets[i] < 0 || sockets[i] >= FD_SETSIZE) {
+			/* This cannot happen - ignore if so. */
 			continue;
+		}
 		FD_SET(sockets[i], &wr_fds);
 		FD_SET(sockets[i], &r_fds);
 		if (sockets[i]>maxfd)
@@ -1305,8 +1312,10 @@
 
 	for (i=0; i<num_addrs; i++) {
 
-		if (sockets[i] == -1)
+		if (sockets[i] < 0 || sockets[i] >= FD_SETSIZE) {
+			/* This cannot happen - ignore if so. */
 			continue;
+		}
 
 		/* Stevens, Network Programming says that if there's a
 		 * successful connect, the socket is only writable. Upon an

Modified: trunk/samba/source3/libaddns/dnssock.c
===================================================================
--- trunk/samba/source3/libaddns/dnssock.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/libaddns/dnssock.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -219,6 +219,11 @@
 		ssize_t ret;
 		int fd_ready;
 		
+		if (fd < 0 || fd >= FD_SETSIZE) {
+			/* read timeout */
+			return ERROR_DNS_SOCKET_ERROR;
+		}
+
 		FD_ZERO( &rfds );
 		FD_SET( fd, &rfds );
 

Modified: trunk/samba/source3/libsmb/nmblib.c
===================================================================
--- trunk/samba/source3/libsmb/nmblib.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/libsmb/nmblib.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -1094,6 +1094,11 @@
 	struct timeval timeout;
 	int ret;
 
+	if (fd < 0 || fd >= FD_SETSIZE) {
+		errno = EBADF;
+		return NULL;
+	}
+
 	FD_ZERO(&fds);
 	FD_SET(fd,&fds);
 	timeout.tv_sec = t/1000;

Modified: trunk/samba/source3/nmbd/nmbd_packets.c
===================================================================
--- trunk/samba/source3/nmbd/nmbd_packets.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/nmbd/nmbd_packets.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -1696,7 +1696,7 @@
 	/* each interface gets 4 sockets */
 	count *= 4;
 
-	if(count > FD_SETSIZE) {
+	if(count >= FD_SETSIZE) {
 		DEBUG(0,("create_listen_fdset: Too many file descriptors needed (%d). We can \
 only use %d.\n", count, FD_SETSIZE));
 		SAFE_FREE(pset);
@@ -1712,6 +1712,12 @@
 	FD_ZERO(pset);
 
 	/* Add in the lp_socket_address() interface on 137. */
+	if (ClientNMB < 0 || ClientNMB >= FD_SETSIZE) {
+		errno = EBADF;
+		SAFE_FREE(pset);
+		return True;
+	}
+
 	FD_SET(ClientNMB,pset);
 	sock_array[num++] = ClientNMB;
 	*maxfd = MAX( *maxfd, ClientNMB);
@@ -1721,18 +1727,29 @@
 
 	/* Add in the 137 sockets on all the interfaces. */
 	for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) {
+		if (subrec->nmb_sock < 0 || subrec->nmb_sock >= FD_SETSIZE) {
+			/* We have to ignore sockets outside FD_SETSIZE. */
+			continue;
+		}
 		FD_SET(subrec->nmb_sock,pset);
 		sock_array[num++] = subrec->nmb_sock;
 		*maxfd = MAX( *maxfd, subrec->nmb_sock);
 
+		if (subrec->nmb_bcast < 0 || subrec->nmb_bcast >= FD_SETSIZE) {
+			/* We have to ignore sockets outside FD_SETSIZE. */
+			continue;
+		}
 		sock_array[num++] = subrec->nmb_bcast;
-		if (subrec->nmb_bcast != -1) {
-			FD_SET(subrec->nmb_bcast,pset);
-			*maxfd = MAX( *maxfd, subrec->nmb_bcast);
-		}
+		FD_SET(subrec->nmb_bcast,pset);
+		*maxfd = MAX( *maxfd, subrec->nmb_bcast);
 	}
 
 	/* Add in the lp_socket_address() interface on 138. */
+	if (ClientDGRAM < 0 || ClientDGRAM >= FD_SETSIZE) {
+		errno = EBADF;
+		SAFE_FREE(pset);
+		return True;
+	}
 	FD_SET(ClientDGRAM,pset);
 	sock_array[num++] = ClientDGRAM;
 	*maxfd = MAX( *maxfd, ClientDGRAM);
@@ -1742,10 +1759,18 @@
 
 	/* Add in the 138 sockets on all the interfaces. */
 	for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) {
+		if (subrec->dgram_sock < 0 || subrec->dgram_sock >= FD_SETSIZE) {
+			/* We have to ignore sockets outside FD_SETSIZE. */
+			continue;
+		}
 		FD_SET(subrec->dgram_sock,pset);
 		sock_array[num++] = subrec->dgram_sock;
 		*maxfd = MAX( *maxfd, subrec->dgram_sock);
 
+		if (subrec->dgram_bcast < 0 || subrec->dgram_bcast >= FD_SETSIZE) {
+			/* We have to ignore sockets outside FD_SETSIZE. */
+			continue;
+		}
 		sock_array[num++] = subrec->dgram_bcast;
 		if (subrec->dgram_bcast != -1) {
 			FD_SET(subrec->dgram_bcast,pset);
@@ -1876,7 +1901,7 @@
 
 #ifndef SYNC_DNS
 	dns_fd = asyncdns_fd();
-	if (dns_fd != -1) {
+	if (dns_fd >= 0 && dns_fd < FD_SETSIZE) {
 		FD_SET(dns_fd, &r_fds);
 		maxfd = MAX( maxfd, dns_fd);
 	}

Modified: trunk/samba/source3/utils/smbfilter.c
===================================================================
--- trunk/samba/source3/utils/smbfilter.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/utils/smbfilter.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -193,8 +193,8 @@
 		int num;
 		
 		FD_ZERO(&fds);
-		if (s != -1) FD_SET(s, &fds);
-		if (c != -1) FD_SET(c, &fds);
+		if (s >= 0 && s < FD_SETSIZE) FD_SET(s, &fds);
+		if (c >= 0 && c < FD_SETSIZE) FD_SET(c, &fds);
 
 		num = sys_select_intr(MAX(s+1, c+1),&fds,NULL,NULL,NULL);
 		if (num <= 0) continue;
@@ -267,6 +267,9 @@
 		socklen_t in_addrlen = sizeof(ss);
 		
 		FD_ZERO(&fds);
+		if (s < 0 || s >= FD_SETSIZE) {
+			break;
+		}
 		FD_SET(s, &fds);
 
 		num = sys_select_intr(s+1,&fds,NULL,NULL,NULL);

Modified: trunk/samba/source3/winbindd/winbindd_dual.c
===================================================================
--- trunk/samba/source3/winbindd/winbindd_dual.c	2011-03-01 19:53:20 UTC (rev 3687)
+++ trunk/samba/source3/winbindd/winbindd_dual.c	2011-03-01 19:57:41 UTC (rev 3688)
@@ -1460,6 +1460,13 @@
 
 		FD_ZERO(&r_fds);
 		FD_ZERO(&w_fds);
+
+		if (state.sock < 0 || state.sock >= FD_SETSIZE) {
+			TALLOC_FREE(frame);
+			perror("EBADF");
+			_exit(1);
+		}
+
 		FD_SET(state.sock, &r_fds);
 		maxfd = state.sock;
 





More information about the Pkg-samba-maint mailing list