1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-23 04:42:06 +01:00

Fix NPE when validating broken signature

This commit is contained in:
Paul Schaub 2022-03-07 14:56:56 +01:00
parent f1f7dec8b6
commit 3fe78ab12a
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -575,6 +575,10 @@ public final class SignatureSubpacketsUtil {
* @return last occurrence of the subpacket in the vector
*/
public static <P extends org.bouncycastle.bcpg.SignatureSubpacket> P getSignatureSubpacket(PGPSignatureSubpacketVector vector, SignatureSubpacket type) {
if (vector == null) {
// Almost never happens, but may be caused by broken signatures.
return null;
}
org.bouncycastle.bcpg.SignatureSubpacket[] allPackets = vector.getSubpackets(type.getCode());
if (allPackets.length == 0) {
return null;