History

avcodec/hcadec: do not set hfr_group_count to invalid values

Fixes: 62285/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HCA_fuzzer-6247136417087488 Fixes: out of array write

Michael Niedermayer committed 2 years ago

Commit addb85e1 parent 0a114d71 file · +4 −2Browse files

Unified · Split

libavcodec/hcadec.c+4−2
@@ -212,6 +212,7 @@ static int init_hca(AVCodecContext *avctx, const uint8_t *extradata, · 211 unmodified lines
212 int8_t r[16] = { 0 };212 int8_t r[16] = { 0 };
213 unsigned b, chunk;213 unsigned b, chunk;
214 int version, ret;214 int version, ret;
215 unsigned hfr_group_count;
215 216
216 init_flush(avctx);217 init_flush(avctx);
217 218
@@ -336,11 +337,12 @@ static int init_hca(AVCodecContext *avctx, const uint8_t *extradata, · 118 unmodified lines
336 if (c->total_band_count < c->base_band_count)337 if (c->total_band_count < c->base_band_count)
337 return AVERROR_INVALIDDATA;338 return AVERROR_INVALIDDATA;
338 339
339 c->hfr_group_count = ceil2(c->total_band_count - (c->base_band_count + c->stereo_band_count),340 hfr_group_count = ceil2(c->total_band_count - (c->base_band_count + c->stereo_band_count),
340 c->bands_per_hfr_group);341 c->bands_per_hfr_group);
341 342
342 if (c->base_band_count + c->stereo_band_count + (unsigned long)c->hfr_group_count > 128ULL)343 if (c->base_band_count + c->stereo_band_count + (uint64_t)hfr_group_count > 128ULL)
343 return AVERROR_INVALIDDATA;344 return AVERROR_INVALIDDATA;
345 c->hfr_group_count = hfr_group_count;
344 346
345 for (int i = 0; i < avctx->ch_layout.nb_channels; i++) {347 for (int i = 0; i < avctx->ch_layout.nb_channels; i++) {
346 c->ch[i].chan_type = r[i];348 c->ch[i].chan_type = r[i];

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