summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2018-09-01 11:28:06 +0100
committerKen Sharp <ken.sharp@artifex.com>2018-09-01 11:28:06 +0100
commit7ba6d80c69f0c74601ffc1077d27e0d1a299e57f (patch)
tree9b377a97c177249a80dae3816adbeb57299c7fdb
parent61ad589fb861d28e2d2c9d0b609ec4da4d7dd247 (diff)
downloadghostpdl-7ba6d80c69f0c74601ffc1077d27e0d1a299e57f.tar.gz
Bug #699687 "grestore can bypass SAFER"
The code in z2grestore (part of the level 2 restore machinery) in ghostpdl/psi/zdevice2.c sets the device's LockSafetyParams to false, and according to the comments there relies on putdeviceparams setting the flag back when the old device is re-instated. However, if we have corrupted any part of the device's content, then its possible to exit putdeviceparams, in one place only, without setting LockSafetyParams. Here we simply add an explicit reset of the value even in the case of an error setting the new device.
-rw-r--r--base/gsdparam.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/base/gsdparam.c b/base/gsdparam.c
index b06dfb1e5..0a56b7857 100644
--- a/base/gsdparam.c
+++ b/base/gsdparam.c
@@ -1976,10 +1976,20 @@ label:\
/* We must 'commit', in order to detect unknown parameters, */
/* even if there were errors. */
code = param_commit(plist);
- if (ecode < 0)
+ if (ecode < 0) {
+ /* restore_page_device (zdevice2.c) will turn off LockSafetyParams, and relies on putparams
+ * to put it back if we are restoring a device. The locksafe value is picked up above from the
+ * device we are restoring to, and we *must* make sure it is preserved, even if setting the
+ * params failed. Otherwise an attacker can use a failed grestore to reset LockSafetyParams.
+ * See bug #699687.
+ */
+ dev->LockSafetyParams = locksafe;
return ecode;
- if (code < 0)
+ }
+ if (code < 0) {
+ dev->LockSafetyParams = locksafe;
return code;
+ }
/*
* Now actually make the changes. Changing resolution, rotation