Commit Graph

53 Commits

Author SHA1 Message Date
obrien
2a8f1d64a1 Make GCC 3.3 happy with rcsid[], sccs[], and copyright[]. 2003-05-03 19:44:46 +00:00
fanf
4bb74a4762 The POSIXly-correct /dev/stdout handling added in rev 1.44 makes
careless users vulnerable to terminal control sequence attacks,
since they expect uudecode to just drop (or overwrite) a file in
the current directory. POSIX also says that the full pathname from
the input should be used when writing a file, which we only do if
the -s (shoot me in the foot) option is specified; therefore this
revision means that you now need to use -s for standard /dev/stdout
handling.
2003-03-18 14:19:26 +00:00
fanf
d943cf7d51 Don't complain about an early end-of-file in the -r case rather than
the opposite. Does this pointy hat look good on me?
2003-03-04 21:22:05 +00:00
fanf
860333542f Pull some common uu/b64 code out into shared functions. Move some
end-of-file checks out of the inner base64 loop, and remove the
trailing whitespace stripper. The latter was added in rev 1.23 but
the actual fix for the problem was in 1.24 -- b64_pton doesn't mind
extra whitespace. (However there's a bogus comment in OpenSSH's
uuencode.c that also mentions problems with trailing whitespace and
b64_pton, but their real problem is the comment field in the key
file.)
2003-02-27 05:59:18 +00:00
fanf
d90bc6c932 Add a relaxed mode for handling raw input which is missing the
initial and possibly the final framing lines. This is particularly
handy for dealing with broken files or fragments of MIME messages.
2003-02-27 03:28:29 +00:00
fanf
2e51ade059 Be POSIXly correct in the handling of /dev/stdout -- it's a "magic cookie"
not a special file.
2003-02-27 02:24:01 +00:00
fanf
c1d0f70dee Variables that come in in and out pairs should be named accordingly.
Different code that processes the input in similar ways should be
called in similar ways. File-local stuff should be static. Output
errors should be checked for. Diffs sometimes have to be big.
2002-11-01 02:08:51 +00:00
fanf
c467150777 Be much more paranoid about where uudecode writes its output, especially
when the filename comes from the untrusted input. This is a work-around
for careless people who don't routinely check the begin line of the file
or run uudecode -i and instead report "vulnerabilities" to CERT.
	http://www.kb.cert.org/vuls/id/336083
2002-11-01 00:58:00 +00:00
fanf
760e63e6f7 Instead of abusing stdin and stdout, use our own file pointers.
Check for errors when closing the output.
2002-11-01 00:29:00 +00:00
mike
ee94c6be46 Some uses of the variable n needed to be int, others needed to be
size_t.  Add a new variable to cope.
2002-09-11 04:26:09 +00:00
mike
6c06606f5b Unbreak world by fixing 4 syntax errors and 1 wrong variable type. 2002-09-11 01:00:56 +00:00
fanf
c01083a28d Fix style bugs in macros. 2002-09-10 21:14:14 +00:00
fanf
2ce47bcfdf Tidy up the base64 code and relax the error handling. 2002-09-10 21:10:33 +00:00
fanf
5cb3e55396 Style: Don't treat pointers as booleans. 2002-09-10 20:53:46 +00:00
fanf
0df46c2bed Fix tilde-expansion of the filename obtained from the "begin" line in -s
mode, and be more accurate about identifying begin lines so that spurious
ones don't have to be manually edited out, and be more forgiving about
errors so that -c mode is more useful.
2002-09-10 20:48:44 +00:00
fanf
02ac4ff9b2 Replace a goto with continue. 2002-09-10 20:33:39 +00:00
fanf
c5e31d5ee6 Remove register keyword. 2002-09-10 19:23:44 +00:00
fanf
ec1f90b434 Style: space after return. 2002-09-10 18:52:03 +00:00
fanf
f0b6e43cfb Make the handling of -i neater. 2002-09-10 18:34:07 +00:00
fanf
e7f41abf9d Only try to chmod the output if it's a regular file, rather than
hard-coding /dev/stdout as a special case.

Suggested by:	jmallett
2002-09-10 18:28:19 +00:00
fanf
e442c885fb Don't try (and fail) to fchmod /dev/stdout. Revert the manual page
to suggest the portable alternative to -p.

PR:		42356
Submitted by:	Kimura Fuyuki <fuyuki@hadaly.org>
MFC after:	1 week
2002-09-03 19:37:23 +00:00
fanf
e43529519e Remove spurious whitespace 2002-09-03 09:58:11 +00:00
jmallett
073610e016 Synch usage() and manpage for b64encode/b64decode.
Make uudecode's usage more like that of other programs.
2002-05-19 11:22:54 +00:00
jmallett
1fb080cae2 Add b64decode & b64encode as synonyms for uudecode and uuencode -m,
respectively, for convenience when encoding or decoding base64 files.

As requested by various users.
2002-05-19 11:17:17 +00:00
mike
497f9fbf89 Finish converting the rest of the function declaration and prototypes
to ANSI C.  Use new source ID scheme.
2002-05-12 03:56:34 +00:00
alfred
1481568735 unbreak build:
K&R style main() makes gcc emit a warning about missing prototypes so
switch to ANSI.
2002-05-11 03:29:04 +00:00
jmallett
45274f1785 Use fwrite(3) to write out the decoded information, as the b64 decoding stuff
won't NUL terminate the string for us, and so we're liable to pick up trailing
garbage, possibly tons of it.

Pointed out by:	obrien
MFC after:	3 days
2002-04-20 03:33:40 +00:00
jmallett
64ae9117d8 base64_decode() was feeding \r and \n to the decoding function, and that
was causing output to be corrupted.

Pointed out by:	obrien
MFC after:	3 days
2002-04-20 02:33:30 +00:00
jmallett
439a2b1e90 Bump WARNS to 4. 2002-04-20 00:20:54 +00:00
imp
0b20191705 remove __P 2002-03-22 01:42:45 +00:00
jmallett
f350e51990 Fix handling of filenames with spaces in them in the input file to
uudecode(1), as this behaviour was explicitly added in revision 1.12 as
the result of PR 2882.  Remove space (' ') from the delimiter characters
handed to strtok(3).

Reviewed by:	mike
Approved by:	mike
Pointy hat to:	me
2002-03-19 02:05:27 +00:00
jmallett
a67e26bc7a Make uudecode(1) use setmode(3) and getmode(3) instead of just blindly
chmodding using an octal mode, as uudecode needs to handle symbolic modes
as chmod and such do.

Suggested by:	Tim J. Robbins <tim@robbins.id.au>

Also move meta-character (~ in this case) globbing to only if we are reading
the filename from the encoded file, as otherwise it is the shell's job.

Reviewed by:	mike
Approved by:	mike
2002-03-19 00:44:07 +00:00
jmallett
ce51fff754 Add base64 support to uuencode(1) and uudecode(1), as specified by SUSv3.
Add `-o' option to uuencode(1) to pipe the uuencoded output to an
arbitrary file, instead of just stdout.

Reviewed by:	-standards, mike
Approved by:	mike
2002-03-05 03:27:47 +00:00
mike
d2b2c3be4c Un-deprecate the -p option. We now have two ways to output to stdout:
`-o /dev/stdout' or `-p'.

Requested by:	grog, nectar
2002-02-16 09:18:33 +00:00
mike
7e26e18582 Add -o option (POSIX.1-2001) to uudecode(1). Deprecate the -p option
(which allows one to redirect output to stdout); `-o /dev/stdout' is
recommended instead.

Submitted by:	Joseph Mallett <jmallett@xMach.org>
MFC after:	2 weeks
2002-01-27 18:21:23 +00:00
markm
59796f812d WARNS=2 is to become the default, so remove it from here. 2001-12-11 23:14:43 +00:00
dwmalone
d9613ea383 Style improvements recommended by Bruce as a follow up to some
of the recent WARNS commits. The idea is:

1) FreeBSD id tags should follow vendor tags.
2) Vendor tags should not be compiled (though copyrights probably should).
3) There should be no blank line between including cdefs and __FBSDIF.
2001-12-10 21:13:08 +00:00
dwmalone
56460a2eb0 Warns cleanup. Add FreeBSD ID to Makefile. 2001-12-03 21:39:04 +00:00
sheldonh
98310ba5f0 While I'm in here, remove an unused variable.
Submitted by:	Nathan Ahlstrom <nrahlstr@winternet.com>
2000-03-30 09:23:28 +00:00
sheldonh
5f2d618ecb Do not overwrite files when the -i option is specified!
PR:		17476
Reported by:	Jonathan Chen <jon@spock.org>
2000-03-27 11:49:36 +00:00
peter
3b842d34e8 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
steve
75cfd8e8c2 Allow spaces in the filename to be decoded to.
PR:		4882
Submitted by:	Slaven Rezic <eserte@cs.tu-berlin.de>
1998-05-25 06:27:09 +00:00
wosch
813f372ef3 Add two new options:
-i     Do not overwrite files.

     -s     Do not strip output pathname to base filename. By default uuencode
	    deletes any prefix ending with the last slash '/' for security
	    purpose.
1998-01-25 19:26:05 +00:00
phk
d8ac409160 Many places in the code NULL is used in integer context, where
plain 0 should be used.  This happens to work because we #define
NULL to 0, but is stylistically wrong and can cause problems
for people trying to port bits of code to other environments.

PR:		2752
Submitted by:	Arne Henrik Juul <arnej@imf.unit.no>
1997-09-18 14:08:40 +00:00
charnier
40cf595fb5 Use err(3). 1997-08-22 06:53:00 +00:00
imp
141381e1cb compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
wosch
6f2f806e06 Be tolerant to old uuencode programs which encode the ASCII NUL
character as character 32 (space) instead character 64 (`).

See also  'The UNIX-HATERS Handbook', page 82-83.
1997-03-25 14:31:31 +00:00
wosch
adc9806068 Treat 'end\0', 'end\n', 'end\r\n' as trailer line, see rev 1.2 1997-02-18 20:19:04 +00:00
wosch
ed135aa973 Better check for detecting header line. A header line must match
"begin [0-7]* *". Now `begin with, ' is not a header line.

Do a boundary check for body characters. Characters less than 33 or
greater than 96 are out of range. If characters are out of range
uudecode print a error message and die.
1997-02-18 17:49:43 +00:00
wosch
ff1e30c98b New options for uudecode
-p Decode file and write output to standard output.
	-c Decode more than one uuencode'd file from file if possible.
1996-10-21 22:02:30 +00:00