Repository navigation
Guard against NULL filetype in print_job() and send_document() (Issue #1826) - #1827
Open
LangerSword wants to merge 1 commit into
Open
LangerSword wants to merge 1 commit into
LangerSword wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 noneletting cupsd run with an unusable one), bothmimeFileType()and themimeType()fallback return NULL.print_job()then dereferences the NULLfiletypein the[Job ???] Request file type is %s/%s.log call — before the existingelse if (!filetype)rejection further down can run — andsend_document()has the identical unguardeddocument-format-detectedsnprintf. 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 withdocument-format application/octet-stream):Fix: wrap the log +
document-format-detectedblock inif (filetype) { ... }in bothprint_job()andsend_document(), mirroring the already-guarded log insend_document(). No signature or behavior changes otherwise; the existingelse if (!filetype)paths then reject the job withclient-error-document-format-not-supportedinstead 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-streamviamimeAddType(). 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.)