6b338200be
- patch to cure /tmp race condition added; it needs cleaning up before submitting back to authors though (espie@ ok) -- Dvipdfm is a command-line DVI to PDF translator. Its features include TeX \special's that approximate the functionality of the PostScript pdfmarks used by Adobe Acrobat Distiller, the ability to include PDF files and JPEG files as embedded images, support for both Type1 and PK fonts, support for arbitrary linear graphics transformations, a color stack accessible via \special's, partial font embedding and stream compression for reduced output file size, native, portable graphics via TPIC \specials, balanced page and destination trees for improved reader access on very large document files.
44 lines
1.4 KiB
C
44 lines
1.4 KiB
C
$OpenBSD: patch-psimage.c,v 1.1.1.1 2001/01/12 23:21:07 avsm Exp $
|
|
|
|
Cures a /tmp race condition when converting embedded eps/ps formats
|
|
to pdf, using external applications. It needs cleaning up, and fallback
|
|
via autoconf before submission back to authors - avsm@
|
|
|
|
--- psimage.c.orig Fri Oct 13 21:36:47 2000
|
|
+++ psimage.c Thu Jan 11 23:40:40 2001
|
|
@@ -113,10 +113,18 @@ pdf_obj *ps_include (char *file_name,
|
|
{
|
|
#ifdef HAVE_SYSTEM
|
|
pdf_obj *result = NULL;
|
|
- char *tmp, *cmd;
|
|
+ char *cmd, tmp[30];
|
|
FILE *pdf_file = NULL;
|
|
- /* Get a full qualified tmp name */
|
|
- tmp = tmpnam (NULL);
|
|
+ int fd = -1;
|
|
+
|
|
+ strlcpy(tmp, "/tmp/dvipdfm.XXXXXXXXXXXX", sizeof(tmp));
|
|
+ /* Get a full qualified tmp name and create it in one operation */
|
|
+ if ((fd=mkstemp(tmp)) == -1) {
|
|
+ fprintf(stderr, "\nError opening tmp file %s: %s\n", tmp, strerror(errno));
|
|
+ return NULL;
|
|
+ }
|
|
+ close(fd);
|
|
+
|
|
if ((cmd = build_command_line (file_name, tmp))) {
|
|
if (!system (cmd) && (pdf_file = MFOPEN (tmp, FOPEN_RBIN_MODE))) {
|
|
result = pdf_include_page (pdf_file, p, res_name);
|
|
@@ -125,10 +133,11 @@ pdf_obj *ps_include (char *file_name,
|
|
}
|
|
if (pdf_file) {
|
|
MFCLOSE (pdf_file);
|
|
- remove (tmp);
|
|
}
|
|
RELEASE (cmd);
|
|
}
|
|
+
|
|
+ unlink(tmp);
|
|
return result;
|
|
#else
|
|
fprintf (stderr, "\n\nCannot include PS/EPS files unless you have and enable system() command.\n");
|