svn commit: r279344 - head/lib/libc/net

Pedro F. Giffuni pfg at FreeBSD.org
Fri Feb 27 01:59:30 UTC 2015


Author: pfg
Date: Fri Feb 27 01:59:29 2015
New Revision: 279344
URL: https://svnweb.freebsd.org/changeset/base/279344

Log:
  Hint out check for unsigned negative values.
  
  On FreeBSD socklen_t is unsigned so the check negative len
  in inet6_opt_append() is redundant and likely to be optimized
  away by the compiler.
  
  On other operating systems this is not necessarily so, and
  in the future we may want to sign it so leave the check in
  but place it in a secondary position as a subtle indication
  that the bogus check is intentional.
  
  Discussed with:	rpaulo
  
  CID:	1017783

Modified:
  head/lib/libc/net/ip6opt.c

Modified: head/lib/libc/net/ip6opt.c
==============================================================================
--- head/lib/libc/net/ip6opt.c	Fri Feb 27 01:20:17 2015	(r279343)
+++ head/lib/libc/net/ip6opt.c	Fri Feb 27 01:59:29 2015	(r279344)
@@ -419,7 +419,7 @@ inet6_opt_append(void *extbuf, socklen_t
 	 * The option data length must have a value between 0 and 255,
 	 * inclusive, and is the length of the option data that follows.
 	 */
-	if (len < 0 || len > 255)
+	if (len > 255 || len < 0 )
 		return(-1);
 
 	/*


More information about the svn-src-head mailing list