aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-02-14 03:54:13 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2018-04-13 00:35:15 +0200
commit519d48c861a91f3c458e37478d0e408aa608117c (patch)
treedcfa9e972706b00ea1ed856c1bb424823702b6e5
parent878fc42a906d13cd6a78b0820eed75f4fd8e26e5 (diff)
downloadffmpeg-519d48c861a91f3c458e37478d0e408aa608117c.tar.gz
avutil/common: Fix integer overflow in av_clip_uint8_c() and av_clip_uint16_c()
Fixes: 5567/clusterfuzz-testcase-minimized-5769966247739392 Fixes: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit ab6f571ef71967da7c7c1cfba483d3597c7357d5) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavutil/common.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavutil/common.h b/libavutil/common.h
index 8142b31fdb..53e43feb3a 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -158,7 +158,7 @@ static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, in
*/
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
{
- if (a&(~0xFF)) return (-a)>>31;
+ if (a&(~0xFF)) return (~a)>>31;
else return a;
}
@@ -180,7 +180,7 @@ static av_always_inline av_const int8_t av_clip_int8_c(int a)
*/
static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
{
- if (a&(~0xFFFF)) return (-a)>>31;
+ if (a&(~0xFFFF)) return (~a)>>31;
else return a;
}