History

avcodec/jpegxl_parser: check entropy_decoder_read_symbol return value

Found by OSS-Fuzz.

Kacper Michajłow committed 2 years ago

Commit 7b209851 parent c845a071 file · +3 −3Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/jpegxl_parser.c+3−3
@@ -1311,7 +1311,7 @@ static int parse_frame_header(void *avctx, JXLParseContext *ctx, GetBitContext * · 1310 unmodified lines
13111311 // permuted toc
13121312 if (get_bits1(gb)) {
13131313 JXLEntropyDecoder dec;
1314− uint32_t end, lehmer = 0;
1314+ int64_t end, lehmer = 0;
13151315 ret = entropy_decoder_init(avctx, gb, &dec, 8);
13161316 if (ret < 0)
13171317 return ret;
@@ -1320,13 +1320,13 @@ static int parse_frame_header(void *avctx, JXLParseContext *ctx, GetBitContext * · 2 unmodified lines
13201320 return AVERROR_BUFFER_TOO_SMALL;
13211321 }
13221322 end = entropy_decoder_read_symbol(gb, &dec, toc_context(toc_count));
1323− if (end > toc_count) {
1323+ if (end < 0 || end > toc_count) {
13241324 entropy_decoder_close(&dec);
13251325 return AVERROR_INVALIDDATA;
13261326 }
13271327 for (uint32_t i = 0; i < end; i++) {
13281328 lehmer = entropy_decoder_read_symbol(gb, &dec, toc_context(lehmer));
1329− if (get_bits_left(gb) < 0) {
1329+ if (lehmer < 0 || get_bits_left(gb) < 0) {
13301330 entropy_decoder_close(&dec);
13311331 return AVERROR_BUFFER_TOO_SMALL;
13321332 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t