From nobody@FreeBSD.org  Sat Dec 18 19:17:58 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 023631065670
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 18 Dec 2010 19:17:58 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id E567A8FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 18 Dec 2010 19:17:57 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id oBIJHvG2032808
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 18 Dec 2010 19:17:57 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id oBIJHvsE032807;
	Sat, 18 Dec 2010 19:17:57 GMT
	(envelope-from nobody)
Message-Id: <201012181917.oBIJHvsE032807@red.freebsd.org>
Date: Sat, 18 Dec 2010 19:17:57 GMT
From: David Brennan <freebsd@brennanhome.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: uudecode error message is incorrect
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         153276
>Category:       bin
>Synopsis:       [patch] uudecode(1) error message is incorrect
>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:   Sat Dec 18 19:20:08 UTC 2010
>Closed-Date:    
>Last-Modified:  Sat Dec 18 19:58:13 UTC 2010
>Originator:     David Brennan
>Release:        OS X.6.5
>Organization:
>Environment:
Darwin clifford.local 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov  5 23:20:39 PDT 2010; root:xnu-1504.9.17~1/RELEASE_I386 i386

>Description:
I discovered this problem on my OS X machine, and I am just trying to pass the information upstream as I see it also exists in the FreeBSD source code.

When using uudecode, if an improper character is detected, the error message that is printed does not match the actual error. The problem is that the IS_DEC macro allows character 32-96 inclusive. But the error message says that the allowed characters are 33-96. This caused me some trouble in diagnosing a problem with an external uuencode system.


#define IS_DEC(c)	 ( (((c) - ' ') >= 0) && (((c) - ' ') <= 077 + 1) )

#define OUT_OF_RANGE do {						\
	warnx("%s: %s: character out of range: [%d-%d]",		\
	    infile, outfile, 1 + ' ', 077 + ' ' + 1);			\

As you can see, the error message includes a 1 + ' ', which this IS_DEC macro does not have.

>How-To-Repeat:
This only occurs with an improperly formatted file. Here is a simple way to improperly format a file.
$ echo "This is a test" >temp.txt
$ uuencode -o temp.uu temp.txt temp.txt
$ cat temp.uu
begin 644 temp.txt
/5&AI<R!I<R!A('1E<W0*
`
end

$ sed 's/^`$//' temp.uu | uudecode
uudecode: 
    input file: stdin
    encoded file: temp.txt
    character out of range: [33-96]


>Fix:
#define OUT_OF_RANGE do {						\
	warnx("%s: %s: character out of range: [%d-%d]",		\
	    infile, outfile, ' ', 077 + ' ' + 1);			\

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