Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Potential out-of-bounds read in cupsdFindBest() with HTTP_STATE_ERROR

Closed Beginner friendly
#1,729 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
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
security

Research direction

Start in scheduler/auth.c by reading cupsdFindBest() and its caller cupsdAuthorize(), focusing on how httpGetState() supplies the state value. Verify the HTTP_STATE_ERROR path and the limits array bounds. Done means invalid states cannot cause an out-of-bounds access and the normal authorization lookup remains unchanged.

Written by the indexing model from the issue text.

Description

Potential problem

In scheduler/auth.c, the state parameter is used as an array index in cupsdFindBest():

limit = limits[state];

state is obtained from httpGetState(con->http) and passed to cupsdFindBest() by cupsdAuthorize():

con->best = cupsdFindBest(con->uri, httpGetState(con->http));

httpGetState() can return HTTP_STATE_ERROR, which is defined as -1. However, cupsdFindBest() does not validate state before using it as an array index.

If HTTP_STATE_ERROR reaches cupsdFindBest(), the code accesses limits[-1]. This reads memory before the beginning of the array and results in undefined behavior.

Possible solution

Validate state before accessing limits[state], for example:

if (state < 0 ||
    (size_t)state >= sizeof(limits) / sizeof(limits))
  return NULL;

This ensures that an invalid HTTP state cannot be used as an array index.

Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.

Author V. Ostretsov

Dominant language
C
Stars
1.8k
Forks
349
Avg merge
3d 16h
Merged PRs (30d)
12

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.