[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#738440: cups: new version contains Ubuntu Bug #1019662



Le lundi, 10 février 2014, 23.34:23 Till Kamppeter a écrit :
> I have fixed the problem upstream (BZR rev. 7159) now. I do not use
> PATH+MAX any more for strings which are used to hold a command line.
> Command lines have 65535 bytes now.
> 
> Please test and tell whether it solves the problem. If so, I will
> release a new cups-filters version.

At least it doesn't cause obvious regressions for me.

Till: if you release a new version, can you include your fix for the 
upstart job?

Randy: can you recompile cups-filters on your platform with the attached 
patch and confirm that it works?

Cheers, OdyX
Description: foomatic-rip: Do not use PATH_MAX for the length of static
 strings which are supposed to hold a command line. Use our own
 CMDLINE_MAX constant to set them to a length of 65535 bytes
Author: Till Kamppeter <till.kampetter@gmail.com>
Origin: upstream
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1019662
Bug-Debian: https://bugs.debian.org/738440

--- a/filter/foomatic-rip/foomaticrip.h
+++ b/filter/foomatic-rip/foomaticrip.h
@@ -76,8 +76,9 @@
 extern int spooler;
 
 #ifndef PATH_MAX
-#define PATH_MAX 65536
+#define PATH_MAX 4096
 #endif
+#define CMDLINE_MAX 65536
 
 typedef struct {
     char printer[256];
--- a/filter/foomatic-rip/foomaticrip.c
+++ b/filter/foomatic-rip/foomaticrip.c
@@ -571,7 +571,7 @@
 
             if (!ppd_supports_pdf())
             {
-                char pdf2ps_cmd[PATH_MAX];
+                char pdf2ps_cmd[CMDLINE_MAX];
                 FILE *out, *in;
                 int renderer_pid;
 		char tmpfilename[PATH_MAX] = "";
@@ -617,12 +617,12 @@
 		   We give priority to Ghostscript here and use Poppler if
 		   Ghostscript is not available. */
 		if (spooler == SPOOLER_CUPS)
-		  snprintf(pdf2ps_cmd, PATH_MAX,
+		  snprintf(pdf2ps_cmd, CMDLINE_MAX,
 			   "pdftops '%s' '%s' '%s' '%s' '%s' '%s'",
 			   job->id, job->user, job->title, "1", job->optstr->data,
 			   filename);
 		else
-		  snprintf(pdf2ps_cmd, PATH_MAX,
+		  snprintf(pdf2ps_cmd, CMDLINE_MAX,
 			   "gs -q -sstdout=%%stderr -sDEVICE=ps2write -sOutputFile=- "
 			   "-dBATCH -dNOPAUSE -dPARANOIDSAFER -dNOINTERPOLATE %s 2>/dev/null || "
 			   "pdftops -level2 -origpagesizes %s - 2>/dev/null",
--- a/filter/foomatic-rip/pdf.c
+++ b/filter/foomatic-rip/pdf.c
@@ -41,12 +41,12 @@
 
 static int pdf_count_pages(const char *filename)
 {
-    char gscommand[4095];
+    char gscommand[CMDLINE_MAX];
     char output[31] = "";
     int pagecount;
     size_t bytes;
 
-    snprintf(gscommand, 4095, "%s -dNODISPLAY -q -c "
+    snprintf(gscommand, CMDLINE_MAX, "%s -dNODISPLAY -q -c "
 	     "'/pdffile (%s) (r) file def pdfdict begin pdffile pdfopen begin "
 	     "(PageCount: ) print pdfpagecount == flush currentdict pdfclose "
 	     "end end quit'",
@@ -109,7 +109,7 @@
                              int first,
                              int last)
 {
-    char gscommand[4095];
+    char gscommand[CMDLINE_MAX];
     char filename_arg[PATH_MAX], first_arg[50], last_arg[50];
     int fd;
 
@@ -127,7 +127,7 @@
     else
         first_arg[0] = '\0';
 
-    snprintf(gscommand, 4095, "%s -q -dNOPAUSE -dBATCH -dPARANOIDSAFER -dNOINTERPOLATE"
+    snprintf(gscommand, CMDLINE_MAX, "%s -q -dNOPAUSE -dBATCH -dPARANOIDSAFER -dNOINTERPOLATE"
 	     "-sDEVICE=pdfwrite %s %s %s %s",
 	     gspath, filename_arg, first_arg, last_arg, pdffilename);
 
--- a/filter/foomatic-rip/renderer.c
+++ b/filter/foomatic-rip/renderer.c
@@ -37,11 +37,12 @@
  */
 int test_gs_output_redirection()
 {
-    char gstestcommand[PATH_MAX];
+    char gstestcommand[CMDLINE_MAX];
     char output[10] = "";
     int bytes;
 
-    snprintf(gstestcommand, PATH_MAX, "%s -dQUIET -dPARANOIDSAFER -dNOPAUSE "
+    snprintf(gstestcommand, CMDLINE_MAX,
+	     "%s -dQUIET -dPARANOIDSAFER -dNOPAUSE "
              "-dBATCH -dNOMEDIAATTRS -sDEVICE=ps2write -sstdout=%%stderr "
              "-sOutputFile=/dev/null -c '(hello\n) print flush' 2>&1", gspath);
 

Reply to: