Skip to content

Stack buffer overflow in channelno formatting #73

Description

@lnnew

In multiple files (text.cpp, serve.cpp, parse.cpp), channelno buffer is allocated with insufficient size (7 or 8 bytes), but sprintf writes up to 12 bytes.

// text.cpp, serve.cpp, etc.
char channelno[8]; // or [7] in some files
// c->major and c->minor are uint16_t (max 65535)
// "65535.65535" = 11 chars + 1 null terminator = 12 bytes
if (c->major + c->minor > 1)
sprintf(channelno, "%d.%d", c->major, c->minor);

this causes a stack buffer overflow when processing streams with high channel IDs.

Locations:

  • libdvbtee_server/text.cpp: lines 296, 353, 418
  • libdvbtee_server/serve.cpp: line 921
  • libdvbtee/parse.cpp: line 1029

Fix: Increase buffer size to at least 16 bytes and use snprintf.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions