ffmpeg/libavcodec
Andreas Cadhalpun 22e960ad47 golomb: always check for invalid UE golomb codes in get_ue_golomb
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: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-14 20:51:39 +01:00
..
2015-12-04 02:35:42 +01:00
2015-08-22 06:16:31 +01:00
2015-11-30 18:29:57 -05:00
2015-11-22 16:16:16 -05:00
2015-10-29 21:26:43 +01:00
2015-11-21 08:51:49 -05:00
2015-06-14 15:09:33 +02:00
2015-10-08 23:29:18 +02:00
2015-08-18 10:24:01 -04:00
2015-11-30 10:58:46 -05:00
2015-11-06 13:45:50 +01:00
2015-09-10 16:36:47 +02:00
2015-12-11 10:22:09 -05:00
2015-10-13 16:03:04 +02:00
2015-10-26 10:08:01 +01:00
2015-09-03 13:55:38 +02:00
2015-12-07 16:10:51 +01:00
2015-10-09 22:09:08 +02:00
2015-08-11 23:16:35 +02:00
2015-07-27 16:21:14 +01:00
2015-10-25 22:48:04 +01:00
2015-11-12 13:16:25 +01:00
2015-08-21 08:46:05 +02:00
2015-08-21 08:46:05 +02:00
2015-11-17 01:23:10 +01:00
2015-11-14 02:37:12 +01:00
2015-11-20 08:20:13 -05:00
2015-10-11 17:29:50 -03:00
2015-06-17 20:11:43 +02:00
2015-11-30 23:31:12 +01:00
2015-11-30 23:31:12 +01:00
2015-08-18 11:48:49 -04:00
2015-09-06 14:06:44 +02:00
2015-07-22 23:23:29 +02:00
2015-10-26 23:23:59 -07:00
2015-08-15 15:06:01 +02:00
2015-08-18 11:48:49 -04:00
2015-10-09 22:09:08 +02:00
2015-09-07 15:32:08 +02:00
2015-08-03 10:12:10 +02:00
2015-12-07 09:38:59 +01:00
2015-12-07 09:38:59 +01:00
2015-12-07 09:25:02 +01:00
2015-07-27 15:24:58 +01:00