[FFmpeg-devel,5/5] avcodec/fitsdec: Fail on 0 naxisn

Submitted by Michael Niedermayer on Sept. 30, 2019, 4:30 p.m.

Details

Message ID 20190930163027.11686-5-michael@niedermayer.cc
State Accepted
Commit 4a3303d52096337dc109fbd523ecb4b46cddace1
Headers show

Commit Message

Michael Niedermayer Sept. 30, 2019, 4:30 p.m.
Fixes: Timeout (100+ sec -> 23ms)
Fixes: 17769/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FITS_fuzzer-5678314672357376

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/fitsdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul B Mahol Oct. 8, 2019, 3:47 p.m.
lgtm

On 9/30/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: Timeout (100+ sec -> 23ms)
> Fixes:
> 17769/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FITS_fuzzer-5678314672357376
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/fitsdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/fitsdec.c b/libavcodec/fitsdec.c
> index 2bb215943c..32a79cdd0d 100644
> --- a/libavcodec/fitsdec.c
> +++ b/libavcodec/fitsdec.c
> @@ -143,7 +143,7 @@ static int fits_read_header(AVCodecContext *avctx, const
> uint8_t **ptr, FITSHead
>
>      size = abs(header->bitpix) >> 3;
>      for (i = 0; i < header->naxis; i++) {
> -        if (size && header->naxisn[i] > SIZE_MAX / size) {
> +        if (size == 0 || header->naxisn[i] > SIZE_MAX / size) {
>              av_log(avctx, AV_LOG_ERROR, "unsupported size of FITS image");
>              return AVERROR_INVALIDDATA;
>          }
> --
> 2.23.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Oct. 10, 2019, 12:32 p.m.
On Tue, Oct 08, 2019 at 05:47:07PM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/fitsdec.c b/libavcodec/fitsdec.c
index 2bb215943c..32a79cdd0d 100644
--- a/libavcodec/fitsdec.c
+++ b/libavcodec/fitsdec.c
@@ -143,7 +143,7 @@  static int fits_read_header(AVCodecContext *avctx, const uint8_t **ptr, FITSHead
 
     size = abs(header->bitpix) >> 3;
     for (i = 0; i < header->naxis; i++) {
-        if (size && header->naxisn[i] > SIZE_MAX / size) {
+        if (size == 0 || header->naxisn[i] > SIZE_MAX / size) {
             av_log(avctx, AV_LOG_ERROR, "unsupported size of FITS image");
             return AVERROR_INVALIDDATA;
         }