Re: [Bug 687317] New: EncryptionR=2 doesn't work withPermissions=-44
"Russell Lang" <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <403D1E6A.29231.42C69D11@localhost> |
Igor, Updated patch attached. To be applied to HEAD and GS_8_1X. Log message: Fix pdfwrite allowable Permissions for EncryptionR=2. Fix default Permissions. DETAILS: The code was assuming that the extra permissions should be 0's, when in fact they should be 1's. The fixed code is a bit more conservative and requires that all reserved bits match the PDF specification. Set the default permissions to -4 which allows everything. On 25 Feb 2004 at 11:18, Igor V. Melichev wrote: > I agree that the check in incorrect. > However the patch is incomplete. It must fix the default value in > gdevpdf.c ln 206 . > > Probably GS_8_1X to be patched as well. > > Igor. > > ----- Original Message ----- > From: "Russell Lang" <[email protected]> > To: <[email protected]> > Sent: Wednesday, February 25, 2004 10:43 AM > Subject: [gs-code-review] [Bug 687317] New: EncryptionR=2 doesn't work > withPermissions=-44 > > > > Log message: > > Fix pdfwrite allowable Permissions for EncryptionR=2. > > > > DETAILS: > > The code was assuming that the extra permissions should be 0's, > > when in fact they should be 1's. The fixed code is a bit more > > conservative and requires that all reserved bits match the PDF > > specification. > > > > diff -u -r1.89 gdevpdf.c > > --- a/gdevpdf.c 13 Feb 2004 08:08:35 -0000 1.89 > > +++ b/gdevpdf.c 25 Feb 2004 03:33:54 -0000 > > @@ -545,7 +545,8 @@ > > eprintf("PDF encryption key length must be a multiple of 8.\n"); > > return_error(gs_error_rangecheck); > > } > > - if (pdev->EncryptionR == 2 && (pdev->Permissions & (0xF << 8))) { > > + if (pdev->EncryptionR == 2 && > > + ((pdev->Permissions & (0xFFFFFFC3)) != 0xFFFFFFC0)) { > > eprintf("Some of Permissions are not allowed with R=2.\n"); > > return_error(gs_error_rangecheck); > > } > > Russell Lang [email protected] > > Ghostgum Software Pty Ltd http://www.ghostgum.com.au/ > > > > > > _______________________________________________ > > gs-code-review mailing list > > [email protected] > > http://www.ghostscript.com/mailman/listinfo/gs-code-review > > > Russell Lang [email protected] Ghostgum Software Pty Ltd http://www.ghostgum.com.au/ --- src/gdevpdf.c 2004-02-18 07:20:25.000000000 +1100 +++ ./gdevpdf.c 2004-02-25 22:05:33.000000000 +1100 @@ -203,7 +203,7 @@ {0, 0}, /* OwnerPassword */ {0, 0}, /* UserPassword */ 0, /* KeyLength */ - 4, /* Permissions */ + -4, /* Permissions */ 0, /* EncryptionR */ {0}, /* EncryptionO */ {0}, /* EncryptionU */ @@ -545,7 +545,8 @@ eprintf("PDF encryption key length must be a multiple of 8.\n"); return_error(gs_error_rangecheck); } - if (pdev->EncryptionR == 2 && (pdev->Permissions & (0xF << 8))) { + if (pdev->EncryptionR == 2 && + ((pdev->Permissions & (0xFFFFFFC3)) != 0xFFFFFFC0)) { eprintf("Some of Permissions are not allowed with R=2.\n"); return_error(gs_error_rangecheck); } _______________________________________________ gs-code-review mailing list [email protected] http://www.ghostscript.com/mailman/listinfo/gs-code-review