engine: common: soundlib: libmpg: backport fix for CVE-2017-12839.

Original patch: https://www.mpg123.de/cgi-bin/scm/mpg123/trunk/src/libmpg123/getbits.h?view=patch&r1=2024&r2=4323
Same as: 8a5e21a2a2
This commit is contained in:
Andrey Akhmichin 2023-01-25 04:22:31 +05:00 committed by Alibek Omarov
parent 84c14b32ec
commit ffd5c2d3d0

View File

@ -47,6 +47,10 @@ static uint getbits( mpg123_handle_t *fr, int number_of_bits )
{ {
ulong rval; ulong rval;
if( (long)(fr->wordpointer-fr->bsbuf)*8
+ fr->bitindex+number_of_bits > (long)fr->framesize*8 )
return 0;
rval = fr->wordpointer[0]; rval = fr->wordpointer[0];
rval <<= 8; rval <<= 8;
rval |= fr->wordpointer[1]; rval |= fr->wordpointer[1];