ghostscript/ghostscript-10.01.0-convert-defaultpage-to-lowercase.patch
Richard Lescak 2f987fc842 fix for CVE-2023-28879 (#2184586)
add patch for converting default page name to lowercase (#2183166)
2023-04-06 14:25:43 +02:00

63 lines
2.6 KiB
Diff

diff --git a/Resource/Init/gs_statd.ps b/Resource/Init/gs_statd.ps
index 6751c032908337e400c67c02a80cbeae8a8b3122..83181257dea8b3438ccf8ce290422283414f8755 100644 (file)
--- a/Resource/Init/gs_statd.ps
+++ b/Resource/Init/gs_statd.ps
@@ -42,7 +42,7 @@ statusdict begin
% Keep the table of named paper sizes as procedures. Reuse them later
% as compatibility operators.
-/.pagetypeprocs 70 dict begin
+/.pagetypeprocs 81 dict begin
% Define various paper formats. The Adobe documentation defines only these:
% 11x17, a3, a4, a4small, b5, ledger, legal, letter, lettersmall, note.
@@ -116,6 +116,11 @@ statusdict begin
/archC {1296 1728 //.setpagesize stopped { pop pop /archC $error /errorname get signalerror } if } bind def
/archB {864 1296 //.setpagesize stopped { pop pop /archB $error /errorname get signalerror } if } bind def
/archA {648 864 //.setpagesize stopped { pop pop /archA $error /errorname get signalerror } if } bind def
+ /archa /archA load def
+ /archb /archB load def
+ /archc /archC load def
+ /archd /archD load def
+ /arche /archE load def
% Other paper sizes
/flsa {612 936 //.setpagesize stopped { pop pop /flsa $error /errorname get signalerror } if } bind def % U.S. foolscap
/flse {612 936 //.setpagesize stopped { pop pop /flse $error /errorname get signalerror } if } bind def % European foolscap
@@ -132,6 +137,12 @@ statusdict begin
/ANSI_D {1585 2448 //.setpagesize stopped { pop pop /ANSI_D $error /errorname get signalerror } if } bind def
/ANSI_E {2448 3168 //.setpagesize stopped { pop pop /ANSI_E $error /errorname get signalerror } if } bind def
/ANSI_F {2016 2880 //.setpagesize stopped { pop pop /ANSI_F $error /errorname get signalerror } if } bind def
+ /ansi_a /ANSI_A load def
+ /ansi_b /ANSI_B load def
+ /ansi_c /ANSI_C load def
+ /ansi_d /ANSI_D load def
+ /ansi_e /ANSI_E load def
+ /ansi_f /ANSI_F load def
%END SIZES
currentdict end
userdict begin dup { def } forall end % reuse!
diff --git a/psi/zmisc.c b/psi/zmisc.c
--- a/psi/zmisc.c
+++ b/psi/zmisc.c
@@ -255,7 +255,7 @@
{
os_ptr op = osp;
byte *value;
- int len = 0;
+ int len = 0, i;
if (gp_defaultpapersize((char *)0, &len) > 0) {
/* no default paper size */
@@ -269,6 +269,10 @@
return_error(gs_error_VMerror);
}
DISCARD(gp_defaultpapersize((char *)value, &len)); /* can't fail */
+ /* Note 'len' includes the NULL terminator, which we can ignore */
+ for (i = 0;i < (len - 1); i++)
+ value[i] = tolower(value[i]);
+
/* Delete the stupid C string terminator. */
value = iresize_string(value, len, len - 1,
"defaultpapersize value"); /* can't fail */