Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Sep 2016 12:41:54 +0000 (UTC)
From:      Ruslan Bukin <br@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r306186 - head/sys/kern
Message-ID:  <201609221241.u8MCfsvv097499@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: br
Date: Thu Sep 22 12:41:53 2016
New Revision: 306186
URL: https://svnweb.freebsd.org/changeset/base/306186

Log:
  Adjust the sopt_val pointer on bigendian systems (e.g. MIPS64EB).
  
  sooptcopyin() checks if size of data provided by user is <= than we can
  accept, else it strips down the size. On bigendian platforms we have to
  move pointer as well so we copy the actual data.
  
  Reviewed by:	gnn
  Sponsored by:	DARPA, AFRL
  Sponsored by:	HEIF5
  Differential Revision:	https://reviews.freebsd.org/D7980

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Thu Sep 22 12:08:26 2016	(r306185)
+++ head/sys/kern/uipc_socket.c	Thu Sep 22 12:41:53 2016	(r306186)
@@ -2455,8 +2455,12 @@ sooptcopyin(struct sockopt *sopt, void *
 	 */
 	if ((valsize = sopt->sopt_valsize) < minlen)
 		return EINVAL;
-	if (valsize > len)
+	if (valsize > len) {
+#if _BYTE_ORDER == _BIG_ENDIAN
+		sopt->sopt_val = (void *)((uintptr_t)sopt->sopt_val + (valsize - len));
+#endif
 		sopt->sopt_valsize = valsize = len;
+	}
 
 	if (sopt->sopt_td != NULL)
 		return (copyin(sopt->sopt_val, buf, valsize));



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