Check that the recovery id is valid

It must be 0,1,2 or 3, this is an explicit requirement of the secp256k1 library.
This commit is contained in:
sstone
2023-12-11 11:53:56 +01:00
parent 41eac9273f
commit 929e2cda40
3 changed files with 6 additions and 1 deletions

View File

@@ -637,7 +637,7 @@ JNIEXPORT jbyteArray JNICALL Java_fr_acinq_secp256k1_Secp256k1CFunctions_secp256
return NULL;
if (jmsg == NULL)
return NULL;
CHECKRESULT(recid < 0 || recid > 3, "recid must be 0, 1, 2 or 3")
sigSize = (*penv)->GetArrayLength(penv, jsig);
int sigFormat = GetSignatureFormat(sigSize);
CHECKRESULT(sigFormat == SIG_FORMAT_UNKNOWN, "invalid signature size");