NULL pointer dereference in `print_job()` during MIME auto-detection

Open Beginner friendly
#1,826 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c
Domain
backend, security

Research direction

Start in scheduler/ipp.c at print_job() around the reported line 8867, then inspect send_document() and trace how each handles a NULL result from mimeFileType() and mimeType(). Check the nearby tests for MIME auto-detection and add coverage for both functions with no MIME definitions; done means neither path dereferences a missing MIME type and the scheduler continues handling the request.

Written by the indexing model from the issue text.

Description

Summary
An IPP client permitted to submit print jobs can crash cupsd if document auto-typing finds no MIME type and the configured MIME database cannot supply a fallback. The crash stops the scheduler, interrupting printing for all queues it serves.

Details
In scheduler/ipp.c, print_job() calls mimeFileType() to identify the document type and falls back to mimeType(). If both return NULL, it dereferences filetype in the log call and again in snprintf(). In the tested CUPS 2.4.19 build, the crash occurred in snprintf() at scheduler/ipp.c:8867.

In both tested configurations, cupsd continued accepting IPP requests without loading any MIME definitions. send_document() checks filetype before logging but still dereferences it in the following snprintf() call. Both code paths are present in CUPS 2.4.20 and at commit d473b41.

Dominant language
C
Stars
1.8k
Forks
362
Avg merge
1d 46m
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenPrinting/cups

All issues in OpenPrinting/cups

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.