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/m4a.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/m4a.c')
-rw-r--r-- | lib/rbcodec/codecs/libm4a/m4a.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/rbcodec/codecs/libm4a/m4a.c b/lib/rbcodec/codecs/libm4a/m4a.c index b63b8bad2c..1672cf300c 100644 --- a/lib/rbcodec/codecs/libm4a/m4a.c +++ b/lib/rbcodec/codecs/libm4a/m4a.c | |||
@@ -181,8 +181,6 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, | |||
181 | /* Find the chunk after 'sample_i'. */ | 181 | /* Find the chunk after 'sample_i'. */ |
182 | for (chunk = 1; chunk < demux_res->num_lookup_table; ++chunk) | 182 | for (chunk = 1; chunk < demux_res->num_lookup_table; ++chunk) |
183 | { | 183 | { |
184 | if (tco_tab[chunk].offset == 0) | ||
185 | break; | ||
186 | if (tco_tab[chunk].sample > sample_i) | 184 | if (tco_tab[chunk].sample > sample_i) |
187 | break; | 185 | break; |
188 | } | 186 | } |
@@ -287,12 +285,12 @@ unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream, | |||
287 | 285 | ||
288 | /* We know the desired byte offset, search for the chunk right before. | 286 | /* We know the desired byte offset, search for the chunk right before. |
289 | * Return the associated sample to this chunk as chunk_sample. */ | 287 | * Return the associated sample to this chunk as chunk_sample. */ |
290 | for (i=0; i < demux_res->num_lookup_table; ++i) | 288 | for (i = 1; i < demux_res->num_lookup_table; ++i) |
291 | { | 289 | { |
292 | if (demux_res->lookup_table[i].offset > file_loc) | 290 | if (demux_res->lookup_table[i].offset > file_loc) |
293 | break; | 291 | break; |
294 | } | 292 | } |
295 | i = (i>0) ? i-1 : 0; /* We want the last chunk _before_ file_loc. */ | 293 | --i; /* We want the last chunk _before_ file_loc. */ |
296 | *lookup_table_idx = i; | 294 | *lookup_table_idx = i; |
297 | chunk_sample = demux_res->lookup_table[i].sample; | 295 | chunk_sample = demux_res->lookup_table[i].sample; |
298 | new_pos = demux_res->lookup_table[i].offset; | 296 | new_pos = demux_res->lookup_table[i].offset; |