aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/fits.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-05-05 18:38:33 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-05-06 23:58:34 +0200
commit0b5c93b276a14d1990aaabd77410a562f4b242c3 (patch)
tree3e5ad40a973702b7c5e0c8f7f71d13dfe4d7a6fe /libavcodec/fits.c
parente668260ba948f728a0dd7dbff289327c07b1e8b0 (diff)
downloadffmpeg-0b5c93b276a14d1990aaabd77410a562f4b242c3.tar.gz
avcodec/fits: Check bitpix
Reference: Table 8: Interpretation of valid BITPIX value from FITS standard 4.0 Fixes: runtime error: division by zero Fixes: 14581/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FITS_fuzzer-5652382425284608 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/fits.c')
-rw-r--r--libavcodec/fits.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavcodec/fits.c b/libavcodec/fits.c
index 365347fc64..ad73ab70de 100644
--- a/libavcodec/fits.c
+++ b/libavcodec/fits.c
@@ -138,6 +138,17 @@ int avpriv_fits_header_parse_line(void *avcl, FITSHeader *header, const uint8_t
case STATE_BITPIX:
CHECK_KEYWORD("BITPIX");
CHECK_VALUE("BITPIX", bitpix);
+
+ switch(header->bitpix) {
+ case 8:
+ case 16:
+ case 32: case -32:
+ case 64: case -64: break;
+ default:
+ av_log(avcl, AV_LOG_ERROR, "invalid value of BITPIX %d\n", header->bitpix); \
+ return AVERROR_INVALIDDATA;
+ }
+
dict_set_if_not_null(metadata, keyword, value);
header->state = STATE_NAXIS;