Commit d9ba767d authored by Mans Rullgard's avatar Mans Rullgard

musepack: fix signed shift overflow in mpc_read_packet()

Using an unsigned variable avoids problems with overflows.
There is further no need for a 64-bit intermediate here.
Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
parent 028a2375
...@@ -117,7 +117,8 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -117,7 +117,8 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
{ {
MPCContext *c = s->priv_data; MPCContext *c = s->priv_data;
int ret, size, size2, curbits, cur = c->curframe; int ret, size, size2, curbits, cur = c->curframe;
int64_t tmp, pos; unsigned tmp;
int64_t pos;
if (c->curframe >= c->fcount && c->fcount) if (c->curframe >= c->fcount && c->fcount)
return -1; return -1;
...@@ -134,8 +135,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -134,8 +135,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
if(curbits <= 12){ if(curbits <= 12){
size2 = (tmp >> (12 - curbits)) & 0xFFFFF; size2 = (tmp >> (12 - curbits)) & 0xFFFFF;
}else{ }else{
tmp = (tmp << 32) | avio_rl32(s->pb); size2 = (tmp << (curbits - 12) | avio_rl32(s->pb) >> (44 - curbits)) & 0xFFFFF;
size2 = (tmp >> (44 - curbits)) & 0xFFFFF;
} }
curbits += 20; curbits += 20;
avio_seek(s->pb, pos, SEEK_SET); avio_seek(s->pb, pos, SEEK_SET);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment