[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pdf-tools fedd930a09: Revert "Use mkstemp instead of tempn
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pdf-tools fedd930a09: Revert "Use mkstemp instead of tempnam" |
Date: |
Wed, 11 May 2022 21:58:38 -0400 (EDT) |
branch: elpa/pdf-tools
commit fedd930a09a497c03df3ce5204ccbd80da724662
Author: Vedang Manerikar <ved.manerikar@gmail.com>
Commit: Vedang Manerikar <ved.manerikar@gmail.com>
Revert "Use mkstemp instead of tempnam"
This reverts commit 37bbe861755bc60c7cc333359fee3e2a5d919c77.
As explained by @ShuguangSun (re: testing the change on Windows) on
> Sorry. It is my fault. The issue is still there. The different is
> that the temp dir is created now. However, it reports "Unable to
> create temporary file".
Reopens: #110
---
server/epdfinfo.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/server/epdfinfo.c b/server/epdfinfo.c
index 906bdb486b..3e0e7c1166 100644
--- a/server/epdfinfo.c
+++ b/server/epdfinfo.c
@@ -35,7 +35,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <unistd.h>
#include <errno.h>
#include <png.h>
#include <math.h>
@@ -347,18 +346,26 @@ strchomp (char *str)
static char*
mktempfile()
{
- char template[] = P_tmpdir "/epdfinfoXXXXXX";
- char *filename = malloc(sizeof(template));
- memcpy(filename, template, sizeof(template));
- int fd = mkstemp(filename);
- if (fd == -1)
+ char *filename = NULL;
+ int tries = 3;
+ while (! filename && tries-- > 0)
{
- fprintf (stderr, "Unable to create tempfile");
- free(filename);
- filename = NULL;
+
+ filename = tempnam(NULL, "epdfinfo");
+ if (filename)
+ {
+ int fd = open(filename, O_CREAT | O_EXCL | O_RDONLY, S_IRWXU);
+ if (fd > 0)
+ close (fd);
+ else
+ {
+ free (filename);
+ filename = NULL;
+ }
+ }
}
- else
- close(fd);
+ if (! filename)
+ fprintf (stderr, "Unable to create tempfile");
return filename;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/pdf-tools fedd930a09: Revert "Use mkstemp instead of tempnam",
ELPA Syncer <=