[FFmpeg-cvslog] avcodec/png: more informative error message for invalid sBIT size

Leo Izen git at videolan.org
Fri Jul 19 04:34:30 EEST 2024


ffmpeg | branch: master | Leo Izen <leo.izen at gmail.com> | Fri Jul 12 15:03:17 2024 -0400| [90e28331c7887b83d7c508bea71735ae12dad177] | committer: Leo Izen

avcodec/png: more informative error message for invalid sBIT size

If the sBIT chunk size is invalid, we should print a more informative
error message rather than return an error and print nothing.

Signed-off-by: Leo Izen <leo.izen at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=90e28331c7887b83d7c508bea71735ae12dad177
---

 libavcodec/pngdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index b0d02c97dd..cb861e5f60 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1086,8 +1086,11 @@ static int decode_sbit_chunk(AVCodecContext *avctx, PNGDecContext *s,
 
     channels = s->color_type & PNG_COLOR_MASK_PALETTE ? 3 : ff_png_get_nb_channels(s->color_type);
 
-    if (bytestream2_get_bytes_left(gb) != channels)
+    if (bytestream2_get_bytes_left(gb) != channels) {
+        av_log(avctx, AV_LOG_ERROR, "Invalid sBIT size: %d, expected: %d\n",
+            bytestream2_get_bytes_left(gb), channels);
         return AVERROR_INVALIDDATA;
+    }
 
     for (int i = 0; i < channels; i++) {
         int b = bytestream2_get_byteu(gb);



More information about the ffmpeg-cvslog mailing list