On 02.01.2016 16:56, Nicolas George wrote:
> Le tridi 13 nivôse, an CCXXIV, Andreas Cadhalpun a écrit :
>> This fixes ubsan runtime error: left shift by 8 places cannot be
>> represented in type 'int'
>>
>> Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
>> ---
>>  libavformat/ffmdec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
>> index 7b2d0d7..3162354 100644
>> --- a/libavformat/ffmdec.c
>> +++ b/libavformat/ffmdec.c
>> @@ -76,7 +76,7 @@ static int ffm_resync(AVFormatContext *s, int state)
>>              av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n");
>>              return -1;
>>          }
>> -        state = (state << 8) | avio_r8(s->pb);
>> +        state = ((unsigned)state << 8) | avio_r8(s->pb);
>>      }
>>      return 0;
>>  }
> 
> IMHO, it would be more correct to make state uint32_t (and id at the call
> site possibly too).

That alternative is fine for me, too. Patch attached.

Happy new year,
Andreas

>From a461d6e867aa0b4be7c673d69f1318eff9ffa4d5 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
Date: Sat, 2 Jan 2016 16:27:43 +0100
Subject: [PATCH 2/3] ffmdec: change type of state and id to unsigned

This fixes ubsan runtime error: left shift by 8 places cannot be
represented in type 'int'

Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
---
 libavformat/ffmdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 7b2d0d7..3ce6376 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -68,7 +68,7 @@ static int ffm_is_avail_data(AVFormatContext *s, int size)
         return AVERROR_INVALIDDATA;
 }
 
-static int ffm_resync(AVFormatContext *s, int state)
+static int ffm_resync(AVFormatContext *s, uint32_t state)
 {
     av_log(s, AV_LOG_ERROR, "resyncing\n");
     while (state != PACKET_ID) {
@@ -87,7 +87,8 @@ static int ffm_read_data(AVFormatContext *s,
 {
     FFMContext *ffm = s->priv_data;
     AVIOContext *pb = s->pb;
-    int len, fill_size, size1, frame_offset, id;
+    int len, fill_size, size1, frame_offset;
+    uint32_t id;
     int64_t last_pos = -1;
 
     size1 = size;
-- 
2.6.4

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

Reply via email to