diff options
author | Leo Izen <leo.izen@gmail.com> | 2024-07-19 12:04:19 -0400 |
---|---|---|
committer | Leo Izen <leo.izen@gmail.com> | 2024-07-30 05:43:31 -0400 |
commit | 825606641b11f3f1f5c5efb0f95501b2c2d34d50 (patch) | |
tree | d335ae2e0236f1cb5498448ae96522128a05c5b6 /libavcodec | |
parent | e2105b2800d99cf878c8bf7ed56e7162fca2952e (diff) | |
download | ffmpeg-825606641b11f3f1f5c5efb0f95501b2c2d34d50.tar.gz |
avcodec/pngdec: use 8-bit sBIT cap for indexed PNGs per spec
The PNG specification[1] says that sBIT entries must be at most the bit
depth specified in IHDR, unless the PNG is indexed-color, in which case
sBIT must be between 1 and 8. We should not reject valid sBITs on PNGs
with indexed color.
[1]: https://www.w3.org/TR/png-3/#11sBIT
Regression since 84b454935fae2633a8a5dd075e22393f3e8f932f.
Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reported-by: Ramiro Polla <ramiro.polla@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/pngdec.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index cb861e5f60..c5b32c166d 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1097,7 +1097,7 @@ static int decode_sbit_chunk(AVCodecContext *avctx, PNGDecContext *s, bits = FFMAX(b, bits); } - if (bits < 0 || bits > s->bit_depth) { + if (bits <= 0 || bits > (s->color_type & PNG_COLOR_MASK_PALETTE ? 8 : s->bit_depth)) { av_log(avctx, AV_LOG_ERROR, "Invalid significant bits: %d\n", bits); return AVERROR_INVALIDDATA; } |