summaryrefslogtreecommitdiffstats
path: root/usr.bin/uudecode/uudecode.c
diff options
context:
space:
mode:
authorfanf <fanf@FreeBSD.org>2002-09-10 18:28:19 +0000
committerfanf <fanf@FreeBSD.org>2002-09-10 18:28:19 +0000
commite7f41abf9da22e8e0307f4c8d1f9e3a4808c6490 (patch)
treef6971d84f1c4a927c68ceae89bb1d1f96b99c52b /usr.bin/uudecode/uudecode.c
parent1f3c15fd943f608a0ed05da3eea370d3802ff8ab (diff)
downloadFreeBSD-src-e7f41abf9da22e8e0307f4c8d1f9e3a4808c6490.zip
FreeBSD-src-e7f41abf9da22e8e0307f4c8d1f9e3a4808c6490.tar.gz
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
Diffstat (limited to 'usr.bin/uudecode/uudecode.c')
-rw-r--r--usr.bin/uudecode/uudecode.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/uudecode/uudecode.c b/usr.bin/uudecode/uudecode.c
index 270d055..134bc7f 100644
--- a/usr.bin/uudecode/uudecode.c
+++ b/usr.bin/uudecode/uudecode.c
@@ -96,8 +96,6 @@ main(int argc, char *argv[])
oflag = 1; /* output to the specified file */
sflag = 1; /* do not strip pathnames for output */
outfile = optarg; /* set the output filename */
- if (strcmp(outfile, "/dev/stdout") == 0)
- pflag = 1;
break;
case 'p':
if (oflag)
@@ -163,6 +161,7 @@ decode2(int flag)
char buffn[MAXPATHLEN+1]; /* file name buffer */
char *mode, *s;
void *mode_handle;
+ struct stat st;
base64 = ignore = 0;
/* search for header line */
@@ -242,8 +241,9 @@ decode2(int flag)
if (iflag && !access(buf, F_OK)) {
(void)fprintf(stderr, "not overwritten: %s\n", buf);
ignore++;
- } else if (!freopen(buf, "w", stdout) ||
- fchmod(fileno(stdout), getmode(mode_handle, 0) & 0666)) {
+ } else if (freopen(buf, "w", stdout) == NULL ||
+ stat(buf, &st) < 0 || (S_ISREG(st.st_mode) &&
+ fchmod(fileno(stdout), getmode(mode_handle, 0) & 0666))) {
warn("%s: %s", buf, filename);
return(1);
}
OpenPOWER on IntegriCloud