svn commit: r270233 - stable/10/sys/kern

Davide Italiano davide at FreeBSD.org
Wed Aug 20 17:26:05 UTC 2014


Author: davide
Date: Wed Aug 20 17:26:05 2014
New Revision: 270233
URL: http://svnweb.freebsd.org/changeset/base/270233

Log:
  MFC r269502:
  Fix an overflow in getsockopt(). optval isn't big enough to hold
  sbintime_t.
  Re-introduce r255030 behaviour capping socket timeouts to INT_32
  if they're too large.

Modified:
  stable/10/sys/kern/uipc_socket.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/uipc_socket.c
==============================================================================
--- stable/10/sys/kern/uipc_socket.c	Wed Aug 20 17:07:41 2014	(r270232)
+++ stable/10/sys/kern/uipc_socket.c	Wed Aug 20 17:26:05 2014	(r270233)
@@ -2548,8 +2548,10 @@ sosetopt(struct socket *so, struct socko
 				error = EDOM;
 				goto bad;
 			}
-			val = tvtosbt(tv);
-
+			if (tv.tv_sec > INT32_MAX)
+				val = SBT_MAX;
+			else
+				val = tvtosbt(tv);
 			switch (sopt->sopt_name) {
 			case SO_SNDTIMEO:
 				so->so_snd.sb_timeo = val;
@@ -2699,10 +2701,8 @@ integer:
 
 		case SO_SNDTIMEO:
 		case SO_RCVTIMEO:
-			optval = (sopt->sopt_name == SO_SNDTIMEO ?
-				  so->so_snd.sb_timeo : so->so_rcv.sb_timeo);
-
-			tv = sbttotv(optval);
+			tv = sbttotv(sopt->sopt_name == SO_SNDTIMEO ?
+			    so->so_snd.sb_timeo : so->so_rcv.sb_timeo);
 #ifdef COMPAT_FREEBSD32
 			if (SV_CURPROC_FLAG(SV_ILP32)) {
 				struct timeval32 tv32;


More information about the svn-src-all mailing list