Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Mar 2012 01:27:55 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r233147 - stable/8/lib/libc/string
Message-ID:  <201203190127.q2J1RtgB044557@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Mon Mar 19 01:27:55 2012
New Revision: 233147
URL: http://svn.freebsd.org/changeset/base/233147

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

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

Modified: stable/8/lib/libc/string/swab.3
==============================================================================
--- stable/8/lib/libc/string/swab.3	Mon Mar 19 01:27:30 2012	(r233146)
+++ stable/8/lib/libc/string/swab.3	Mon Mar 19 01:27:55 2012	(r233147)
@@ -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/8/lib/libc/string/swab.c
==============================================================================
--- stable/8/lib/libc/string/swab.c	Mon Mar 19 01:27:30 2012	(r233146)
+++ stable/8/lib/libc/string/swab.c	Mon Mar 19 01:27:55 2012	(r233147)
@@ -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;



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