Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/bin/csh Pullup 1.15 [christos]:



details:   https://anonhg.NetBSD.org/src/rev/4622aff317d2
branches:  netbsd-1-5
changeset: 490066:4622aff317d2
user:      tv <tv%NetBSD.org@localhost>
date:      Wed Nov 01 03:51:28 2000 +0000

description:
Pullup 1.15 [christos]:
Avoid turning into a random file writing tool when using here-doc's.
Reported to BUGTRAQ by proton <proton%ENERGYMECH.NET@localhost>.

diffstat:

 bin/csh/dol.c |  17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r 1b23ef8d140a -r 4622aff317d2 bin/csh/dol.c
--- a/bin/csh/dol.c     Wed Nov 01 03:44:32 2000 +0000
+++ b/bin/csh/dol.c     Wed Nov 01 03:51:28 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dol.c,v 1.14 2000/05/31 22:48:45 christos Exp $        */
+/*     $NetBSD: dol.c,v 1.14.2.1 2000/11/01 03:51:28 tv Exp $  */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)dol.c      8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: dol.c,v 1.14 2000/05/31 22:48:45 christos Exp $");
+__RCSID("$NetBSD: dol.c,v 1.14.2.1 2000/11/01 03:51:28 tv Exp $");
 #endif
 #endif /* not lint */
 
@@ -853,10 +853,21 @@
     Char  **vp;
     bool    quoted;
     char   *tmp;
+    struct timeval tv;
 
+again:
     tmp = short2str(shtemp);
-    if (open(tmp, O_RDWR | O_CREAT | O_TRUNC, 0600) < 0)
+    if (open(tmp, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600) < 0) {
+       if (errno == EEXIST) {
+           if (unlink(tmp) == -1) {
+               (void) gettimeofday(&tv, NULL);
+               shtemp = Strspl(STRtmpsh, putn((((int)tv.tv_sec) ^ 
+                   ((int)tv.tv_usec) ^ ((int)doldol)) & 0x00ffffff));
+           }
+           goto again;
+       }
        stderror(ERR_SYSTEM, tmp, strerror(errno));
+    }
     (void) unlink(tmp);                /* 0 0 inode! */
     Dv[0] = term;
     Dv[1] = NULL;



Home | Main Index | Thread Index | Old Index