Audit uudecode(1)
Style cleanup, Manpage refactoring.
This commit is contained in:
parent
4af8889396
commit
1b71559431
2
README
2
README
|
@ -84,7 +84,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
|
||||||
#*| unexpand yes none
|
#*| unexpand yes none
|
||||||
=*| uniq yes none
|
=*| uniq yes none
|
||||||
=*| unlink yes none
|
=*| unlink yes none
|
||||||
=* uudecode yes none
|
=*| uudecode yes none
|
||||||
=* uuencode yes none
|
=* uuencode yes none
|
||||||
#* wc yes none
|
#* wc yes none
|
||||||
= xargs no -I, -L, -p, -s, -t, -x
|
= xargs no -I, -L, -p, -s, -t, -x
|
||||||
|
|
24
uudecode.1
24
uudecode.1
|
@ -1,4 +1,4 @@
|
||||||
.Dd February 13, 2015
|
.Dd March 18, 2015
|
||||||
.Dt UUDECODE 1
|
.Dt UUDECODE 1
|
||||||
.Os sbase
|
.Os sbase
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -13,23 +13,27 @@
|
||||||
.Nm
|
.Nm
|
||||||
reads
|
reads
|
||||||
.Ar file
|
.Ar file
|
||||||
(or by default, the standard input) and writes a decoded
|
and writes a decoded version to the file specified in the uuencoded header.
|
||||||
version to the file specified in the uuencoded header. In case that
|
In case the file already exists, it is truncated. Otherwise a new file is
|
||||||
the file already exists, it is truncated. Otherwise a new file is
|
created. The permissions of the created/accessed file are changed to
|
||||||
created. After the operation the permissions of the created/accessed
|
reflect the mode in the header.
|
||||||
are changed to reflect the mode in the header.
|
If no
|
||||||
|
.Ar file
|
||||||
|
is given
|
||||||
|
.Nm
|
||||||
|
reads from stdin.
|
||||||
.Sh OPTIONS
|
.Sh OPTIONS
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Fl m
|
.It Fl m
|
||||||
Use Base64 for decoding.
|
Use Base64 for decoding.
|
||||||
.It Fl o Ar output
|
.It Fl o Ar output
|
||||||
Use the file specified by
|
Write to
|
||||||
.Ar output
|
.Ar output
|
||||||
instead of standard output.
|
rather than the file specified in the header.
|
||||||
.El
|
.El
|
||||||
.Sh IMPLEMENTATION NOTES
|
.Sh IMPLEMENTATION NOTES
|
||||||
For safety currently uudecode operates only on regular files and
|
For safety uudecode operates on regular files and stdout only.
|
||||||
stdout. Trying to uudecode to a link, directory, or special file
|
Trying to uudecode to a link, directory, or special file
|
||||||
yields an error.
|
yields an error.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr uuencode 1
|
.Xr uuencode 1
|
||||||
|
|
19
uudecode.c
19
uudecode.c
|
@ -17,7 +17,7 @@ parsefile(const char *fname)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (strcmp(fname, "/dev/stdout") == 0 || strcmp(fname, "-") == 0)
|
if (!strcmp(fname, "/dev/stdout") || !strcmp(fname, "-"))
|
||||||
return stdout;
|
return stdout;
|
||||||
ret = lstat(fname, &st);
|
ret = lstat(fname, &st);
|
||||||
/* if it is a new file, try to open it */
|
/* if it is a new file, try to open it */
|
||||||
|
@ -32,12 +32,11 @@ parsefile(const char *fname)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tropen:
|
tropen:
|
||||||
return fopen(fname,"w");
|
return fopen(fname, "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parseheader(FILE *fp, const char *s, char **header, mode_t *mode,
|
parseheader(FILE *fp, const char *s, char **header, mode_t *mode, char **fname)
|
||||||
char **fname)
|
|
||||||
{
|
{
|
||||||
char bufs[PATH_MAX + 18]; /* len header + mode + maxname */
|
char bufs[PATH_MAX + 18]; /* len header + mode + maxname */
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
|
@ -74,8 +73,8 @@ parseheader(FILE *fp, const char *s, char **header, mode_t *mode,
|
||||||
static const char b64dt[] = {
|
static const char b64dt[] = {
|
||||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
-1,-1,-1,-1,-1,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
|
-1,-1,-1,-1,-1,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
|
||||||
52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,
|
52,53,54,55,56,57,58,59,60,61,-1,-1,-1, 0,-1,-1,-1, 0, 1, 2, 3, 4, 5, 6,
|
||||||
7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,
|
7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,
|
||||||
-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
|
-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
|
||||||
49,50,51,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
49,50,51,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||||
|
@ -212,7 +211,7 @@ uudecode(FILE *fp, FILE *outfp)
|
||||||
}
|
}
|
||||||
/* check for end or fail */
|
/* check for end or fail */
|
||||||
len = getline(&bufb, &n, fp);
|
len = getline(&bufb, &n, fp);
|
||||||
if (len < 3 || strncmp(bufb, "end", 3) != 0 || bufb[3] != '\n')
|
if (len < 3 || strncmp(bufb, "end", 3) || bufb[3] != '\n')
|
||||||
eprintf("invalid uudecode footer \"end\" not found\n");
|
eprintf("invalid uudecode footer \"end\" not found\n");
|
||||||
free(bufb);
|
free(bufb);
|
||||||
}
|
}
|
||||||
|
@ -227,11 +226,9 @@ int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FILE *fp = NULL, *nfp = NULL;
|
FILE *fp = NULL, *nfp = NULL;
|
||||||
char *fname, *header;
|
|
||||||
const char *ifname;
|
|
||||||
mode_t mode = 0;
|
mode_t mode = 0;
|
||||||
|
char *fname, *header, *ifname, *ofname = NULL;
|
||||||
void (*d) (FILE *, FILE *) = NULL;
|
void (*d) (FILE *, FILE *) = NULL;
|
||||||
char *ofname = NULL;
|
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'm':
|
case 'm':
|
||||||
|
@ -248,7 +245,7 @@ main(int argc, char *argv[])
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if (argc == 0) {
|
if (!argc) {
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
ifname = "<stdin>";
|
ifname = "<stdin>";
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user