summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2023-01-04 19:54:07 +0000
committerAidan MacDonald <amachronic@protonmail.com>2023-01-06 14:19:28 -0500
commit5bb062391fc259a7bcdd4d69d587ab4adf454e97 (patch)
treeca526034fa90da4a49cb93a6047e44f0355677dd
parent5d0c382a59d84208be5ed719b510794f465ccd8b (diff)
downloadrockbox-5bb062391f.tar.gz
rockbox-5bb062391f.zip
playlist.c fix old out of bounds read
In case next_index == -1, this would read before the start of the playlist->indices buffer. Change-Id: I0a32a31c7c97c755a1217b8bea90a650f9e36a93
-rw-r--r--apps/playlist.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 80685f8655..b349799269 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -1828,7 +1828,8 @@ static int get_next_index(const struct playlist_info* playlist, int steps,
}
/* No luck if the whole playlist was bad. */
- if (playlist->indices[next_index] & PLAYLIST_SKIPPED)
+ if (next_index < 0 || next_index >= playlist->amount ||
+ playlist->indices[next_index] & PLAYLIST_SKIPPED)
return -1;
return next_index;