Skip to content

Fix incorrect boundary check in CVE-2020-0499 patch for FLAC bitreader - #205

Closed
MatPoliquin with Copilot wants to merge 2 commits into
masterfrom
copilot/check-for-bugs-in-pr
Closed

Fix incorrect boundary check in CVE-2020-0499 patch for FLAC bitreader#205
MatPoliquin with Copilot wants to merge 2 commits into
masterfrom
copilot/check-for-bugs-in-pr

Conversation

Copilot AI commented Jan 1, 2026

Copy link
Copy Markdown
Contributor

PR #179 attempts to fix CVE-2020-0499 in FLAC's bitreader but uses br->capacity (allocated buffer size) instead of br->words (actual valid data). This still allows reading uninitialized memory between valid data and buffer end.

Changes

  • cores/genesis/core/cd_hw/libchdr/deps/libFLAC/bitreader.c: Change boundary check from capacity to words
  • cores/pce/deps/flac-1.3.2/src/libFLAC/bitreader.c: Change boundary check from capacity to words
// PR #179 (incorrect - checks allocated size)
b = cwords < br->capacity ? br->buffer[cwords] << br->consumed_bits : 0;

// This PR (correct - checks actual data)
b = cwords < words ? br->buffer[cwords] << br->consumed_bits : 0;

The words variable is set to br->words two lines above and represents completed words in buffer. This matches the boundary check pattern used elsewhere in the same function (line 866) and the original xiph/flac security fix.

Original prompt

#179

This PR doesn't introduce any bugs right?


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: MatPoliquin <7024551+MatPoliquin@users.noreply.github.com>
Copilot AI changed the title [WIP] Review PR for potential bugs Fix incorrect boundary check in CVE-2020-0499 patch for FLAC bitreader Jan 1, 2026
Copilot AI requested a review from MatPoliquin January 1, 2026 03:58
@MatPoliquin
MatPoliquin deleted the copilot/check-for-bugs-in-pr branch February 16, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants