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 ommit message (Expand)Author 2020-12-15store-copy: 'populate-store' can optionally deduplicate files....Until now deduplication was performed as an additional pass after copying files, which involve re-traversing all the files that had just been copied. * guix/store/deduplication.scm (copy-file/deduplicate): New procedure. * tests/store-deduplication.scm ("copy-file/deduplicate"): New test. * guix/build/store-copy.scm (populate-store): Add #:deduplicate? parameter and honor it. * tests/gexp.scm ("gexp->derivation, store copy"): Pass #:deduplicate? #f to 'populate-store'. * gnu/build/image.scm (initialize-root-partition): Pass #:deduplicate? to 'populate-store'. Pass #:deduplicate? #f to 'register-closure'. * gnu/build/vm.scm (root-partition-initializer): Likewise. * gnu/build/install.scm (populate-single-profile-directory): Pass #:deduplicate? #f to 'populate-store'. * gnu/build/linux-initrd.scm (build-initrd): Likewise. * guix/scripts/pack.scm (self-contained-tarball)[import-module?]: New procedure. [build]: Pass it as an argument to 'source-module-closure'. * guix/scripts/pack.scm (squashfs-image)[build]: Wrap in 'with-extensions'. * gnu/system/linux-initrd.scm (expression->initrd)[import-module?]: New procedure. [builder]: Pass it to 'source-module-closure'. * gnu/system/install.scm (cow-store-service-type)[import-module?]: New procedure. Pass it to 'source-module-closure'. Ludovic Courtès 2020-11-21linux-initrd: Remove unnecessary timestamp reset phase....* gnu/build/linux-initrd.scm (write-cpio-archive): Mention timestamps in docstring. (build-initrd): Remove unnecessary timestamp reset phase. Ludovic Courtès 2019-09-25build: initrd: Fix "write-cpio-archive" return value....* gnu/build/linux-initrd.scm (write-cpio-archive): Really return OUTPUT on success, even when compression is disabled. Maxim Cournoyer 2018-11-21linux-initrd: 'expression->initrd' returns the complete file name....Previously 'expression->initrd' would return the directory that contains the 'initrd' file; now it returns the complete file name for that file. * gnu/system/linux-initrd.scm (expression->initrd)[builder]: Change output file name to "initrd.cpio.gz". Tail-call 'file-append' to return the complete file name. * gnu/system.scm (operating-system-initrd-file): Remove 'file-append' call. * gnu/build/linux-initrd.scm (write-cpio-archive): Check whether OUTPUT already has the ".gz" suffix; rename if before invoking GZIP if it does, and otherwise after. * gnu/system/vm.scm (expression->derivation-in-linux-vm)[builder]: Do not append "/initrd" to #$initrd. Ludovic Courtès 2018-11-07linux-initrd: Make sure 'build-initrd' can delete files....Fixes <https://bugs.gnu.org/33297>. Reported by Mark H Weaver <mhw@netris.org>. This fixes a regression introduced in 72dc64f8f720268930eed448abfc15d2a0eca3cf, which made files read-only. * gnu/build/linux-initrd.scm (build-initrd): Call 'make-file-writable' on all the files under contents/. Ludovic Courtès