summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2023-09-06 21:05:53 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2023-09-09 21:16:35 -0400
commit6b0e3fe775f6bdd52f3442447832271bbf613497 (patch)
tree2399906e74973fa5d297aa75057ff97020aec799
parentb3abb271792914e7037d69ee5e2dc78ae1e2f048 (diff)
downloadrockbox-6b0e3fe775.tar.gz
rockbox-6b0e3fe775.zip
Codecs: mp4: Improve support for long files, prevent endless loop
pretty unlikely but I think in a memory exaustion scenario you might roll the uint8 over to zero and crash Change-Id: If73dc64484f2d363446be068aa7bf8025407a2a7
-rw-r--r--lib/rbcodec/codecs/libm4a/demux.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/rbcodec/codecs/libm4a/demux.c b/lib/rbcodec/codecs/libm4a/demux.c
index ae3c34fde4..cd1b6c6077 100644
--- a/lib/rbcodec/codecs/libm4a/demux.c
+++ b/lib/rbcodec/codecs/libm4a/demux.c
@@ -475,14 +475,14 @@ static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len)
{
qtmovie->res->lookup_table = malloc(fit_numentries * sizeof(*qtmovie->res->lookup_table));
- if (qtmovie->res->lookup_table)
+ if (qtmovie->res->lookup_table || (++accuracy_divider == 0))
{
break;
}
else
{
// we failed to alloc memory for lookup table, so reduce seek accuracy and try again
- fit_numentries = numentries / ++accuracy_divider;
+ fit_numentries = numentries / accuracy_divider;
}
}
DEBUGF("lookup_table numentries %d, fit_numentries %d\n", numentries, fit_numentries);