summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-09-21 14:18:08 +0100
committerSam James <sam@gentoo.org>2022-10-02 04:31:25 +0100
commita529111f77ff46f4836fe7312e70953bc16587cf (patch)
tree9dc3924cb1a6ef3ef853b7bb45f735365e0b4e6d /psi/zfile.c
parentImport Ghostscript 9.56.1 (diff)
downloadghostscript-gpl-patches-ghostscript-10.tar.gz
ghostscript-gpl-patches-ghostscript-10.tar.bz2
ghostscript-gpl-patches-ghostscript-10.zip
Import Ghostscript 10.0ghostscript-10.0ghostscript-10
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'psi/zfile.c')
-rw-r--r--psi/zfile.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/psi/zfile.c b/psi/zfile.c
index fe3f7e9f..e4a2a3e1 100644
--- a/psi/zfile.c
+++ b/psi/zfile.c
@@ -772,18 +772,25 @@ ztempfile(i_ctx_t *i_ctx_p)
if (gp_file_name_is_absolute(pstr, strlen(pstr))) {
int plen = strlen(pstr);
const char *sep = gp_file_name_separator();
-#ifdef DEBUG
int seplen = strlen(sep);
- if (seplen != 1)
+
+ /* This should not be possible if gp_file_name_is_absolute is true I think
+ * But let's avoid the problem.
+ */
+ if (plen < seplen)
return_error(gs_error_Fatal);
-#endif
+
+ plen -= seplen;
/* strip off the file name prefix, leave just the directory name
* so we can check if we are allowed to write to it
*/
for ( ; plen >=0; plen--) {
- if (pstr[plen] == sep[0])
+ if ( gs_file_name_check_separator(&pstr[plen], seplen, &pstr[plen]))
break;
}
+ if (plen < 0)
+ return_error(gs_error_Fatal);
+
memcpy(fname, pstr, plen);
fname[plen] = '\0';
if (check_file_permissions(i_ctx_p, fname, strlen(fname),