From mbsd@pacbell.net  Fri May 19 06:06:15 2006
Return-Path: <mbsd@pacbell.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9CBFA16A421
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 May 2006 06:06:15 +0000 (UTC)
	(envelope-from mbsd@pacbell.net)
Received: from ylpvm01.prodigy.net (ylpvm01-ext.prodigy.net [207.115.57.32])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 07B7D43D45
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 May 2006 06:06:14 +0000 (GMT)
	(envelope-from mbsd@pacbell.net)
Received: from pimout5-ext.prodigy.net (pimout5-int.prodigy.net [207.115.4.21])
	by ylpvm01.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id k4J66ApW015192
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 May 2006 02:06:10 -0400
Received: from antec (ppp-71-139-49-46.dsl.snfc21.pacbell.net [71.139.49.46])
	by pimout5-ext.prodigy.net (8.13.6 out.dk/8.13.6) with ESMTP id k4J666Dp265862
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 19 May 2006 02:06:10 -0400
Message-Id: <20060518230326.K24316@antec.home>
Date: Thu, 18 May 2006 23:06:03 -0700 (PDT)
From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= <mbsd@pacbell.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [Patch] Incorrect conversion in a64l(3)

>Number:         97485
>Category:       bin
>Synopsis:       [Patch] Incorrect conversion in a64l(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jkim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 19 06:10:13 GMT 2006
>Closed-Date:    Wed May 24 18:17:28 GMT 2006
>Last-Modified:  Wed May 24 18:17:28 GMT 2006
>Originator:     Mikko Tyolajarvi
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
>Environment:
System: FreeBSD antec.home 6.1-STABLE FreeBSD 6.1-STABLE #10: Sun May 14 15:21:09 PDT 2006 mikko@antec.home:/x/usr/obj/usr/src/sys/ANTEC i386

 	The problem exists in both 6.1 and 7-current.

>Description:

 	Any string containing a "/" character is decoded incorrectly.

 	For example, the string "/" should decode to the value 1 (it
 	even says so in the man page), but on FreeBSD the result is 3.

>How-To-Repeat:

 	#include <assert.h>
 	int main()
 	{
 		assert(a64l("/") == 1);
 		return 0;
 	}

>Fix:

Here are some suggestions, all of which work:

1)
--- a64l.c.orig	Thu May 18 22:55:23 2006
+++ a64l.c	Thu May 18 22:55:35 2006
@@ -16,7 +16,7 @@
  #include <inttypes.h>

  #define	ADOT	46		/* ASCII '.' */
-#define	ASLASH	ADOT + 1	/* ASCII '/' */
+#define	ASLASH	(ADOT + 1)	/* ASCII '/' */
  #define	A0	48		/* ASCII '0' */
  #define	AA	65		/* ASCII 'A' */
  #define	Aa	97		/* ASCII 'a' */


2)
--- a64l.c.orig	Thu May 18 22:55:23 2006
+++ a64l.c	Thu May 18 22:56:25 2006
@@ -16,7 +16,7 @@
  #include <inttypes.h>

  #define	ADOT	46		/* ASCII '.' */
-#define	ASLASH	ADOT + 1	/* ASCII '/' */
+#define	ASLASH	47		/* ASCII '/' */
  #define	A0	48		/* ASCII '0' */
  #define	AA	65		/* ASCII 'A' */
  #define	Aa	97		/* ASCII 'a' */

3)
--- a64l.c.orig	Thu May 18 22:55:23 2006
+++ a64l.c	Thu May 18 22:57:47 2006
@@ -31,7 +31,7 @@
  	shift = 0;
  	for (i = 0; *s != '\0' && i < 6; i++, s++) {
  		if (*s <= ASLASH)
-			digit = *s - ASLASH + 1;
+			digit = *s - ADOT;
  		else if (*s <= A0 + 9)
  			digit = *s - A0 + 2;
  		else if (*s <= AA + 25)

4)
Use the unmodified code from NetBSD.


   $.02,
   /Mikko
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jkim 
Responsible-Changed-By: jkim 
Responsible-Changed-When: Fri May 19 19:00:42 UTC 2006 
Responsible-Changed-Why:  
I will take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=97485 
State-Changed-From-To: open->patched 
State-Changed-By: jkim 
State-Changed-When: Fri May 19 19:04:55 UTC 2006 
State-Changed-Why:  
Committed.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=97485 
State-Changed-From-To: patched->closed 
State-Changed-By: jkim 
State-Changed-When: Wed May 24 18:16:45 UTC 2006 
State-Changed-Why:  
MFC'd to RELENG_6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=97485 
>Unformatted:
