about summary refs log tree commit diff
path: root/Src/parse.c
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-06-18 07:34:34 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-06-18 07:34:34 +0000
commit39e152d2973235b824253bb82619199389dd9c40 (patch)
tree04d7a7ddad7f6c6f011fa991d47cc37479bb2122 /Src/parse.c
parent3c7f60d08479cf4f8da842c3305f8deeedef8031 (diff)
downloadzsh-39e152d2973235b824253bb82619199389dd9c40.tar.gz
zsh-39e152d2973235b824253bb82619199389dd9c40.tar.xz
zsh-39e152d2973235b824253bb82619199389dd9c40.zip
make zcompile unlink() the zwc file first (in case it is currently mapped we don't want to overwrite it); also, create the file read-only (14952)
Diffstat (limited to 'Src/parse.c')
-rw-r--r--Src/parse.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Src/parse.c b/Src/parse.c
index 09e60ead2..dd89ab0cd 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2544,7 +2544,8 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
     if (!strsfx(FD_EXT, dump))
 	dump = dyncat(dump, FD_EXT);
 
-    if ((dfd = open(dump, O_WRONLY|O_CREAT, 0600)) < 0) {
+    unlink(dump);
+    if ((dfd = open(dump, O_WRONLY|O_CREAT, 0444)) < 0) {
 	zwarnnam(nam, "can't write zwc file: %s", dump, 0);
 	return 1;
     }
@@ -2675,7 +2676,8 @@ build_cur_dump(char *nam, char *dump, char **names, int match, int map,
     if (!strsfx(FD_EXT, dump))
 	dump = dyncat(dump, FD_EXT);
 
-    if ((dfd = open(dump, O_WRONLY|O_CREAT, 0600)) < 0) {
+    unlink(dump);
+    if ((dfd = open(dump, O_WRONLY|O_CREAT, 0444)) < 0) {
 	zwarnnam(nam, "can't write zwc file: %s", dump, 0);
 	return 1;
     }
@@ -2779,10 +2781,10 @@ static FuncDump dumps;
 static int
 zwcstat(char *filename, struct stat *buf, FuncDump dumps)
 {
-    FuncDump f;
-    
     if (stat(filename, buf)) {
 #ifdef HAVE_FSTAT
+        FuncDump f;
+    
 	for (f = dumps; f; f = f->next) {
 	    if (!strncmp(filename, f->filename, strlen(f->filename)) &&
 		!fstat(f->fd, buf))