[gs-cvs] rev 8746 - in trunk/gs: lib src

alexcher at ghostscript.com alexcher at ghostscript.com
Sat May 17 14:33:47 PDT 2008


Author: alexcher
Date: 2008-05-17 14:33:47 -0700 (Sat, 17 May 2008)
New Revision: 8746

Modified:
   trunk/gs/lib/pdf_main.ps
   trunk/gs/src/zfile.c
Log:
Permit opening of temporary files in the safe mode. Fix /invalidaccess
error during interpretation of PDF 1.7 file collections in the safe mode.
Bug 689847.

DIFFERENCES:
None in the standard mode.


Modified: trunk/gs/lib/pdf_main.ps
===================================================================
--- trunk/gs/lib/pdf_main.ps	2008-05-17 12:58:01 UTC (rev 8745)
+++ trunk/gs/lib/pdf_main.ps	2008-05-17 21:33:47 UTC (rev 8746)
@@ -101,7 +101,7 @@
 	    } ifelse
 	    dup (%stdin) (r) file eq {
 	      % Copy PDF from stdin to temporary file then run it.
-	      null (w+) //systemdict /.tempfile get exec exch 3 1 roll
+	      null (w+) /.tempfile systemvar exec exch 3 1 roll
 	      % stack: tempname stdin tempfile
 	      64000 string
 	      {
@@ -208,7 +208,8 @@
             /EF knownoget {
               /F knownoget {
                 //true resolvestream    % {} true strm
-                //null (w) .tempfile    % {} true strm (name) file
+                //null (w) /.tempfile   % {} true strm (name) null (w) /.tempfile
+                .systemvar exec         % {} true strm (name) file
                 3 -1 roll               % {} true (name) file strm
                 32768 string            % {} true (name) file strm (buf)
                 { 3 copy readstring     % {} true (name) file strm (buf) file (data) bool

Modified: trunk/gs/src/zfile.c
===================================================================
--- trunk/gs/src/zfile.c	2008-05-17 12:58:01 UTC (rev 8745)
+++ trunk/gs/src/zfile.c	2008-05-17 21:33:47 UTC (rev 8746)
@@ -288,7 +288,7 @@
  * The names 'SAFETY' and 'tempfiles' are defined by gs_init.ps
 */
 static bool
-file_is_tempfile(i_ctx_t *i_ctx_p, const ref *op)
+file_is_tempfile(i_ctx_t *i_ctx_p, const uchar *fname, int len)
 {
     ref *SAFETY;
     ref *tempfiles;
@@ -297,7 +297,7 @@
     if (dict_find_string(systemdict, "SAFETY", &SAFETY) <= 0 ||
 	    dict_find_string(SAFETY, "tempfiles", &tempfiles) <= 0)
 	return false;
-    if (name_ref(imemory, op->value.bytes, r_size(op), &kname, -1) < 0 ||
+    if (name_ref(imemory, fname, len, &kname, -1) < 0 ||
 	    dict_find(tempfiles, &kname, &SAFETY) <= 0)
 	return false;
     return true;
@@ -318,7 +318,7 @@
     if (pname.iodev == iodev_default) {
 	if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
 		"PermitFileControl")) < 0 &&
-		 !file_is_tempfile(i_ctx_p, op)) {
+		 !file_is_tempfile(i_ctx_p, op->value.bytes, r_size(op))) {
 	    return code;
 	}
     }
@@ -447,7 +447,7 @@
 		 */
 	      ((check_file_permissions(i_ctx_p, pname1.fname, pname1.len,
 	      				"PermitFileControl") < 0 &&
-	          !file_is_tempfile(i_ctx_p, op - 1)) ||
+	          !file_is_tempfile(i_ctx_p, op[-1].value.bytes, r_size(op - 1))) ||
 	      (check_file_permissions(i_ctx_p, pname2.fname, pname2.len,
 	      				"PermitFileControl") < 0 ||
 	      check_file_permissions(i_ctx_p, pname2.fname, pname2.len,
@@ -849,7 +849,8 @@
 	    int code = check_file_permissions(i_ctx_p, pfn->fname, pfn->len,
 		file_access[0] == 'r' ? "PermitFileReading" : "PermitFileWriting");
 
-	    if (code < 0)
+	    if (code < 0 && !file_is_tempfile(i_ctx_p,
+                                          (const uchar *)pfn->fname, pfn->len))
 		return code;
 	}
 	return open_file(iodev, pfn->fname, pfn->len, file_access, ps, mem);



More information about the gs-cvs mailing list