`get_options()` repeats the first byte when hex-encoding octet strings

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

Maintainers usually reply within 1 day

@rue19 is already working on this.

Since Nov 26, 2026.

  • #1831 by @rue19 — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
backend

Research direction

In scheduler/job.c, inspect the hexadecimal output loop in get_options() and compare how the neighboring quoted-string branch advances its input pointer. Change the loop so it emits two hexadecimal digits for each input byte in order; done when 41 0A 42 encodes as 410A42 instead of 414141. The issue does not name a test, so look for an existing test that exercises print filter option encoding.

Written by the indexing model from the issue text.

Description

In scheduler/job.c, the hexadecimal branch of get_options() advances the output pointer but not the input pointer. Each iteration formats *valptr, so a multi-byte octet string that takes this branch is serialized as repetitions of its first byte. Print filters receive a different value from the one supplied.

Expected: Emit two hexadecimal digits for each input byte, in order.

Actual: The first byte is emitted once per input byte. For example, at the encoder level, 41 0A 42 should become <410A42> but the loop produces <414141>. This example is derived from the loop, not an end-to-end print test.

Suggested fix: Advance valptr once per iteration in the hex output loop, as the neighboring quoted-string branch already does.

The hex output loop was introduced in commit 5483fd294, which addressed Apple CUPS issue #5558. That issue concerned handling length-delimited octet strings, not this repeated-byte defect. The later octet-string scan fix advances the pointer while deciding whether to hex-encode, but does not change the hex output loop.

Dominant language
C
Stars
1.8k
Forks
367
Avg merge
12h 18m
Merged PRs (30d)
5

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.