On 2025-03-18 07:50, Martin-Éric Racine wrote: > Yes or just follow what dpkg-source says when it notifies you that you > have modified the source and generates the patch template for you.
Here is my patch, then. Plus a small postscript test document with an extra short title to demonstrate the difference in file name without my patch (generating job 29): [~]$ aptitude show printer-driver-cups-pdf Package: printer-driver-cups-pdf Version: 3.0.1-20 State: installed Automatically installed: no Priority: optional Section: graphics Maintainer: Debian CUPS Maintainers <debian-print...@lists.debian.org> Architecture: amd64 [...] [~]$ ls -al ~/tmp/transfer/print/ total 8 drwxr-xr-x 2 farblos farblos 4096 Mar 21 21:45 . drwxr-xr-x 5 farblos farblos 4096 Mar 19 17:56 .. [~]$ lpr -o Title=0 ~/tmp/test.ps [~]$ ls -al ~/tmp/transfer/print/ total 12 drwxr-xr-x 2 farblos farblos 4096 Mar 21 21:45 . drwxr-xr-x 5 farblos farblos 4096 Mar 19 17:56 .. -rw------- 1 farblos farblos 1608 Mar 21 21:45 Y_ome_farblos_tmp_transfer_print-job_29.pdf And with my patch (generating job 30): [~]$ aptitude show printer-driver-cups-pdf Package: printer-driver-cups-pdf Version: 3.0.1-20.1 State: installed Automatically installed: no Priority: optional Section: graphics Maintainer: Debian CUPS Maintainers <debian-print...@lists.debian.org> Architecture: amd64 [...] [~]$ ls -al ~/tmp/transfer/print/ total 12 drwxr-xr-x 2 farblos farblos 4096 Mar 21 21:45 . drwxr-xr-x 5 farblos farblos 4096 Mar 19 17:56 .. -rw------- 1 farblos farblos 1608 Mar 21 21:45 Y_ome_farblos_tmp_transfer_print-job_29.pdf [~]$ lpr -o Title=0 ~/tmp/test.ps [~]$ ls -al ~/tmp/transfer/print/ total 16 drwxr-xr-x 2 farblos farblos 4096 Mar 21 21:48 . drwxr-xr-x 5 farblos farblos 4096 Mar 19 17:56 .. -rw------- 1 farblos farblos 1608 Mar 21 21:48 Y-job_30.pdf -rw------- 1 farblos farblos 1608 Mar 21 21:45 Y_ome_farblos_tmp_transfer_print-job_29.pdf Please let me know if that is OK for you. Thanks Jens
test.ps
Description: PostScript document
diff -Nru cups-pdf-3.0.1/debian/changelog cups-pdf-3.0.1/debian/changelog --- cups-pdf-3.0.1/debian/changelog 2025-03-08 15:25:05.000000000 +0100 +++ cups-pdf-3.0.1/debian/changelog 2025-03-21 21:28:54.000000000 +0100 @@ -1,3 +1,11 @@ +cups-pdf (3.0.1-20.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Fixed file name derived from in-PostScript title being garbled because of + sscanf not adding a null byte for the %c format specifier (Closes: #912933). + + -- Farblos <farb...@vodafonemail.de> Fri, 21 Mar 2025 21:28:54 +0100 + cups-pdf (3.0.1-20) unstable; urgency=medium * [bug-presubj] diff -Nru cups-pdf-3.0.1/debian/patches/03_fixed-file-name-being-garbled.patch cups-pdf-3.0.1/debian/patches/03_fixed-file-name-being-garbled.patch --- cups-pdf-3.0.1/debian/patches/03_fixed-file-name-being-garbled.patch 1970-01-01 01:00:00.000000000 +0100 +++ cups-pdf-3.0.1/debian/patches/03_fixed-file-name-being-garbled.patch 2025-03-21 21:28:54.000000000 +0100 @@ -0,0 +1,53 @@ +Index: cups-pdf-3.0.1/src/cups-pdf.c +=================================================================== +--- cups-pdf-3.0.1.orig/src/cups-pdf.c ++++ cups-pdf-3.0.1/src/cups-pdf.c +@@ -702,11 +702,14 @@ static char *fgets2(char *fbuffer, int f + return result; + } + ++/* argument title must be set up by the caller with enough room ++ for BUFSIZE char's */ + static int preparespoolfile(FILE *fpsrc, char *spoolfile, char *title, char *cmdtitle, + int job, struct passwd *passwd) { + cp_string buffer; + int rec_depth,is_title=0; + FILE *fpdest; ++ const char *titleformat; + + if (fpsrc == NULL) { + log_event(CPERROR, "failed to open source stream"); +@@ -736,12 +739,20 @@ static int preparespoolfile(FILE *fpsrc, + break; + } + } ++ /* determine title line format depending on the line ++ delimiter(s) that might get added by fgets2 in variable ++ buffer. Whatever is matched by %[...] (plus a terminating ++ null byte) will fit into argument title. */ ++ if (Conf_FixNewlines) ++ titleformat = "%%%%Title: %[^\n\f\r]"; ++ else ++ titleformat = "%%%%Title: %[^\n]"; + log_event(CPDEBUG, "now extracting postscript code"); + (void) fputs(buffer, fpdest); + while (fgets2(buffer, BUFSIZE, fpsrc) != NULL) { + (void) fputs(buffer, fpdest); + if (!is_title && !rec_depth) +- if (sscanf(buffer, "%%%%Title: %"TBUFSIZE"c", title)==1) { ++ if (sscanf(buffer, titleformat, title)==1) { + log_event(CPDEBUG, "found title in ps code: %s", title); + is_title=1; + } +Index: cups-pdf-3.0.1/src/cups-pdf.h +=================================================================== +--- cups-pdf-3.0.1.orig/src/cups-pdf.h ++++ cups-pdf-3.0.1/src/cups-pdf.h +@@ -33,7 +33,6 @@ + #define CPDEBUG 4 + + #define BUFSIZE 4096 +-#define TBUFSIZE "4096" + + typedef char cp_string[BUFSIZE]; + diff -Nru cups-pdf-3.0.1/debian/patches/series cups-pdf-3.0.1/debian/patches/series --- cups-pdf-3.0.1/debian/patches/series 2024-06-07 21:37:02.000000000 +0200 +++ cups-pdf-3.0.1/debian/patches/series 2025-03-21 21:28:54.000000000 +0100 @@ -1,2 +1,3 @@ 01_debian_changes_to_cups-pdf_conf.patch 02_remove-deprecated-ghostscript-setpdfwrite-operator.patch +03_fixed-file-name-being-garbled.patch