Use mkstemp(3) instead of tmpnam(3) when creating temporary files for mode

page editing.

Submitted by:	roberto
Reviewed by:	imp, ken
This commit is contained in:
ken 1999-09-28 02:01:46 +00:00
parent 738e2698d7
commit 54e1a5844c
2 changed files with 12 additions and 6 deletions

View File

@ -291,10 +291,13 @@ edit_done(void)
static void
edit_init(void)
{
int fd;
edit_rewind();
if (tmpnam(edit_name) == 0)
errx(1, "tmpnam failed");
if ((edit_file = fopen(edit_name, "w")) == 0)
strlcpy(edit_name, "/tmp/camXXXXXX", sizeof(edit_name));
if ((fd = mkstemp(edit_name)) == -1)
errx(1, "mkstemp failed");
if ((edit_file = fdopen(fd, "w")) == 0)
err(1, "%s", edit_name);
edit_opened = 1;

View File

@ -291,10 +291,13 @@ edit_done(void)
static void
edit_init(void)
{
int fd;
edit_rewind();
if (tmpnam(edit_name) == 0)
errx(1, "tmpnam failed");
if ((edit_file = fopen(edit_name, "w")) == 0)
strlcpy(edit_name, "/tmp/camXXXXXX", sizeof(edit_name));
if ((fd = mkstemp(edit_name)) == -1)
errx(1, "mkstemp failed");
if ((edit_file = fdopen(fd, "w")) == 0)
err(1, "%s", edit_name);
edit_opened = 1;