From a9181df87d78828318f2e9f8d4ea012bc06883b9 Mon Sep 17 00:00:00 2001 From: Bruno Victal Date: Thu, 7 Sep 2023 16:51:23 +0100 Subject: [PATCH 3/3] Fix double-free when requesting MediaBox. Explicitly close the Ghostscript PDF interpreter before calling quit. References: [1]: [2]: --- src/u_ghostscript.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/u_ghostscript.c b/src/u_ghostscript.c index 5974b31..d14674f 100644 --- a/src/u_ghostscript.c +++ b/src/u_ghostscript.c @@ -317,10 +317,10 @@ gsexe(FILE **out, bool *isnew, char *exenew, char *exeold) * Call ghostscript to extract the /MediaBox from the pdf given in file. * Command line, for gs >= 9.50, * gs -q -dNODISPLAY --permit-file-read=in.pdf -c \ - * "(in.pdf) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == quit" + * "(in.pdf) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == runpdfend quit" * gs < 9.50: * gs -q -dNODISPLAY -dNOSAFER -c \ - * "(in.pdf) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == quit" + * "(in.pdf) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == runpdfend quit" * The command line was found, and modified a bit, at *https://stackoverflow.com/questions/2943281/using-ghostscript-to-get-page-size * Beginning with gs 9.50, "-dSAFER" is the default, and permission to access @@ -349,9 +349,11 @@ gsexe_mediabox(char *file, int *llx, int *lly, int *urx, int *ury) return -3; exenew = "%s -q -dNODISPLAY \"--permit-file-read=%s\" -c \"(%s) (r) " - "file runpdfbegin 1 pdfgetpage /MediaBox pget pop == quit\""; + "file runpdfbegin 1 pdfgetpage /MediaBox pget pop == " + "runpdfend quit\""; exeold = "%s -q -dNODISPLAY -c \"(%s) (r) " - "file runpdfbegin 1 pdfgetpage /MediaBox pget pop == quit\""; + "file runpdfbegin 1 pdfgetpage /MediaBox pget pop == " + "runpdfend quit\""; /* malloc() buffers for the command line, if necessary */ fmt = exenew; @@ -445,7 +447,8 @@ gslib_mediabox(char *file, int *llx, int *lly, int *urx, int *ury) argnew[3] = "--permit-file-read=%s"; /* file */ argnew[4] = "-c"; argnew[5] = - "(%s) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == quit"; + "(%s) (r) file runpdfbegin 1 pdfgetpage /MediaBox pget pop == " + "runpdfend quit"; argold[0] = argnew[0]; argold[1] = argnew[1]; -- 2.40.1 d>2023-10-28grafts: Fix corner case involving multiple-output derivations....Fixes a bug that would occur with references to two outputs of the same derivation, with one of them referring to the other one. For example, the references of libreoffice include both mariadb:dev and mariadb:lib; additionally, mariadb:dev refers to mariadb:lib. In this case, the glibc graft would not be applied on one of the mariadb paths, and both the grafted and ungrafted glibc would end up in the closure of libreoffice. Fixes <https://issues.guix.gnu.org/66662>. * guix/grafts.scm (non-self-references): Simplify and include references to outputs of DRV other than OUTPUTS. (reference-origins): Simplify and possibly return outputs of DRV itself. (cumulative-grafts)[graft-origin?]: Add OUTPUT parameter and honor it. [dependency-grafts]: Adjust accordingly. * tests/grafts.scm ("graft-derivation, multiple outputs need to be replaced"): New test. Change-Id: Iac2005024ab7049037537b3af55298696ec90e3c Ludovic Courtès