This is based on the following:
===
Submitted By: LFS Book <lfs-book@linuxfromscratch.org>
Date: 2003-10-05
Initial Package Version: 0.2
Origin: Slackware Source
Description: Use mkstemp instead of mktemp.
===
However the original patch contained an error.
mkstemp returns a file description, so when fopen ran, the file was opened twice.
The correct change is to use fdopen with mkstemp.
See gentoo bug #73858.
diff -Naur ed-0.2/buf.c ed-0.2-2/buf.c
old
|
new
|
|
200 | 200 | int |
201 | 201 | open_sbuf () |
202 | 202 | { |
203 | | char *mktemp (); |
204 | | int u; |
| 203 | int u, sfd; |
205 | 204 | |
206 | 205 | isbinary = newline_added = 0; |
207 | 206 | u = umask(077); |
208 | 207 | strcpy (sfn, "/tmp/ed.XXXXXX"); |
209 | | if (mktemp (sfn) == NULL || (sfp = fopen (sfn, "w+")) == NULL) |
| 208 | sfd = mkstemp(sfn); |
| 209 | if ((sfd == -1) || (sfp = fdopen (sfd, "w+")) == NULL) |
210 | 210 | { |
211 | 211 | fprintf (stderr, "%s: %s\n", sfn, strerror (errno)); |
212 | 212 | sprintf (errmsg, "Cannot open temp file"); |