Skip to content

Guard against NULL filetype in print_job() and send_document() (Issue #1826) - #1827

Open
LangerSword wants to merge 1 commit into
OpenPrinting:2.4.xfrom
LangerSword:fix/1826-print-job-null-filetype
Open

LangerSword wants to merge 1 commit into
OpenPrinting:2.4.xfrom
LangerSword:fix/1826-print-job-null-filetype

Conversation

@LangerSword

Copy link
Copy Markdown

Fixes #1826 (full repro, backtrace, and analysis in the issue thread).

Root cause: when document auto-typing cannot resolve a MIME type (MIME database that loads 0 types, or FatalErrors none letting cupsd run with an unusable one), both mimeFileType() and the mimeType() fallback return NULL. print_job() then dereferences the NULL filetype in the [Job ???] Request file type is %s/%s. log call — before the existing else if (!filetype) rejection further down can run — and send_document() has the identical unguarded document-format-detected snprintf. One IPP Print-Job in this state crashes the scheduler for every queue it serves.

Reproduced under gdb on a clean v2.4.20 build (0-type MIME database + FatalErrors none + Print-Job with document-format application/octet-stream):

#0  _cups_safe_vsnprintf (...) at debug.c:585
#1  format_log_line (...) at log.c:1339
#2  cupsdLogMessage (...) at log.c:773
#3  print_job (con=..., uri=...) at ipp.c:8908
#4  cupsdProcessIPPRequest ... #7 main

Fix: wrap the log + document-format-detected block in if (filetype) { ... } in both print_job() and send_document(), mirroring the already-guarded log in send_document(). No signature or behavior changes otherwise; the existing else if (!filetype) paths then reject the job with client-error-document-format-not-supported instead of crashing.

Verified with the same repro on two builds carrying this change (a patched v2.4.20 build and a build of this 2.4.x branch): the Print-Job gets Unsupported document-format "application/octet-stream"., the scheduler stays up and serving, and repeated jobs are all rejected cleanly.

Note for master: the same log call is still unguarded there too (ipp.c:8963 on current master) — it is only safe because conf.c seeds application/octet-stream via mimeAddType(). Happy to send the small consistency guard for master as a follow-up.

(AI agent assisted the repro and analysis; the crash, backtrace, and fixed behavior were verified by hand.)

Copilot AI lite review requested due to automatic review settings November 20, 2026 23:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants