Re: [FFmpeg-devel] [PATCH] avutil/common: Fix integer overflow in av_clip_uint8_c() and av_clip_uint16_c()

2018-02-16 Thread Michael Niedermayer
On Thu, Feb 15, 2018 at 01:46:06PM +0100, Michael Niedermayer wrote:
> 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 
> ---
>  libavutil/common.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avutil/common: Fix integer overflow in av_clip_uint8_c() and av_clip_uint16_c()

2018-02-15 Thread Michael Niedermayer
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 
---
 libavutil/common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/common.h b/libavutil/common.h
index 5e0382827b..0fffa67714 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&(~0x)) return (-a)>>31;
+if (a&(~0x)) return (~a)>>31;
 else return a;
 }
 
-- 
2.16.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel