diff options
author | Tony Finch <fanf@FreeBSD.org> | 2002-09-10 18:28:19 +0000 |
---|---|---|
committer | Tony Finch <fanf@FreeBSD.org> | 2002-09-10 18:28:19 +0000 |
commit | 1e4cc3412201697ab45b1050670af32106dc1b6d (patch) | |
tree | f6971d84f1c4a927c68ceae89bb1d1f96b99c52b /usr.bin/uudecode | |
parent | 257446b9b26cf6d576c03c839bdd96a3c5de3258 (diff) | |
download | src-1e4cc3412201697ab45b1050670af32106dc1b6d.tar.gz src-1e4cc3412201697ab45b1050670af32106dc1b6d.zip |
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
Notes
Notes:
svn path=/head/; revision=103194
Diffstat (limited to 'usr.bin/uudecode')
-rw-r--r-- | usr.bin/uudecode/uudecode.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/uudecode/uudecode.c b/usr.bin/uudecode/uudecode.c index 270d0557f17e..134bc7f386bb 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); } |