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: bin/97485: [Patch] Incorrect conversion in a64l(3) Message-ID: <20060518230326.K24316@antec.home> Resent-Message-ID: <200605190610.k4J6AE4X045577@freefall.freebsd.org>
index | next in thread | raw e-mail
>Number: 97485
>Category: bin
>Synopsis: [Patch] Incorrect conversion in a64l(3)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri May 19 06:10:13 GMT 2006
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060518230326.K24316>
