scratch: reject sizes that overflow when added to header #1910

pull theStack wants to merge 1 commits into bitcoin-core:master from theStack:scratch_create-avoid-wrapping-sizes changing 2 files +14 −2
  1. theStack commented at 5:40 PM on August 5, 2026: contributor

    We only use scratch space internally, so this is not an issue for the user (scratch API functions have been removed since 0.6.0, see #1620), but fixing this might still make sense to prepare for the unlikely case that we expose the scratch API again in the future. An alternative could be to simply delete the scratch space functionality already, as e.g. done in PR #1789.

    Reported by Project Loupe

  2. scratch: reject sizes that overflow when added to header
    We only use scratch space internally, so this is not an issue for the
    user (scratch API functions have been removed since 0.6.0), but fixing
    this might still make sense to prepare for the unlikely case that we
    expose the scratch API again in the future. An alternative could be
    to simply delete the scratch space functionality already, as e.g. done
    in PR #1789.
    3d4340d173
  3. in src/tests.c:426 in 3d4340d173
     419 | @@ -420,6 +420,12 @@ static void run_scratch_tests(void) {
     420 |      CHECK(secp256k1_scratch_alloc(&CTX->error_callback, scratch, SIZE_MAX) == NULL);
     421 |      secp256k1_scratch_space_destroy(CTX, scratch);
     422 |  
     423 | +    /* Creating a scratch space whose size would wrap around when the aligned
     424 | +     * header size is added to it fails, both for SIZE_MAX and for the smallest
     425 | +     * size that still wraps. */
     426 | +    CHECK(secp256k1_scratch_space_create(CTX, SIZE_MAX) == NULL);
    


    l0rinc commented at 7:42 PM on August 5, 2026:
  4. theStack added the label assurance on Aug 7, 2026
  5. theStack added the label tweak/refactor on Aug 7, 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-08-10 19:15 UTC

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