From 2dc1293603873051647ad99ec76703e8f59fd8a6 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sat, 4 Apr 1998 18:57:48 +0000 Subject: [PATCH] (pop_dropcopy): first do mkstemp and tehn fdopen. Originally from git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4719 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/popper/pop_dropcopy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/appl/popper/pop_dropcopy.c b/appl/popper/pop_dropcopy.c index 0a4ba15b5..8232236c1 100644 --- a/appl/popper/pop_dropcopy.c +++ b/appl/popper/pop_dropcopy.c @@ -24,6 +24,7 @@ pop_dropcopy(POP *p, struct passwd *pwp) char buffer[BUFSIZ]; /* Read buffer */ long offset; /* Old/New boundary */ int nchar; /* Bytes written/read */ + int tf_fd; /* fd for temp file */ /* Create a temporary maildrop into which to copy the updated maildrop */ snprintf(p->temp_drop, sizeof(p->temp_drop), POP_DROP,p->user); @@ -39,9 +40,9 @@ pop_dropcopy(POP *p, struct passwd *pwp) * running as root. */ - /* First create a unique file. Would prefer mkstemp, but Ultrix...*/ - strcpy(template,POP_TMPDROP); - if ((tf=fdopen(mkstemp(template),"w+")) == NULL) { /* failure, bail out */ + strcpy(template, POP_TMPDROP); + if ((tf_fd = mkstemp(template) < 0) || + (tf = fdopen(tf_fd, "w+")) == NULL) { pop_log(p,POP_PRIORITY, "Unable to create temporary temporary maildrop '%s': %s",template, strerror(errno));