Bug#428055: gs-gpl: gs segfaults on ia64
tag 428055 + patch
thanks
The segfaults during startup on ia64 are due to a bug in Debian-specific
patch 06_libpaper_support.dpatch: Due to a missing declaration, the
pointer returned by libpaper's systempapername() in
imainarg.c::gs_main_init_with_args() gets truncated, and gs segfaults a
few lines later when trying to dereference it. This bug should occur on
each 64bit platform, but apparently it's only fatal on ia64. It's easily
fixed with an #include of paper.h. I'm attaching an updated
06_libpaper_support.dpatch. (Incidentially, I've also prepared and
tested updated packages. So far, they're only used locally, but if you
want to save yourself a bit of work, just drop me a note and I can
upload them as an NMU with no extra effort.)
Regards,
Daniel.
#! /bin/sh -e
## 06_libpaper_support.dpatch by Masayuki Hatta <mhatta@debian.org>
##
## All lines beginning with \`## DP:' are a description of the patch.
## DP: Adds libpaper support
if [ $# -ne 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
case "$1" in
-patch) patch -f --no-backup-if-mismatch --dry-run -p1 < $0 && patch -f --no-backup-if-mismatch -p1 < $0
;;
-unpatch) patch -f --no-backup-if-mismatch -R -p1 < $0;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1;;
esac
exit 0
@DPATCH@
diff -urNad gs-gpl-8.56.dfsg.1~/lib/gs_init.ps gs-gpl-8.56.dfsg.1/lib/gs_init.ps
--- gs-gpl-8.56.dfsg.1~/lib/gs_init.ps 2007-02-24 15:32:48.000000000 +0000
+++ gs-gpl-8.56.dfsg.1/lib/gs_init.ps 2007-06-13 20:23:32.000000000 +0000
@@ -73,6 +73,13 @@
% devices that default to letter or A4 can be changed by setting
% DEFAULTPAPERSIZE.
% /DEFAULTPAPERSIZE (a4) def
+% Debian: Libpaper's default is in DEFPAPERSIZE; use that if the
+% current device is not "cups".
+currentdict /DEFPAPERSIZE known
+currentdict /DEVICE known { DEVICE } { () } ifelse
+(cups) ne and
+ { DEFPAPERSIZE /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse }
+if
% Turn on array packing for the rest of initialization.
true setpacking
diff -urNad gs-gpl-8.56.dfsg.1~/src/imainarg.c gs-gpl-8.56.dfsg.1/src/imainarg.c
--- gs-gpl-8.56.dfsg.1~/src/imainarg.c 2007-01-17 21:10:47.000000000 +0000
+++ gs-gpl-8.56.dfsg.1/src/imainarg.c 2007-06-13 20:23:49.000000000 +0000
@@ -17,6 +17,7 @@
#include "memory_.h"
#include "string_.h"
#include <stdlib.h> /* for qsort */
+#include <paper.h>
#include "ghost.h"
#include "gp.h"
@@ -198,6 +199,29 @@
return e_Fatal;
}
}
+
+ /* Change by Torsten Landschoff <torsten@debian.org>:
+ * If no papersize is given on the commandline we want gs to use the
+ * default papersize of the system. This change differs from the old
+ * Debian change in that it does not use arg_push_string and therefore
+ * is not using up the nesting depth.
+ * -- Thu, 30 Mar 2000 21:28:25 +0200
+ *
+ * Applied to GPL/AFPL GhostScript by Masayuki Hatta
+ * -- Wed Mar 24 15:00:00 JST 2004 */
+
+ {
+ const char *paper = systempapername();
+ static char paperswitch[15+40+1] = "-sDEFPAPERSIZE=";
+ /* strlen("-sDEFPAPERSIZE") + 40 + space for '\0' */
+
+ if (paper != NULL) {
+ strncat(paperswitch, paper, 40);
+ swproc(minst, paperswitch, &args);
+ /* args is not modified since a "-s" argument does not need
+ * such special handling */
+ }
+ }
while ((arg = arg_next(&args, &code)) != 0) {
switch (*arg) {
case '-':
Reply to: