diff options
author | roman.artiukhin <bahusdrive@gmail.com> | 2023-09-18 13:36:12 +0300 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2023-09-22 10:37:38 -0400 |
commit | a45204f5df18843674c8072f95817e24aed4ff27 (patch) | |
tree | fa9d0824af395f5bbd937904fb7ed9317718a753 /lib/rbcodec/codecs/libm4a/demux.c | |
parent | 57a47ef67a64f24cb5d4baa196e08448d4eeec08 (diff) | |
download | rockbox-a45204f5df18843674c8072f95817e24aed4ff27.tar.gz rockbox-a45204f5df18843674c8072f95817e24aed4ff27.zip |
Codecs: mp4: Fix seek in files with single element in lookup_table
lookup_table offset shouldn't be zero terminated.
And fix possible out of bound access.
Change-Id: I212a5fcc1868a2ca519b0052b170e836276fe9de
Diffstat (limited to 'lib/rbcodec/codecs/libm4a/demux.c')
-rw-r--r-- | lib/rbcodec/codecs/libm4a/demux.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/rbcodec/codecs/libm4a/demux.c b/lib/rbcodec/codecs/libm4a/demux.c index 8a424c5187..47cce9857f 100644 --- a/lib/rbcodec/codecs/libm4a/demux.c +++ b/lib/rbcodec/codecs/libm4a/demux.c | |||
@@ -524,7 +524,7 @@ static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len) | |||
524 | stream_seek(qtmovie->stream, qtmovie->res->sample_to_chunk_offset); | 524 | stream_seek(qtmovie->stream, qtmovie->res->sample_to_chunk_offset); |
525 | stream_read_sample_to_chunk(qtmovie->stream, &old_first, &old_frame); | 525 | stream_read_sample_to_chunk(qtmovie->stream, &old_first, &old_frame); |
526 | stream_read_sample_to_chunk(qtmovie->stream, &new_first, &new_frame); | 526 | stream_read_sample_to_chunk(qtmovie->stream, &new_first, &new_frame); |
527 | for (k = 1; k < numentries; ++k) | 527 | for (k = 1; k < numentries + 1; ++k) |
528 | { | 528 | { |
529 | for (; i < qtmovie->res->num_sample_to_chunks; ++i) | 529 | for (; i < qtmovie->res->num_sample_to_chunks; ++i) |
530 | { | 530 | { |
@@ -548,9 +548,11 @@ static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len) | |||
548 | qtmovie->res->lookup_table[idx++].sample = frame + (k - old_first) * old_frame; | 548 | qtmovie->res->lookup_table[idx++].sample = frame + (k - old_first) * old_frame; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | /* zero-terminate the lookup table */ | 551 | /* zero-terminate sample if it wasn't calculated */ |
552 | qtmovie->res->lookup_table[idx].sample = 0; | 552 | if (idx < fit_numentries) |
553 | qtmovie->res->lookup_table[idx].offset = 0; | 553 | { |
554 | qtmovie->res->lookup_table[idx].sample = 0; | ||
555 | } | ||
554 | 556 | ||
555 | stream_seek(qtmovie->stream, current_offset); | 557 | stream_seek(qtmovie->stream, current_offset); |
556 | if (size_remaining) | 558 | if (size_remaining) |