History

avcodec/jpegxl_parser: fix reading lz77-pair as initial entropy symbol

The JPEG XL parser has an entropy decoder inside, which supports LZ77 length-distance pairs. If the first symbol from the entropy stream is an LZ77 pair, the bitstream is invalid, so we should abort immediately rather than attempt to read it anyway (which would read from the uninitialized starting window).

Leo Izen committed 2 years ago

Commit 18883fb1 parent a5dabfc1 file · +3 −0Browse files

Unified · Split

libavcodec/jpegxl_parser.c+3−0
@@ -352,6 +352,8 @@ static int decode_hybrid_varlen_uint(GetBitContext *gb, JXLEntropyDecoder *dec, · 351 unmodified lines
352 352
353 if (bundle->lz77_enabled && token >= bundle->lz77_min_symbol) {353 if (bundle->lz77_enabled && token >= bundle->lz77_min_symbol) {
354 const JXLSymbolDistribution *lz77dist = &bundle->dists[bundle->cluster_map[bundle->num_dist - 1]];354 const JXLSymbolDistribution *lz77dist = &bundle->dists[bundle->cluster_map[bundle->num_dist - 1]];
355 if (!dec->num_decoded)
356 return AVERROR_INVALIDDATA;
355 ret = read_hybrid_uint(gb, &bundle->lz_len_conf, token - bundle->lz77_min_symbol, &dec->num_to_copy);357 ret = read_hybrid_uint(gb, &bundle->lz_len_conf, token - bundle->lz77_min_symbol, &dec->num_to_copy);
356 if (ret < 0)358 if (ret < 0)
357 return ret;359 return ret;
@@ -531,6 +533,7 @@ static int read_dist_clustering(GetBitContext *gb, JXLEntropyDecoder *dec, JXLDi · 173 unmodified lines
531 dec->state = -1;533 dec->state = -1;
532 /* it's not going to necessarily be zero after reading */534 /* it's not going to necessarily be zero after reading */
533 dec->num_to_copy = 0;535 dec->num_to_copy = 0;
536 dec->num_decoded = 0;
534 dist_bundle_close(&nested);537 dist_bundle_close(&nested);
535 if (use_mtf) {538 if (use_mtf) {
536 uint8_t mtf[256];539 uint8_t mtf[256];

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