]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
backend/ipp.c: Fix printing jobs with long names on older IPP printers
authorZdenek Dohnal <zdohnal@redhat.com>
Tue, 16 Jan 2024 12:30:17 +0000 (13:30 +0100)
committerZdenek Dohnal <zdohnal@redhat.com>
Tue, 16 Jan 2024 12:30:17 +0000 (13:30 +0100)
On older printers (ones which don't support IPP operation Create-Job)
we concatenate job number and title into one string, which we use as
IPP attribute job-name. If the original title was almost 255 chars,
the joining the strings will overflow maximal required length
for this attribute, and Validate-Job fails.

We could check whether the string is longer than 255 and cut it,
but I chose to shrink the buffer to 256, since we already use snprintf()
which will cut the string and put null terminator for us.

Fixes #644

CHANGES.md
backend/ipp.c

index a0c7edcc9a9247a6dd2bf2773ba1b78e7cbee567..b75aa434c054c7236718963b6de32c734878ca2d 100644 (file)
@@ -4,6 +4,7 @@ CHANGES - OpenPrinting CUPS 2.4.8 - TBA
 Changes in CUPS v2.4.8 (TBA)
 ----------------------------
 
+- Fixed printing of jobs with job name longer than 255 chars on older printers (Issue #644)
 - Really backport fix for Issue #742
 - Raised `cups_enum_dests()` timeout for listing available IPP printers (Issue #751)
 - Fixed memory leak when unloading a job (Issue #813)
index b5da8b88ca457bec577e2bf1484408f4f2f23034..2bbdefbd1f6a0b41bf118dae777fb0c1e1181030 100644 (file)
@@ -219,7 +219,7 @@ main(int  argc,                             /* I - Number of command-line args */
   off_t                compatsize = 0;         /* Size of compatibility file */
   int          port;                   /* Port number (not used) */
   char         uri[HTTP_MAX_URI];      /* Updated URI without user/pass */
-  char         print_job_name[1024];   /* Update job-name for Print-Job */
+  char         print_job_name[256];    /* Update job-name for Print-Job */
   http_status_t        http_status;            /* Status of HTTP request */
   ipp_status_t ipp_status;             /* Status of IPP request */
   http_t       *http;                  /* HTTP connection */
@@ -1484,6 +1484,10 @@ main(int  argc,                          /* I - Number of command-line args */
   }
   else
   {
+   /*
+    * TODO: make this compatible with UTF-8 - possible UTF-8 truncation here..
+    */
+
     snprintf(print_job_name, sizeof(print_job_name), "%s - %s", argv[1],
              argv[3]);
     monitor.job_name = print_job_name;