From e7f41abf9da22e8e0307f4c8d1f9e3a4808c6490 Mon Sep 17 00:00:00 2001 From: fanf Date: Tue, 10 Sep 2002 18:28:19 +0000 Subject: 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 --- usr.bin/uudecode/uudecode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'usr.bin/uudecode/uudecode.c') 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); } -- cgit v1.1