From 5e16bd277e3e9bc19d738563027794b0459a54ee Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Sun, 25 May 1997 02:48:29 +0000 Subject: [PATCH] Use mkstemp. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1767 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/popper/pop_dropcopy.c | 3 +-- appl/popper/pop_xmit.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/appl/popper/pop_dropcopy.c b/appl/popper/pop_dropcopy.c index 9f067d851..d1c78d9a3 100644 --- a/appl/popper/pop_dropcopy.c +++ b/appl/popper/pop_dropcopy.c @@ -41,8 +41,7 @@ pop_dropcopy(POP *p, struct passwd *pwp) /* First create a unique file. Would prefer mkstemp, but Ultrix...*/ strcpy(template,POP_TMPDROP); - mktemp(template); - if ( (tf=fopen(template,"w+")) == NULL ) { /* failure, bail out */ + if ((tf=fdopen(mkstemp(template),"w+")) == NULL) { /* failure, bail out */ pop_log(p,POP_PRIORITY, "Unable to create temporary temporary maildrop '%s': %s",template, strerror(errno)); diff --git a/appl/popper/pop_xmit.c b/appl/popper/pop_xmit.c index b73172086..88c43e13b 100644 --- a/appl/popper/pop_xmit.c +++ b/appl/popper/pop_xmit.c @@ -24,18 +24,17 @@ pop_xmit (POP *p) int id, pid; /* Create a temporary file into which to copy the user's message */ - mktemp(strcpy(temp_xmit,POP_TMPXMIT)); -#ifdef DEBUG - if(p->debug) - pop_log(p, POP_DEBUG, - "Creating temporary file for sending a mail message \"%s\"\n", - temp_xmit); -#endif /* DEBUG */ - if ((tmp = fopen(temp_xmit, "w+")) == NULL) + if ((tmp = fdopen(mkstemp(temp_xmit), "w+")) == NULL) return (pop_msg(p, POP_FAILURE, "Unable to create temporary message file \"%s\": %s", temp_xmit, strerror(errno))); +#ifdef DEBUG + if(p->debug) + pop_log(p, POP_DEBUG, + "Creating temporary file for sending a mail message \"%s\"\n", + temp_xmit); +#endif /* DEBUG */ /* Tell the client to start sending the message */ pop_msg(p,POP_SUCCESS,"Start sending the message.");