mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-02 13:37:24 +00:00
Restrict scope of NPE check for Bouncy Castle bug.
This commit is contained in:
@@ -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
|
||||
// Thus, we always use the positive versions.
|
||||
// See: http://r6.ca/blog/20111119T211504Z.html
|
||||
return signer.verifySignature(data, r.getPositiveValue(), s.getPositiveValue());
|
||||
try {
|
||||
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) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (NullPointerException e) {
|
||||
// Bug in BouncyCastle can cause this for invalid signatures.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user