[BUG] DVB: map-table cases in dvbsub_parse_pixel_data_block read past the object field data
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 30/100
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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CCExtractor/ccextractor
-
GXF: heap buffer overflow in parse_ad_cdp() — unbounded cc_count in CDP cc data sectionPossibly taken @pranayr710 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
CCExtractor/ccextractor#2498 ·
Maintainers usually reply within 1 day
-
[BUG] + file-sequence expansion picks the digit in the extension (clip001.mp4+ only processes clip001.mp4)Possibly taken @imfarhan0105-bits claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
CCExtractor/ccextractor#2478 · 2 comments ·
Maintainers usually reply within 1 day
-
[BUG] encoders: WebVTT encoder generates invalid ## delimiter and malformed @import violating W3C specificationPossibly taken @yasar710 claimed this 7 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
CCExtractor/ccextractor#2465 · 2 comments ·
Maintainers usually reply within 1 day
-
GXF: heap buffer overflow in parse_mpeg_packet() — oversized mpeg_pic_size overflows the demuxer bufferPossibly taken @pranayr710 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
CCExtractor/ccextractor#2500 ·
Maintainers usually reply within 1 day
-
[BUG] read_exp_golomb_unsigned panics/aborts on 64 or more leading zero bits (malformed SPS)Possibly taken @Souravrajvi0 claimed this 5 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 76/100
CCExtractor/ccextractor#2470 · 2 comments ·
Maintainers usually reply within 1 day
All issues in CCExtractor/ccextractor
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: services kind: bug preview-effort: small priority: low
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Static Analysis failurePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100