Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SECP256K1] Prevent arithmetic on NULL pointer if the scratch space i…
…s too small Summary: ``` If the scratch space is too small when calling `secp256k1_ecmult_strauss_batch()`, the `state.pre_a` allocation will fail and the pointer will be `NULL`. This causes `state.pre_a_lam` to be computed from the `NULL` pointer. It is also possible that the first allocation to fail is for `state.ps`, which will cause the failure to occur when in `secp256k1_ecmult_strauss_wnaf()`. The issue has been detected by UBSAN using Clang 10: CC=clang \ CFLAGS="-fsanitize=undefined -fno-omit-frame-pointer" \ LDFLAGS="-fsanitize=undefined -fno-omit-frame-pointer" \ ../configure UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 make check ``` Backport of secp256k1 [[bitcoin-core/secp256k1#839 | PR839]]. Test Plan: With Clang and UBSAN: ninja check-secp256k1 Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D8265
- Loading branch information