# DIY Linux Patch
Date: 2005-01-18
Author: See Upstream Status
Origin: http://savannah.gnu.org/patch/download.php?item_id=3628&item_file_id=4021
Maker: Greg Schafer <gschafer@zip.com.au>
Upstream Status: http://savannah.gnu.org/patch/?func=detailitem&item_id=3628
Description: Fix security issue. 

diff -Naur ed-0.2.orig/buf.c ed-0.2/buf.c
--- ed-0.2.orig/buf.c	1994-11-19 12:37:59.000000000 +0000
+++ ed-0.2/buf.c	2005-01-18 09:09:14.068699752 +0000
@@ -200,13 +200,13 @@
 int
 open_sbuf ()
 {
-  char *mktemp ();
-  int u;
+  int u, sfd;
 
   isbinary = newline_added = 0;
   u = umask(077);
   strcpy (sfn, "/tmp/ed.XXXXXX");
-  if (mktemp (sfn) == NULL || (sfp = fopen (sfn, "w+")) == NULL)
+  sfd = mkstemp(sfn);
+  if ((sfd == -1) || (sfp = fdopen (sfd, "w+")) == NULL)
     {
       fprintf (stderr, "%s: %s\n", sfn, strerror (errno));
       sprintf (errmsg, "Cannot open temp file");
