svn commit: r233146 - stable/9/lib/libc/string

Eitan Adler eadler at FreeBSD.org
Mon Mar 19 01:27:31 UTC 2012


Author: eadler
Date: Mon Mar 19 01:27:30 2012
New Revision: 233146
URL: http://svn.freebsd.org/changeset/base/233146

Log:
  MFC r232503:
  	POSIX mandates that swab do nothing when len < 0
  
  PR:		140690
  Approved by:	cperciva

Modified:
  stable/9/lib/libc/string/swab.3
  stable/9/lib/libc/string/swab.c
Directory Properties:
  stable/9/lib/libc/   (props changed)

Modified: stable/9/lib/libc/string/swab.3
==============================================================================
--- stable/9/lib/libc/string/swab.3	Mon Mar 19 01:19:04 2012	(r233145)
+++ stable/9/lib/libc/string/swab.3	Mon Mar 19 01:27:30 2012	(r233146)
@@ -28,7 +28,7 @@
 .\"     @(#)swab.3	8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd December 10, 2004
+.Dd March 4, 2012
 .Dt SWAB 3
 .Os
 .Sh NAME
@@ -54,6 +54,9 @@ swapping adjacent bytes.
 The argument
 .Fa len
 must be an even number.
+If
+.Fa len
+is less than zero, nothing will be done.
 .Sh SEE ALSO
 .Xr bzero 3 ,
 .Xr memset 3

Modified: stable/9/lib/libc/string/swab.c
==============================================================================
--- stable/9/lib/libc/string/swab.c	Mon Mar 19 01:19:04 2012	(r233145)
+++ stable/9/lib/libc/string/swab.c	Mon Mar 19 01:27:30 2012	(r233146)
@@ -45,6 +45,8 @@ swab(const void * __restrict from, void 
 	int n;
 	char *fp, *tp;
 
+	if (len <= 0)
+		return;
 	n = len >> 1;
 	fp = (char *)from;
 	tp = (char *)to;


More information about the svn-src-stable-9 mailing list