--- cscope-15.5/src/main.c.orig 2007-03-05 11:59:08.000000000 -0500 +++ cscope-15.5/src/main.c 2007-03-05 11:59:33.000000000 -0500 @@ -102,6 +102,7 @@ BOOL select_large = NO; /* enable more t #endif char temp1[PATHLEN + 1]; /* temporary file name */ char temp2[PATHLEN + 1]; /* temporary file name */ +char tempdirpv[PATHLEN +1]; /* private temp directory */ long totalterms; /* total inverted index terms */ BOOL trun_syms; /* truncate symbols to 8 characters */ char tempstring[8192]; /* use this as a buffer, instead of 'yytext', @@ -138,6 +139,7 @@ main(int argc, char **argv) pid_t pid; struct stat stat_buf; struct sigaction winch_action; + mode_t orig_umask; yyin = stdin; yyout = stdout; @@ -337,9 +339,18 @@ lastarg: } /* create the temporary file names */ + orig_umask = umask(S_IRWXG|S_IRWXO); pid = getpid(); - (void) sprintf(temp1, "%s/cscope%d.1", tmpdir, pid); - (void) sprintf(temp2, "%s/cscope%d.2", tmpdir, pid); + (void) sprintf(tempdirpv, "%s/cscope.%d", tmpdir, pid); + if(mkdir(tempdirpv,S_IRWXU)) + { + fprintf(stderr, "cscope: Could not create private temp dir %s\n",tempdirpv); + myexit(1); + } + umask(orig_umask); + + (void) sprintf(temp1, "%s/cscope.1", tempdirpv, pid); + (void) sprintf(temp2, "%s/cscope.2", tempdirpv, pid); /* if running in the foreground */ if (signal(SIGINT, SIG_IGN) != SIG_IGN) { @@ -847,6 +858,7 @@ myexit(int sig) if (temp1[0] != '\0') { (void) unlink(temp1); (void) unlink(temp2); + (void) rmdir(tempdirpv); } /* restore the terminal to its original mode */ if (incurses == YES) {