Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Nov 2009 02:44:45 GMT
From:      Jeremy Huddleston <jeremyhu@apple.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/140690: swab() with negative len should do nothing
Message-ID:  <200911190244.nAJ2ij5C016512@www.freebsd.org>
Resent-Message-ID: <200911190250.nAJ2o1aB084315@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         140690
>Category:       misc
>Synopsis:       swab() with negative len should do nothing
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 19 02:50:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Jeremy Huddleston
>Release:        MAIN
>Organization:
Apple
>Environment:
NA
>Description:
src/lib/libc/string/swab.c has a bug when len < 0.  The "round to multiple of 8" for loop will still STEP with negative values.  This should not be the case.  Simple patch is attached.
>How-To-Repeat:

>Fix:
--- swab.c.bsdnew	2009-11-18 18:24:38.000000000 -0800
+++ swab.c	2009-11-18 18:40:17.000000000 -0800
@@ -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;


>Release-Note:
>Audit-Trail:
>Unformatted:



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