-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: secp256k1_ecmult_multi_var
is called with a NULL
error callback
#1527
Comments
Thanks, I agree with the analysis. Note that Can I ask you how you found this? Simply by eyeballing or using some (semi-)automated analysis?
Yes. (Yes!)
Hm, I don't think so. I mean, it's not wrong to do this, but our convention so far is that |
Thanks for your quick reply :)
I was running some static analysis tools against the latest release (0.5.0) and reviewed the findings from clang's static analyzer (
Ok, I created #1528
All right. This makes sense and I will not add such |
…L` error callback 9554362 tests: call secp256k1_ecmult_multi_var with a non-NULL error callback (Nicolas Iooss) Pull request description: Hello, This Pull Request fixes the issue reported in #1527. Function `secp256k1_ecmult_multi_var` expects to be called with a non-`NULL` `error_callback` parameter. Fix the invocation in `test_ecmult_accumulate` to do this. While at it, wrap the call in a `CHECK` macro to ensure it succeeds. ACKs for top commit: real-or-random: utACK 9554362 siv2r: ACK 9554362, I have also verified that other invocations of `ecmult_multi_var` (in tests) don’t use `NULL` for the error callback function argument. Tree-SHA512: 6a9f6c10c575794da75f2254d6fbbc195de889c81a371ce35ab38e2e5483aa1e25ec0bcd5aa8d6a32a1493586f73430208a4bd0613e373571d2f04d63dbc4a1c
Hello,
In the tests, function
test_ecmult_accumulate
callssecp256k1_ecmult_multi_var
witherror_callback = NULL
(since version 0.2.0, PR #920):secp256k1/src/tests.c
Lines 5497 to 5498 in 7712a53
This function eventually calls
secp256k1_scratch_max_allocation
:secp256k1/src/scratch_impl.h
Lines 58 to 60 in 7712a53
... which directly dereferences the callback parameter:
secp256k1/src/util.h
Lines 86 to 87 in 7712a53
In short, it seems
secp256k1_ecmult_multi_var
does not expecterror_callback
to beNULL
.The consequence of
test_ecmult_accumulate
not following this expectation would be a possible crash (by null pointer dereference) if something ever go wrong in the test. While this bug does not directly impactsecp256k1
library (it occurs in the test suite), I believe this issue should be fixed because I think tests should follow the calling convention of the library functions (such as not passingNULL
where functions expects non-NULL
parameters).Moreover,
CHECK()
could probably be added to verify the result ofsecp256k1_ecmult_multi_var
. Therefore, I am suggesting this change:Would such a change be acceptable? (If yes, I can submit a pull request)
Moreover, should some attributes
SECP256K1_ARG_NONNULL
be added to functions expecting non-NULL
error_callback
too?The text was updated successfully, but these errors were encountered: