[FFmpeg-devel] [PATCH 2/3] ffmdec: cast state to unsigned for left shift

Michael Niedermayer michael at niedermayer.cc
Sat Jan 2 18:59:25 CET 2016


On Sat, Jan 02, 2016 at 05:12:13PM +0100, Andreas Cadhalpun wrote:
> 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.Cadhalpun at 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
> 

>  ffmdec.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 6c3ca0f947737208725d30a735deaea2a95531ba  0002-ffmdec-change-type-of-state-and-id-to-unsigned.patch
> From a461d6e867aa0b4be7c673d69f1318eff9ffa4d5 Mon Sep 17 00:00:00 2001
> From: Andreas Cadhalpun <Andreas.Cadhalpun at 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.Cadhalpun at googlemail.com>

LGTM

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160102/a2907b72/attachment.sig>


More information about the ffmpeg-devel mailing list