streams: Add stream position validation in BufferedFile::AdvanceStream #31839

pull crStiv wants to merge 1 commits into bitcoin:master from crStiv:фффф changing 1 files +3 −0
  1. crStiv commented at 0:41 am on February 11, 2025: none

    Description: Add safety check in BufferedFile::AdvanceStream to prevent potential integer overflow when calculating bytes_until_source_pos. This ensures that m_read_pos never exceeds nSrcPos, which could lead to undefined behavior.

    The change:

    • Adds validation before calculating (nSrcPos - m_read_pos)
    • Throws std::ios_base::failure if invalid state is detected
  2. Update streams.h a88db6b66d
  3. DrahtBot commented at 0:41 am on February 11, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31839.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  4. maflcko commented at 7:06 am on February 11, 2025: member

    The prior assert with the exact same check covers this. This is adding dead code.

    Is this AI generated?

  5. maflcko closed this on Feb 11, 2025

  6. mzumsande commented at 4:57 pm on February 11, 2025: contributor

    The prior assert with the exact same check covers this. This is adding dead code.

    Fill() may be called in between, which can change nSrcPos - but it can only increase it, so yes, still dead code.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-02-22 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me