ffmpeg/libavcodec
Andreas Cadhalpun 435b0ab969 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>
(cherry picked from commit 22e960ad478e568f4094971a58c6ad8f549c0180)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-17 21:20:29 +01:00
..
2014-11-13 19:01:08 +01:00
2015-03-10 23:33:57 +01:00
2015-04-20 04:11:23 +02:00
2015-06-04 22:37:01 +02:00
2015-02-21 20:38:13 +01:00
2015-06-04 23:10:56 +02:00
2015-04-22 17:45:51 +02:00
2015-06-18 22:09:01 +02:00
2014-12-18 23:27:14 +01:00
2015-02-06 19:07:29 +01:00
2014-11-14 20:25:02 +01:00
2015-04-29 20:13:59 +02:00
2015-04-18 14:14:24 -03:00
2015-11-12 02:55:45 +01:00
2015-05-06 17:50:09 +02:00
2014-10-28 12:22:03 +01:00
2014-10-28 15:30:05 +01:00
2015-03-14 14:05:25 +01:00
2015-06-06 16:02:19 +00:00
2014-10-24 09:53:42 +03:00
2015-02-10 14:20:32 +00:00
2015-03-02 19:32:23 +01:00
2015-07-19 10:01:30 +02:00
2015-06-08 19:11:27 +02:00
2015-07-19 09:37:19 +02:00
2015-11-14 03:03:38 +01:00
2015-05-31 15:03:31 +02:00
2015-05-25 16:08:08 +02:00
2015-05-07 07:19:52 -04:00
2015-05-31 15:03:31 +02:00
2014-11-25 02:00:06 +00:00
2015-05-20 15:50:58 +02:00
2015-01-17 13:01:26 +01:00
2015-01-15 01:25:16 +01:00
2014-12-20 11:29:19 +01:00
2015-01-22 01:47:54 +01:00
2014-12-03 11:56:22 +01:00
2015-01-22 01:49:04 +01:00
2015-01-22 01:49:04 +01:00
2015-01-13 17:27:45 +01:00
2015-01-11 12:15:03 +01:00
2014-11-16 23:48:38 +01:00
2015-07-19 09:36:13 +02:00
2014-10-27 20:55:57 +01:00
2014-11-25 02:00:27 +01:00
2015-11-12 02:55:46 +01:00
2015-11-12 02:55:45 +01:00
2015-03-16 13:04:47 +01:00
2014-10-22 23:12:38 +02:00
2015-02-06 21:02:08 +01:00
2015-02-14 12:48:41 +00:00
2015-05-13 00:41:38 +02:00
2015-04-18 18:07:54 -03:00
2015-05-31 15:03:31 +02:00
2015-02-04 09:45:41 +00:00
2015-01-19 17:12:09 +01:00