[BUG] DVB: map-table cases in dvbsub_parse_pixel_data_block read past the object field data

Open
#2,482 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@pranayr710 is already working on this.

Since Nov 23, 2026.

  • #2483 by @pranayr710 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
30/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
security

Research direction

Start in dvbsub_parse_pixel_data_block() in src/lib_ccx/dvb_subtitle_decoder.c; read the location check at the top of the loop and the string helpers that stop at buf_size, since the map cases should mirror them. For cases 0x20, 0x21 and 0x22, compare buf_end - buf against the 2, 4 or 16 operand bytes needed and set parseerror and break when short. Done looks like a truncated block ending on one of those command bytes no longer reads past buf_end. Note the reporter states a patch and PR are already planned.

Written by the indexing model from the issue text.

Description

Summary

dvbsub_parse_pixel_data_block() in src/lib_ccx/dvb_subtitle_decoder.c loops
while (!parseerror && buf < buf_end), but three of its cases read a fixed
number of operand bytes from the stream without checking any remain. The loop
condition only guarantees one byte (the command byte) before each iteration.

Where
switch (*buf++)
{
        ...
        case 0x20:                                  // 2-bit / 4-bit map
                map2to4[0] = (*buf) >> 4;
                map2to4[1] = (*buf++) & 0xf;        // reads 2 bytes
                map2to4[2] = (*buf) >> 4;
                map2to4[3] = (*buf++) & 0xf;
                break;
        case 0x21:                                  // 2-bit / 8-bit map
                for (i = 0; i < 4; i++)
                        map2to8[i] = *buf++;        // reads 4 bytes
                break;
        case 0x22:                                  // 4-bit / 8-bit map
                for (i = 0; i < 16; i++)
                        map4to8[i] = *buf++;        // reads 16 bytes
                break;

A pixel-data sub-block whose last byte is 0x20, 0x21 or 0x22 makes the
decoder read 2, 4 or up to 16 bytes past the object's field data (buf_end is
the end of top_field_len / bottom_field_len, validated in
dvbsub_parse_object_segment).

Impact

The object's field data is a slice of the larger segment/PES buffer, so these
reads land on the adjacent bytes of that buffer rather than past the allocation
— the same reason ASan does not flag it. It is still a read past the length the
block was given, in the same class as the other bounds this function already
enforces (it checks the object location before each 0x1x pixel string, and the
string helpers stop at buf_size). The map-table cases were simply missed.

Fix

Check buf_end - buf before each of the three cases and set parseerror /
break on a short block, exactly as the location check at the top of the loop
already does.

I have a patch and will open a PR referencing this issue. Found while reading
the segment parsers after the ISDB and EPG descriptor bounds fixes.

(Analysis and patch prepared with AI assistance.)

Dominant language
C
Stars
919
Forks
604
Avg merge
9d 5h
Merged PRs (30d)
26

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 CCExtractor/ccextractor

All issues in CCExtractor/ccextractor

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.