Avoid passing out-of-bound pointers to 0-size memcpy #879

pull sipa wants to merge 1 commits into bitcoin-core:master from sipa:202101_no_zero_memcpy changing 3 files +4 −4
  1. sipa commented at 5:57 AM on January 24, 2021: contributor

    Doing so could be considered UB in a pedantic interpretation of the standard. Avoid it.

    Closes #876.

  2. Avoid passing out-of-bound pointers to 0-size memcpy
    Doing so could be considered UB in a strict reading of the standard.
    Avoid it.
    9570f674cc
  3. practicalswift commented at 7:50 AM on January 24, 2021: contributor

    cr ACK 9570f674cc729cafcba65f4cce03552d9a6108f4: patch looks correct

  4. real-or-random commented at 5:53 PM on January 24, 2021: contributor

    When we change the contrib functions, we should also consider changing the copies in Bitcoin Core, see #781 edit: What I'm saying is: Let's take care of this in #781.

    Can you also change the comparison in the same function here https://github.com/bitcoin-core/secp256k1/blob/9570f674cc729cafcba65f4cce03552d9a6108f4/src/ecdsa_impl.h#L115

    to read rlen > (size_t)(sigend - *sig) ? This will never compute an out-of-bounds pointer (which is another case of pedantic UB).

  5. real-or-random commented at 6:46 AM on June 11, 2021: contributor

    @sipa ping

  6. real-or-random commented at 8:19 AM on June 16, 2021: contributor

    ACK 9570f674cc729cafcba65f4cce03552d9a6108f4

    I'll open a new PR for the other issue

  7. real-or-random merged this on Jun 16, 2021
  8. real-or-random closed this on Jun 16, 2021

  9. real-or-random referenced this in commit 920a0e5fa6 on Oct 17, 2021
  10. Fabcien referenced this in commit 7380db86f5 on Jan 9, 2026
  11. Fabcien referenced this in commit d53ad18aed on Jan 9, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:52 UTC