|
|
3a994f |
From 950c602dc2dbbcbf5a856e85dba99bc8ac8420b9 Mon Sep 17 00:00:00 2001
|
|
|
3a994f |
From: Chris Liddell <chris.liddell@artifex.com>
|
|
|
3a994f |
Date: Sat, 5 Mar 2016 14:56:03 -0800
|
|
|
3a994f |
Subject: [PATCH 1/1] Bug 694724: Have filenameforall and getenv honor SAFER
|
|
|
3a994f |
|
|
|
3a994f |
---
|
|
|
3a994f |
Resource/Init/gs_init.ps | 1 +
|
|
|
3a994f |
psi/zfile.c | 36 ++++++++++++++++++++----------------
|
|
|
3a994f |
2 files changed, 21 insertions(+), 16 deletions(-)
|
|
|
3a994f |
|
|
|
3a994f |
diff --git a/Resource/Init/gs_init.ps b/Resource/Init/gs_init.ps
|
|
|
3a994f |
index c3f567d..abb9489 100644
|
|
|
3a994f |
--- a/Resource/Init/gs_init.ps
|
|
|
3a994f |
+++ b/Resource/Init/gs_init.ps
|
|
|
3a994f |
@@ -2019,6 +2019,7 @@ readonly def
|
|
|
3a994f |
/LockFilePermissions //true
|
|
|
3a994f |
>> setuserparams
|
|
|
3a994f |
}
|
|
|
3a994f |
+ systemdict /getenv {pop //false} put
|
|
|
3a994f |
if
|
|
|
3a994f |
% setpagedevice has the side effect of clearing the page, but
|
|
|
3a994f |
% we will just document that. Using setpagedevice keeps the device
|
|
|
3a994f |
diff --git a/psi/zfile.c b/psi/zfile.c
|
|
|
3a994f |
index 4011789..dd05919 100644
|
|
|
3a994f |
--- a/psi/zfile.c
|
|
|
3a994f |
+++ b/psi/zfile.c
|
|
|
3a994f |
@@ -371,22 +371,26 @@ file_continue(i_ctx_t *i_ctx_p)
|
|
|
3a994f |
|
|
|
3a994f |
if (len < devlen)
|
|
|
3a994f |
return_error(e_rangecheck); /* not even room for device len */
|
|
|
3a994f |
- memcpy((char *)pscratch->value.bytes, iodev->dname, devlen);
|
|
|
3a994f |
- code = iodev->procs.enumerate_next(pfen, (char *)pscratch->value.bytes + devlen,
|
|
|
3a994f |
- len - devlen);
|
|
|
3a994f |
- if (code == ~(uint) 0) { /* all done */
|
|
|
3a994f |
- esp -= 5; /* pop proc, pfen, devlen, iodev , mark */
|
|
|
3a994f |
- return o_pop_estack;
|
|
|
3a994f |
- } else if (code > len) /* overran string */
|
|
|
3a994f |
- return_error(e_rangecheck);
|
|
|
3a994f |
- else {
|
|
|
3a994f |
- push(1);
|
|
|
3a994f |
- ref_assign(op, pscratch);
|
|
|
3a994f |
- r_set_size(op, code + devlen);
|
|
|
3a994f |
- push_op_estack(file_continue); /* come again */
|
|
|
3a994f |
- *++esp = pscratch[2]; /* proc */
|
|
|
3a994f |
- return o_push_estack;
|
|
|
3a994f |
- }
|
|
|
3a994f |
+
|
|
|
3a994f |
+ do {
|
|
|
3a994f |
+ memcpy((char *)pscratch->value.bytes, iodev->dname, devlen);
|
|
|
3a994f |
+ code = iodev->procs.enumerate_next(pfen, (char *)pscratch->value.bytes + devlen,
|
|
|
3a994f |
+ len - devlen);
|
|
|
3a994f |
+ if (code == ~(uint) 0) { /* all done */
|
|
|
3a994f |
+ esp -= 5; /* pop proc, pfen, devlen, iodev , mark */
|
|
|
3a994f |
+ return o_pop_estack;
|
|
|
3a994f |
+ } else if (code > len) /* overran string */
|
|
|
3a994f |
+ return_error(gs_error_rangecheck);
|
|
|
3a994f |
+ else if (iodev != iodev_default(imemory)
|
|
|
3a994f |
+ || (check_file_permissions_reduced(i_ctx_p, (char *)pscratch->value.bytes, code + devlen, "PermitFileReading")) == 0) {
|
|
|
3a994f |
+ push(1);
|
|
|
3a994f |
+ ref_assign(op, pscratch);
|
|
|
3a994f |
+ r_set_size(op, code + devlen);
|
|
|
3a994f |
+ push_op_estack(file_continue); /* come again */
|
|
|
3a994f |
+ *++esp = pscratch[2]; /* proc */
|
|
|
3a994f |
+ return o_push_estack;
|
|
|
3a994f |
+ }
|
|
|
3a994f |
+ } while(1);
|
|
|
3a994f |
}
|
|
|
3a994f |
/* Cleanup procedure for enumerating files */
|
|
|
3a994f |
static int
|
|
|
3a994f |
--
|
|
|
3a994f |
2.7.4
|
|
|
3a994f |
|