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

未关闭
#2,482 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@pranayr710 已经在做这个了。

开始于 2026年11月23日。

  • #2483 来自 @pranayr710 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
security

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.)

主要语言
C
星标
919
派生
604
平均合并
9 天 5 小时
30 天内合并 PR
26

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

CCExtractor/ccextractor 的其他 Issue

查看 CCExtractor/ccextractor 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。