Monday, November 06, 2023

Re: audio/solfege build failure (Re: [Security] ghostscript/gnu 10.02.1)

Hi,

On Mon, Nov 06, 2023 at 09:31:14PM +0100, Volker Schlecht wrote:
> On 2023-11-06 20:40, Theo Buehler wrote:
> > On Thu, Nov 02, 2023 at 07:13:45PM +0100, Volker Schlecht wrote:
> > > ghostscript released a patch release addressing some vaguely specified
> > > security bugs.
> > > From the changelog, it looks like there's at least a buffer overflow and an
> > > integer overflow that got fixed, so I think we want those fixes ASAP:
> > >
> > > https://git.ghostscript.com/?p=ghostpdl.git;a=shortlog;h=refs/tags/ghostpdl-10.02.1
> > >
> > > Built and tested on amd64. ok?
> >
> > I see the following build failure of audio/solfege with ghostscript
> > 10.02.1 but not with 10.02.0, full log attached:
>
> For full context:
>
> https://bugs.ghostscript.com/show_bug.cgi?id=707307
> https://gitlab.com/lilypond/lilypond/-/merge_requests/2160/
>
> The attached diff backports the current draft merge request to print/lilypond
> referenced above, which fixes both print/lilypond and audio/solfege for me.

ok kili@

> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/print/lilypond/Makefile,v
> retrieving revision 1.59
> diff -u -p -r1.59 Makefile
> --- Makefile 30 Oct 2023 23:41:03 -0000 1.59
> +++ Makefile 6 Nov 2023 20:23:31 -0000
> @@ -7,6 +7,7 @@ DISTNAME-docs= lilypond-${VERSION}-docu
> PKGNAME-main= lilypond-${VERSION}
> PKGNAME-docs= lilypond-docs-${VERSION}
> CATEGORIES= print
> +REVISION= 0
>
> URW_V= 20200910
> DISTFILES= ${DISTNAME}.tar.bz2
> Index: patches/patch-scm_backend-library_scm
> ===================================================================
> RCS file: patches/patch-scm_backend-library_scm
> diff -N patches/patch-scm_backend-library_scm
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-scm_backend-library_scm 6 Nov 2023 20:23:31 -0000
> @@ -0,0 +1,56 @@
> +Fix for ghostscript 10.02.1 (finddevice removed) by backporting
> +https://gitlab.com/lilypond/lilypond/-/merge_requests/2160/diffs?commit_id=3d1a7fa40fae01c40c60344a09d0bcf01896557a
> +
> +Index: scm/backend-library.scm
> +--- scm/backend-library.scm.orig
> ++++ scm/backend-library.scm
> +@@ -115,7 +115,8 @@
> + (run-strings
> + (filter string?
> + (list
> +- (format #f "mark /OutputFile (~a)" output-file)
> ++ "<<"
> ++ (format #f "/OutputFile (~a)" output-file)
> + ;; Ghostscript's default level may change with future
> + ;; releases, the current being 1.7 since 9.24. This
> + ;; results in a warning when embedding the produced PDF
> +@@ -125,10 +126,16 @@
> + "/CompatibilityLevel 1.4"
> + (if (not is-eps)
> + (ly:format "/PageSize [~$ ~$]" paper-width paper-height))
> +- "(pdfwrite) finddevice putdeviceprops pop"
> +- ;; `setdevice` does not set some defaults. So we use
> +- ;; `selectdevide` instead.
> +- "(pdfwrite) selectdevice"
> ++ "/OutputDevice /pdfwrite >> setpagedevice"
> ++ ;; `setpagedevice` does not set some defaults, creating
> ++ ;; larger output files than necessary. To fix this we use
> ++ ;; the undocumented, internal `.setdefaultscreen` procedure
> ++ ;; (tested with gs 10.02.1).
> ++ "/.setdefaultscreen where {"
> ++ "pop .setdefaultscreen"
> ++ "} {"
> ++ "(Warning: .setdefaultscreen not available) print"
> ++ "} ifelse"
> + ;; from Resource/Init/gs_pdfwr.ps; needed here because we
> + ;; do not have the pdfwrite device initially (-dNODISPLAY).
> + "newpath fill"
> +@@ -146,10 +153,15 @@
> + (ly:gs-api (gs-cmd-args is-eps #f)
> + (string-join
> + (list
> +- (format #f "mark /OutputFile (~a)" flush-name)
> +- "(pdfwrite) finddevice putdeviceprops pop"
> ++ "<<"
> ++ (format #f "/OutputFile (~a)" flush-name)
> ++ "/OutputDevice /pdfwrite >> setpagedevice"
> + ;; see above
> +- "(pdfwrite) selectdevice"
> ++ "/.setdefaultscreen where {"
> ++ "pop .setdefaultscreen"
> ++ "} {"
> ++ "(Warning: .setdefaultscreen not available) print"
> ++ "} ifelse"
> + ;; see above
> + "newpath fill")
> + " "))
> Index: patches/patch-scm_framework-ps_scm
> ===================================================================
> RCS file: patches/patch-scm_framework-ps_scm
> diff -N patches/patch-scm_framework-ps_scm
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-scm_framework-ps_scm 6 Nov 2023 20:23:31 -0000
> @@ -0,0 +1,17 @@
> +Fix for ghostscript 10.02.1 (finddevice removed) by backporting
> +https://gitlab.com/lilypond/lilypond/-/merge_requests/2160/diffs?commit_id=3d1a7fa40fae01c40c60344a09d0bcf01896557a
> +
> +Index: scm/framework-ps.scm
> +--- scm/framework-ps.scm.orig
> ++++ scm/framework-ps.scm
> +@@ -613,8 +613,8 @@
> + (begin
> + (display "
> + /currentpagedevice where {
> +- pop currentpagedevice /Name known {
> +- currentpagedevice /Name get (pdfwrite) eq {
> ++ pop currentpagedevice /OutputDevice known {
> ++ currentpagedevice /OutputDevice get (pdfwrite) eq {
> + << /NeverEmbed [" port)
> + (display (string-concatenate
> + (map (lambda (f) (string-append " /" f))
> Index: patches/patch-scm_ps-to-png_scm
> ===================================================================
> RCS file: patches/patch-scm_ps-to-png_scm
> diff -N patches/patch-scm_ps-to-png_scm
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-scm_ps-to-png_scm 6 Nov 2023 20:23:31 -0000
> @@ -0,0 +1,43 @@
> +Fix for ghostscript 10.02.1 (finddevice removed) by backporting
> +https://gitlab.com/lilypond/lilypond/-/merge_requests/2160/diffs?commit_id=3d1a7fa40fae01c40c60344a09d0bcf01896557a
> +
> +Index: scm/ps-to-png.scm
> +--- scm/ps-to-png.scm.orig
> ++++ scm/ps-to-png.scm
> +@@ -117,7 +117,8 @@
> + (filter
> + string?
> + (list
> +- (format #f "mark /OutputFile (~a)" pngn-gs)
> ++ "<<"
> ++ (format #f "/OutputFile (~a)" pngn-gs)
> + "/GraphicsAlphaBits 4 /TextAlphaBits 4"
> + (if fit-page
> + ;; Get available resolution and magnify it according
> +@@ -132,20 +133,12 @@ currentpagedevice /HWResolution get 1 get ~a mul \
> + (format #f "/DownScaleFactor ~a" anti-alias-factor)
> + (if (or (not is-eps) fit-page)
> + (format #f "/PageSize [~a ~a]" width height))
> +- ;; We use `findprotodevice` because `finddevice` always returns
> +- ;; the same device instance and we can't reset the page number of
> +- ;; the device. `findprotodevice copydevice` creates a new device
> +- ;; instance each time, which can reset the page number.
> +- (format #f "(~a) findprotodevice copydevice" pixmap-format)
> +- "putdeviceprops setdevice"
> +- ;; We want to use `selectdevice` instead of `setdevice` because
> +- ;; `setdevice` doesn't set some defaults. But using `selectdevice`
> +- ;; can't reset the page number because `selectdevice` uses
> +- ;; `finddevice` internally. So, as a workaround, we use an
> +- ;; undocumented `.setdefaultscreen` procedure which is used inside
> +- ;; `selectdevice` to set the defaults. It works in Ghostscript
> +- ;; 9.52 but may not work if the internal implementation of
> +- ;; `selectdevice` is changed in the future.
> ++ (format #f "/OutputDevice /~a" pixmap-format)
> ++ ">> setpagedevice"
> ++ ;; `setpagedevice` does not set some defaults, creating
> ++ ;; larger output files than necessary. To fix this we use
> ++ ;; the undocumented, internal `.setdefaultscreen` procedure
> ++ ;; (tested with gs 10.02.1).
> + "/.setdefaultscreen where {"
> + "pop .setdefaultscreen"
> + "} {"
> Index: patches/patch-scripts_build_output-distance_py
> ===================================================================
> RCS file: patches/patch-scripts_build_output-distance_py
> diff -N patches/patch-scripts_build_output-distance_py
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-scripts_build_output-distance_py 6 Nov 2023 20:23:31 -0000
> @@ -0,0 +1,19 @@
> +Fix for ghostscript 10.02.1 (finddevice removed) by backporting
> +https://gitlab.com/lilypond/lilypond/-/merge_requests/2160/diffs?commit_id=3d1a7fa40fae01c40c60344a09d0bcf01896557a
> +
> +Index: scripts/build/output-distance.py
> +--- scripts/build/output-distance.py.orig
> ++++ scripts/build/output-distance.py
> +@@ -539,10 +539,10 @@ def eps_to_png(files: Dict[str, str]):
> + verbose_print = ' (processing %s\n) print ' % input_fn
> + driver.write('''
> + %s
> +- mark /OutputFile (%s)
> ++ << /OutputFile (%s)
> + /GraphicsAlphaBits 4 /TextAlphaBits 4
> + /HWResolution [101 101]
> +- (png16m) finddevice putdeviceprops setdevice
> ++ /OutputDevice /png16m >> setpagedevice
> + (%s) run
> + ''' % (verbose_print, outfile, input_fn))
> +

No comments:

Post a Comment