Verify multiple APNG lengths to prevent bad input from crashing.

This commit is contained in:
Cody Henthorne
2026-06-10 15:20:00 -04:00
parent 029b91066f
commit e468156c4c
5 changed files with 166 additions and 22 deletions
@@ -25,7 +25,7 @@ class ApngInputStreamFactoryResourceDecoder : ResourceDecoder<InputStreamFactory
@Throws(IOException::class)
override fun decode(source: InputStreamFactory, width: Int, height: Int, options: Options): Resource<ApngDecoder>? {
val decoder = ApngDecoder.create { source.create() }
val decoder = ApngDecoder.create(contentLength = source.length()) { source.create() }
return ApngResource(decoder)
}
}
@@ -39,7 +39,7 @@ internal class EncryptedApngCacheDecoder(private val secret: ByteArray) : Encryp
@Throws(IOException::class)
override fun decode(source: File, width: Int, height: Int, options: Options): Resource<ApngDecoder>? {
val decoder = ApngDecoder.create { createEncryptedInputStream(secret, source) }
val decoder = ApngDecoder.create(contentLength = source.length()) { createEncryptedInputStream(secret, source) }
return ApngResource(decoder)
}
}