[Pkg-bitcoin-commits] [libsecp256k1] 07/45: JNI: Only call ecdsa_verify if its inputs parsed correctly
Jonas Smedegaard
dr at jones.dk
Sat Aug 27 12:00:01 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository libsecp256k1.
commit a40c701c8393849f894ede74bb7c70e5f2ac694d
Author: Jon Griffiths <jon_p_griffiths at yahoo.com>
Date: Mon May 2 23:21:33 2016 +1200
JNI: Only call ecdsa_verify if its inputs parsed correctly
Return 0 otherwise instead of calling it with bad parameters.
---
src/java/org_bitcoin_NativeSecp256k1.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/java/org_bitcoin_NativeSecp256k1.c b/src/java/org_bitcoin_NativeSecp256k1.c
index 8224929..0171c44 100644
--- a/src/java/org_bitcoin_NativeSecp256k1.c
+++ b/src/java/org_bitcoin_NativeSecp256k1.c
@@ -48,7 +48,6 @@ SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1ve
{
secp256k1_context *ctx = (secp256k1_context*)ctx_l;
- int result;
unsigned char* data = (unsigned char*) (*env)->GetDirectBufferAddress(env, byteBufferObject);
const unsigned char* sigdata = { (unsigned char*) (data + 32) };
const unsigned char* pubdata = { (unsigned char*) (data + siglen + 32) };
@@ -60,13 +59,15 @@ SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1ve
if( ret ) {
ret = secp256k1_ec_pubkey_parse(ctx, &pubkey, pubdata, publen);
+
+ if( ret ) {
+ ret = secp256k1_ecdsa_verify(ctx, &sig, data, &pubkey);
+ }
}
(void)classObject;
- result = secp256k1_ecdsa_verify(ctx, &sig, data, &pubkey);
-
- return result;
+ return ret;
}
SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1sign
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/libsecp256k1.git
More information about the Pkg-bitcoin-commits
mailing list