From owner-freebsd-bugs@FreeBSD.ORG Thu Nov 19 02:50:02 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FDC81065672 for ; Thu, 19 Nov 2009 02:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 0326A8FC19 for ; Thu, 19 Nov 2009 02:50:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nAJ2o1jt084316 for ; Thu, 19 Nov 2009 02:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id nAJ2o1aB084315; Thu, 19 Nov 2009 02:50:01 GMT (envelope-from gnats) Resent-Date: Thu, 19 Nov 2009 02:50:01 GMT Resent-Message-Id: <200911190250.nAJ2o1aB084315@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jeremy Huddleston Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BDC5106566B for ; Thu, 19 Nov 2009 02:44:46 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 2BAB08FC0C for ; Thu, 19 Nov 2009 02:44:46 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nAJ2ijHM016513 for ; Thu, 19 Nov 2009 02:44:45 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id nAJ2ij5C016512; Thu, 19 Nov 2009 02:44:45 GMT (envelope-from nobody) Message-Id: <200911190244.nAJ2ij5C016512@www.freebsd.org> Date: Thu, 19 Nov 2009 02:44:45 GMT From: Jeremy Huddleston To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/140690: swab() with negative len should do nothing X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2009 02:50:02 -0000 >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: