Skip to content

Commit d959811

Browse files
committed
backend/ipp.c: Fix printing jobs with long names on older IPP printers
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
1 parent 89f7f5d commit d959811

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Changes in CUPS v2.5b1 (TBA)
2727
- Fixed Digest authentication support (Issue #260)
2828
- Fixed extensive looping in scheduler (Issue #604)
2929
- Fixed printing multiple files on specific printers (Issue #643)
30+
- Fixed printing of jobs with job name longer than 255 chars on older printers (Issue #644)
3031
- Fixed segfault in `cupsGetNamedDest()` when trying to get default printer, but
3132
the default printer is not set (Issue #719)
3233
- Fixed ready media support for iOS 17+ (Issue #738)

backend/ipp.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ main(int argc, /* I - Number of command-line args */
216216
off_t compatsize = 0; /* Size of compatibility file */
217217
int port; /* Port number (not used) */
218218
char uri[HTTP_MAX_URI]; /* Updated URI without user/pass */
219-
char print_job_name[1024]; /* Update job-name for Print-Job */
219+
char print_job_name[256]; /* Update job-name for Print-Job */
220220
http_status_t http_status; /* Status of HTTP request */
221221
ipp_status_t ipp_status; /* Status of IPP request */
222222
http_t *http; /* HTTP connection */
@@ -1464,6 +1464,10 @@ main(int argc, /* I - Number of command-line args */
14641464
}
14651465
else
14661466
{
1467+
/*
1468+
* TODO: make this compatible with UTF-8 - possible UTF-8 truncation here..
1469+
*/
1470+
14671471
snprintf(print_job_name, sizeof(print_job_name), "%s - %s", argv[1],
14681472
argv[3]);
14691473
monitor.job_name = print_job_name;

0 commit comments

Comments
 (0)