mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-30 23:02:15 +00:00
Restrict scope of NPE check for Bouncy Castle bug.
This commit is contained in:
parent
85c9950d9e
commit
3680c7f52f
@ -323,12 +323,17 @@ public class ECKey implements Serializable {
|
|||||||
// OpenSSL deviates from the DER spec by interpreting these values as unsigned, though they should not be
|
// OpenSSL deviates from the DER spec by interpreting these values as unsigned, though they should not be
|
||||||
// Thus, we always use the positive versions.
|
// Thus, we always use the positive versions.
|
||||||
// See: http://r6.ca/blog/20111119T211504Z.html
|
// See: http://r6.ca/blog/20111119T211504Z.html
|
||||||
|
try {
|
||||||
return signer.verifySignature(data, r.getPositiveValue(), s.getPositiveValue());
|
return signer.verifySignature(data, r.getPositiveValue(), s.getPositiveValue());
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
// Bouncy Castle contains a bug that can cause NPEs given specially crafted signatures. Those signatures
|
||||||
|
// are inherently invalid/attack sigs so we just fail them here rather than crash the thread.
|
||||||
|
System.err.println("Caught NPE inside bouncy castle: " + e);
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (NullPointerException e) {
|
|
||||||
// Bug in BouncyCastle can cause this for invalid signatures.
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user