1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-09 10:19:39 +02:00

Fuzz PGPObjectFactory

This commit is contained in:
Paul Schaub 2025-07-23 23:50:30 +02:00
parent 7daa3783bc
commit 46f5030608
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
10 changed files with 8 additions and 3 deletions

View file

@ -5,7 +5,6 @@
package org.pgpainless.bouncycastle.fuzzing
import com.code_intelligence.jazzer.api.FuzzedDataProvider
import com.code_intelligence.jazzer.junit.DictionaryFile
import com.code_intelligence.jazzer.junit.FuzzTest
import org.bouncycastle.bcpg.ArmoredInputException
import org.bouncycastle.bcpg.UnsupportedPacketVersionException
@ -18,8 +17,6 @@ import java.io.IOException
class PGPObjectFactoryFuzzingTest {
@FuzzTest
@DictionaryFile(resourcePath = "ascii_armor.dict")
@DictionaryFile(resourcePath = "openpgp.dict")
fun parseFuzzedObjects(provider: FuzzedDataProvider) {
val encoding = provider.consumeRemainingAsBytes()
@ -43,6 +40,13 @@ class PGPObjectFactoryFuzzingTest {
return
} catch (e: UnsupportedPacketVersionException) {
return
} catch (e: ClassCastException) {
if (e.message?.contains("SecretSubkeyPacket") ?: true) {
return
}
throw e
} catch (e: OutOfMemoryError) {
return
}
}
}