Blob Blame History Raw
--- src/pawlib/paw/stagerd/child.c.old	2003-04-23 23:46:07.000000000 +0200
+++ src/pawlib/paw/stagerd/child.c	2003-04-24 17:36:50.000000000 +0200
@@ -65,16 +65,21 @@
     fname = dir;
     fdir = (char *)0;
   }
-
+  
+#if 0
   strcpy(tmp,tmppath);
   strcat(tmp,TMP_TEMPLATE);
   mktemp(tmp);
+#endif
 
   /* builtin ftp client */
-
+  /* Fixed to use tmpfile() rather than the insecure mktemp()
+     -- Kevin McCarty, for Debian, 24 April 2003 */
+  
   if (bftp.bf_bufsize > 0) {
-    if (!(f = fopen(tmp,"w"))) {
-      errlog(LOG_ERR,"c_ftp_client() : can't open %s",tmp);
+    if (!(f = tmpfile())) {
+      errlog(LOG_ERR,"c_ftp_client() : tmpfile() failed : %s",
+	     strerror(errno););
       return SGD_RET_FOPEN;
     }
     ret = ftp_ftp(f,cl_dat,st_dat,fdir,fname);
@@ -142,15 +147,20 @@
     FILE *f;
     char tmp[PATH_MAX + 1], *s;
 
+#if 0
     strcpy(tmp,tmppath);
     strcat(tmp,TMP_TEMPLATE);
     mktemp(tmp);
+#endif
 
     /* builtin ftp client */
+    /* Fixed to use tmpfile() rather than the insecure mktemp()
+       -- Kevin McCarty, for Debian, 24 April 2003 */
 
     if (bftp.bf_bufsize > 0) {
-      if (!(f = fopen(tmp,"w"))) {
-        errlog(LOG_ERR,"c_stage_tape() : can't open %s",tmp);
+      if (!(f = tmpfile())) {
+        errlog(LOG_ERR,"c_stage_tape() : tmpfile() failed : %s",
+	       strerror(errno));
         return SGD_RET_FOPEN;
       }
       ret = ftp_clio(f,cl_dat,st_dat,volid,fseqid,lbltyp,volser);
--- src/packlib/kuip/programs/kxterm/kxterm.c.old	2003-08-19 17:38:06.000000000 -0400
+++ src/packlib/kuip/programs/kxterm/kxterm.c	2003-08-20 13:36:56.000000000 -0400
@@ -645,10 +645,9 @@
 void exit_kxterm()
 {
    /* close transcript file and if it is a tmp file remove it */
+   /* (the result of tmpfile() is removed automatically upon being closed) */
    if (tfp) {
       fclose(tfp);
-      if (tr_tmp_file)
-         remove(transcript_file);
    }
 
    exit(0);
@@ -1168,32 +1167,34 @@
      char *file;
 {
    /*
-    * close the tmp file, move it to user specified file and open it again
+    * copy the temp file to user specified file, close temp file and open
+    * user specified file again
     */
    if (tfp) {
       fflush(tfp);
       if (!strcmp(transcript_file, file))
          return;
       else {
-         char line[256];
+         char line[MAX_FILE_LENGTH + 50];
+	 FILE *stream;
 
-         fclose(tfp);
-         if (!(tfp = fopen(file, "w"))) {
+         if (!(stream = fopen(file, "w"))) {
             sprintf(line, "Cannot open transcript file %s",
                     file);
             warn_user(kuipIo, line);
          }
          else {
             /* copy current transcript to new file */
-            FILE *stream = fopen(transcript_file, "r");
-            while( fgets( line, (sizeof line), stream ) != NULL )
-               fputs( line, tfp );
-            fclose( stream );
-
+	    rewind( tfp );
+            while( fgets( line, (sizeof line), tfp ) != NULL )
+               fputs( line, stream );
+	    fclose( stream );
+            fclose( tfp );
+	    tfp = fopen(file, "a+");
+            strcpy(transcript_file, file);
+	    
             if (tr_tmp_file) {
-               remove(transcript_file);
                tr_tmp_file = False;
-               strcpy(transcript_file, file);
             }
             fflush(tfp);
          }
@@ -2684,15 +2685,19 @@
    init_kuipio();
 
    /* open tmpfile to save transcript pad */
-   tmpnam(transcript_file);
-   if (!(tfp = fopen(transcript_file, "w+"))) {
+   if (!(tfp = tmpfile())) {
       insert_string(outputText,
                     "*** Cannot open tmp file to save transcript pad ***\n",
                     False);
       XtSetSensitive(saveTransButton, False);
       XtSetSensitive(saveTransAsButton, False);
-   } else
+   }
+   else {
       tr_tmp_file = True;
+      /* since we don't know the filename created by tmpfile(), make it
+       * the null string: */
+      strcpy(transcript_file, "");
+   }
 
    /* unbuffered I/O */
    setbuf(stdin,  NULL);