Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Mar 2012 16:39:08 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r232503 - head/lib/libc/string
Message-ID:  <201203041639.q24Gd8dJ043387@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Sun Mar  4 16:39:08 2012
New Revision: 232503
URL: http://svn.freebsd.org/changeset/base/232503

Log:
  POSIX mandates that swab do nothing when len < 0
  
  PR:		kern/140690
  Submitted by:	Jeremy Huddleston <jeremyhu@apple.com>
  Approved by:	cperciva
  MFC after:	2 weeks

Modified:
  head/lib/libc/string/swab.3
  head/lib/libc/string/swab.c

Modified: head/lib/libc/string/swab.3
==============================================================================
--- head/lib/libc/string/swab.3	Sun Mar  4 16:37:44 2012	(r232502)
+++ head/lib/libc/string/swab.3	Sun Mar  4 16:39:08 2012	(r232503)
@@ -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: head/lib/libc/string/swab.c
==============================================================================
--- head/lib/libc/string/swab.c	Sun Mar  4 16:37:44 2012	(r232502)
+++ head/lib/libc/string/swab.c	Sun Mar  4 16:39:08 2012	(r232503)
@@ -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?201203041639.q24Gd8dJ043387>