diff --git a/usr.bin/bintrans/uudecode.c b/usr.bin/bintrans/uudecode.c --- a/usr.bin/bintrans/uudecode.c +++ b/usr.bin/bintrans/uudecode.c @@ -184,6 +184,7 @@ static int decode2(void) { + const char *routfile = outfile; int flags, fd, mode; size_t n, m; char *p, *q; @@ -259,28 +260,28 @@ q = p + 1; } if (!oflag) - outfile = q; + routfile = q; /* POSIX says "/dev/stdout" is a 'magic cookie' not a special file. */ - if (pflag || strcmp(outfile, "/dev/stdout") == 0) + if (pflag || strcmp(routfile, "/dev/stdout") == 0) outfp = stdout; else { flags = O_WRONLY | O_CREAT | O_EXCL; - if (lstat(outfile, &st) == 0) { + if (lstat(routfile, &st) == 0) { if (iflag) { - warnc(EEXIST, "%s: %s", infile, outfile); + warnc(EEXIST, "%s: %s", infile, routfile); return (0); } switch (st.st_mode & S_IFMT) { case S_IFREG: case S_IFLNK: /* avoid symlink attacks */ - if (unlink(outfile) == 0 || errno == ENOENT) + if (unlink(routfile) == 0 || errno == ENOENT) break; - warn("%s: unlink %s", infile, outfile); + warn("%s: unlink %s", infile, routfile); return (1); case S_IFDIR: - warnc(EISDIR, "%s: %s", infile, outfile); + warnc(EISDIR, "%s: %s", infile, routfile); return (1); default: if (oflag) { @@ -288,16 +289,16 @@ flags &= ~O_EXCL; break; } - warnc(EEXIST, "%s: %s", infile, outfile); + warnc(EEXIST, "%s: %s", infile, routfile); return (1); } } else if (errno != ENOENT) { - warn("%s: %s", infile, outfile); + warn("%s: %s", infile, routfile); return (1); } - if ((fd = open(outfile, flags, mode)) < 0 || + if ((fd = open(routfile, flags, mode)) < 0 || (outfp = fdopen(fd, "w")) == NULL) { - warn("%s: %s", infile, outfile); + warn("%s: %s", infile, routfile); return (1); } }