diff options
author | Dmitry Sivachenko <demon@FreeBSD.org> | 2001-11-04 07:35:38 +0000 |
---|---|---|
committer | Dmitry Sivachenko <demon@FreeBSD.org> | 2001-11-04 07:35:38 +0000 |
commit | 9c45f91fe676941baaafa1e7f811cd23d36329fa (patch) | |
tree | e109850c51367da160b9eda35405ec3480949c72 /print/ghostscript-gnu/files/patch-src:gp_unifs.c | |
parent | Update to 7.03 (diff) |
Update to 6.52
PR: 31724
Submitted by: KATO Tsuguru <tkato@prontomail.com>
Notes
Notes:
svn path=/head/; revision=49552
Diffstat (limited to 'print/ghostscript-gnu/files/patch-src:gp_unifs.c')
-rw-r--r-- | print/ghostscript-gnu/files/patch-src:gp_unifs.c | 68 |
1 files changed, 47 insertions, 21 deletions
diff --git a/print/ghostscript-gnu/files/patch-src:gp_unifs.c b/print/ghostscript-gnu/files/patch-src:gp_unifs.c index e7db705ace5f..ba0f9597e6e5 100644 --- a/print/ghostscript-gnu/files/patch-src:gp_unifs.c +++ b/print/ghostscript-gnu/files/patch-src:gp_unifs.c @@ -1,34 +1,60 @@ ---- src/gp_unifs.c.orig Tue Jun 5 15:38:58 2001 -+++ src/gp_unifs.c Wed Jun 20 04:18:03 2001 -@@ -29,6 +29,7 @@ +--- src/gp_unifs.c.orig Tue Jun 5 15:31:44 2001 ++++ src/gp_unifs.c Sun Jul 15 22:57:50 2001 +@@ -28,6 +27,8 @@ + #include "gsutil.h" /* for string_match */ #include "stat_.h" #include "dirent_.h" ++#include "unistd_.h" ++#include <stdlib.h> /* for mkstemp/mktemp */ #include <sys/param.h> /* for MAXPATHLEN */ -+#include <unistd.h> /* Some systems (Interactive for example) don't define MAXPATHLEN, - * so we define it here. (This probably should be done via a Config-Script.) -@@ -59,6 +60,8 @@ +@@ -57,22 +58,44 @@ + FILE * + gp_open_scratch_file(const char *prefix, char fname[gp_file_name_sizeof], const char *mode) - { /* The -8 is for XXXXXX plus a possible final / and -. */ - int len = gp_file_name_sizeof - strlen(prefix) - 8; -+ int fd; -+ FILE *f; - - if (gp_gettmpdir(fname, &len) != 0) +-{ /* The -8 is for XXXXXX plus a possible final / and -. */ +- int len = gp_file_name_sizeof - strlen(prefix) - 8; +- +- if (gp_gettmpdir(fname, &len) != 0) ++{ /* The -8 is for XXXXXX plus a possible final / and -. */ ++ int prefix_length = strlen(prefix); ++ int len = gp_file_name_sizeof - prefix_length - 8; ++ ++ if (gp_file_name_is_absolute(prefix, prefix_length)) ++ *fname = 0; ++ else if (gp_gettmpdir(fname, &len) != 0) strcpy(fname, "/tmp/"); -@@ -71,8 +74,12 @@ + else { + if (strlen(fname) != 0 && fname[strlen(fname) - 1] != '/') + strcat(fname, "/"); + } ++ if (strlen(fname) + prefix_length + 8 >= gp_file_name_sizeof) ++ return 0; /* file name too long */ + strcat(fname, prefix); + /* Prevent trailing X's in path from being converted by mktemp. */ if (*fname != 0 && fname[strlen(fname) - 1] == 'X') strcat(fname, "-"); strcat(fname, "XXXXXX"); -- mktemp(fname); -- return gp_fopentemp(fname, mode); -+ fd = mkstemp(fname); -+ if (fd == -1) -+ return NULL; -+ if ((f = fdopen(fd, mode)) == NULL) -+ close(fd); -+ return f; ++ ++#ifdef HAVE_MKSTEMP ++ { ++ int file; ++ FILE *fp; ++ ++ file = mkstemp(fname); ++ if (file < -1) ++ return NULL; ++ fp = fdopen(file, mode); ++ if (fp == NULL) ++ close(file); ++ ++ return fp; ++ } ++#else + mktemp(fname); + return gp_fopentemp(fname, mode); ++#endif } /* Open a file with the given name, as a stream of uninterpreted bytes. */ |