Sophie

Sophie

distrib > Mageia > 9 > armv7hl > media > core-release-src > by-pkgid > d3fc76fe325ca661cb5adbf012153e1c > files > 6

ghostscript-10.00.0-6.mga9.src.rpm

From 36b01018cf2d263dc9dac37cd464f5248e3852d4 Mon Sep 17 00:00:00 2001
From: Ken Sharp <ken.sharp@artifex.com>
Date: Sun, 2 Oct 2022 11:28:19 +0100
Subject: [PATCH 126/155] pdfwrite - fix Permissions on 64-bit Linux build

Bug #705951 "-dPermissions=<negative>: 32bit gs -> /P <negative>, 64bit gs -> /P <unsigned int>"

The code in pdf_close to write out the Encrypt dictionary was writing
the Permissions as a long, which is fine on Windows where it is always
32-bit, but doesn't work correctly on Linux because long is 64-bit on
a 64-bit build on Linux.

Change the print to use an int instead of a long, and also alter the
structure member to be a 32-bit integer (not required but might as well
be consistent).
---
 devices/vector/gdevpdf.c  | 2 +-
 devices/vector/gdevpdfx.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/devices/vector/gdevpdf.c b/devices/vector/gdevpdf.c
index 40beb06a5..6c4908bc3 100644
--- a/devices/vector/gdevpdf.c
+++ b/devices/vector/gdevpdf.c
@@ -3115,7 +3115,7 @@ pdf_close(gx_device * dev)
             pprintld1(s, "/V %ld ", pdev->EncryptionV);
             pprintld1(s, "/Length %ld ", pdev->KeyLength);
             pprintld1(s, "/R %ld ", pdev->EncryptionR);
-            pprintld1(s, "/P %ld ", pdev->Permissions);
+            pprintd1(s, "/P %d ", pdev->Permissions);
             stream_puts(s, "/O ");
             pdf_put_string(pdev, pdev->EncryptionO, sizeof(pdev->EncryptionO));
             stream_puts(s, "\n/U ");
diff --git a/devices/vector/gdevpdfx.h b/devices/vector/gdevpdfx.h
index 098fc4fc9..61a5c582c 100644
--- a/devices/vector/gdevpdfx.h
+++ b/devices/vector/gdevpdfx.h
@@ -641,7 +641,7 @@ struct gx_device_pdf_s {
     gs_param_string OwnerPassword;
     gs_param_string UserPassword;
     uint KeyLength;
-    uint Permissions;
+    int32_t Permissions;
     uint EncryptionR;
     gs_param_string NoEncrypt;
     bool EncryptMetadata;
-- 
2.38.0