• Andreas Cadhalpun's avatar
    golomb: always check for invalid UE golomb codes in get_ue_golomb · 22e960ad
    Andreas Cadhalpun authored
    Also correct the check to reject log < 7, because UPDATE_CACHE only
    guarantees 25 meaningful bits.
    
    This fixes undefined behavior:
    runtime error: shift exponent is negative
    
    Testing with START/STOP timers in get_ue_golomb, one for the first
    branch (A) and one for the second (B), shows that there is practically no
    slowdown, e.g. for the cavs decoder:
    
    With the check in the B branch:
        629 decicycles in get_ue_golomb B, 4194260 runs,     44 skips
        433 decicycles in get_ue_golomb A,268434102 runs,   1354 skips
    
    Without the check:
        624 decicycles in get_ue_golomb B, 4194273 runs,     31 skips
        433 decicycles in get_ue_golomb A,268434203 runs,   1253 skips
    
    Since the B branch is executed far less often than the A branch, this
    change is negligible, even more so for the h264 decoder, where the ratio
    B/A is a lot smaller.
    
    Fixes: mozilla bug 1230239
    Fixes: fbeb8b2c7c996e9b91c6b1af319d7ebc/asan_heap-oob_195450f_2743_e8856ece4579ea486670be2b236099a0.bit
    
    Found-by: Tyson Smith
    Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
    Reviewed-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
    Signed-off-by: 's avatarAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
    22e960ad
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libpostproc Loading commit data...
libswresample Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
INSTALL.md Loading commit data...
LICENSE.md Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
RELEASE Loading commit data...
arch.mak Loading commit data...
cmdutils.c Loading commit data...
cmdutils.h Loading commit data...
cmdutils_common_opts.h Loading commit data...
cmdutils_opencl.c Loading commit data...
common.mak Loading commit data...
configure Loading commit data...
ffmpeg.c Loading commit data...
ffmpeg.h Loading commit data...
ffmpeg_dxva2.c Loading commit data...
ffmpeg_filter.c Loading commit data...
ffmpeg_opt.c Loading commit data...
ffmpeg_qsv.c Loading commit data...
ffmpeg_vdpau.c Loading commit data...
ffmpeg_videotoolbox.c Loading commit data...
ffplay.c Loading commit data...
ffprobe.c Loading commit data...
ffserver.c Loading commit data...
ffserver_config.c Loading commit data...
ffserver_config.h Loading commit data...
library.mak Loading commit data...
version.sh Loading commit data...