avcodec/fitsdec: Use lrint()
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 30 Sep 2019 16:30:26 +0000 (18:30 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 5 Dec 2019 19:20:05 +0000 (20:20 +0100)
Fixes: fate-fitsdec-bitpix-64

Possibly Fixes: -nan is outside the range of representable values of type 'unsigned short'
Possibly 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
tests/ref/fate/fitsdec-bitpix-32
tests/ref/fate/fitsdec-bitpix-64
tests/ref/fate/fitsdec-blank_bitpix32
tests/ref/fate/fitsdec-ext_data_min_max
tests/ref/fate/fitsdec-gray
tests/ref/lavf/gray16be.fits

index 1f06754f8b1e3ab2fc87357d3bc8d27868e2dd2a..32a79cdd0d744c1e20d91d50c26a2239abf93cda 100644 (file)
@@ -279,7 +279,7 @@ static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
             for (j = 0; j < avctx->width; j++) { \
                 t = rd; \
                 if (!header.blank_found || t != header.blank) { \
-                    *dst++ = ((t - header.data_min) * ((1 << (sizeof(type) * 8)) - 1)) * scale; \
+                    *dst++ = lrint(((t - header.data_min) * ((1 << (sizeof(type) * 8)) - 1)) * scale); \
                 } else { \
                     *dst++ = fitsctx->blank_val; \
                 } \
index 9bce3615550981c7c5ad6d620c636c203d5925c5..b3a51401d409e32ed12d3178d172a0dff02ee1a8 100644 (file)
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 102x109
 #sar 0: 0/1
-0,          0,          0,        1,    22236, 0x34490902
+0,          0,          0,        1,    22236, 0x24634517
index 9febdd68f4d58e52cf2e867fcbafeaa927337ab2..e50d5e029c6024966c71a093acc34f9b5ec00d3b 100644 (file)
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 77x173
 #sar 0: 0/1
-0,          0,          0,        1,    26642, 0x0ad2a46a
+0,          0,          0,        1,    26642, 0xa9eec634
index 184fd41c59eb77eb9f3065d3778dc558738cfffa..330d6710ca103722bdf3ab996bf6642313543e67 100644 (file)
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 256x256
 #sar 0: 0/1
-0,          0,          0,        1,   131072, 0x7fb22427
+0,          0,          0,        1,   131072, 0x3ecd0739
index 9009a4efb3492769da76fbd3b334ccb9ec12208c..006d8d62504e34860bcf30e3d004cc1475075427 100644 (file)
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 512x512
 #sar 0: 0/1
-0,          0,          0,        1,   524288, 0xc327ed23
+0,          0,          0,        1,   524288, 0x6567ecb3
index 425b31fc0f172c4a34270cbc6b07be8adda4d07a..d0807324526272a9c205888fc67c09a3e1a80ab8 100644 (file)
@@ -3,4 +3,4 @@
 #codec_id 0: rawvideo
 #dimensions 0: 128x128
 #sar 0: 0/1
-0,          0,          0,        1,    16384, 0xd788a2d2
+0,          0,          0,        1,    16384, 0x353dbacd
index 078d6c867899956cffbc18a387e2d2971524b66b..058fa4ad19cc86eaefd64bec5700f955d62e406a 100644 (file)
@@ -1,3 +1,3 @@
 15e85a553bbd07783f92377ed369308b *tests/data/lavf/lavf.gray16be.fits
 5184000 tests/data/lavf/lavf.gray16be.fits
-tests/data/lavf/lavf.gray16be.fits CRC=0x8b840cff
+tests/data/lavf/lavf.gray16be.fits CRC=0x8cdcbeb2