From d5b765ed1bf83caaad8fbcfde9e6142f86d032b8 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Wed, 11 Jan 2012 11:23:32 -0700 Subject: [PATCH] of course, it'd be helpful to actually apply the patch in my tree... --- as31/run.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/as31/run.c b/as31/run.c index 126d3b5..28c5317 100644 --- a/as31/run.c +++ b/as31/run.c @@ -39,8 +39,8 @@ int run_as31(const char *infile, int lst, int use_stdout, char *incLineBuffer=NULL; int incSizeBuf=0; FILE* includeFile=NULL; + int fd; - uid_t uid; /* first, figure out all the file names */ dashl = lst; @@ -95,11 +95,18 @@ int run_as31(const char *infile, int lst, int use_stdout, } } - uid = geteuid(); - sprintf(tmpName,"/tmp/as31-%i-%ld.asm",uid,random()); - fin = fopen(tmpName, "w"); + sprintf(tmpName,"/tmp/as31-XXXXXX.asm"); + fd = mkstemps(tmpName, 4); + if (fd == -1) { + mesg_f("Cannot create temp file\n"); + if (outfile) free(outfile); + if (lstfile) free(lstfile); + return -1; + } + fin = fdopen(fd, "w"); if (fin == NULL) { mesg_f("Cannot open temp file: %s\n",tmpName); + close(fd); if (outfile) free(outfile); if (lstfile) free(lstfile); return -1; -- 2.30.2