Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Aug 2014 17:26:05 +0000 (UTC)
From:      Davide Italiano <davide@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r270233 - stable/10/sys/kern
Message-ID:  <201408201726.s7KHQ5qg018962@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408201726.s7KHQ5qg018962>