summaryrefslogtreecommitdiffstats
path: root/apps/playlist.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-07-30 00:04:25 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2021-07-30 00:40:43 -0400
commitee05b8574a84fa7a46d6f0453b60a611c1bcc813 (patch)
tree1d4d974c004635bfa9f57171714a7ee4d5516e7e /apps/playlist.c
parentf9c5d1fccf2b82b2f1eb6c3e525643e9d3ba6264 (diff)
downloadrockbox-ee05b8574a84fa7a46d6f0453b60a611c1bcc813.tar.gz
rockbox-ee05b8574a84fa7a46d6f0453b60a611c1bcc813.zip
playlist.c fix multitude of sins Invalid Control file on USB unplug?
failure to close file handles reading memory prior to buffer on error loop variable integer overflow on error Change-Id: I2893c34cd041d085fd7f56a88cb4cb14131cea11
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 7cd264e821..2e28fc859d 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -542,7 +542,7 @@ static void update_playlist_filename(struct playlist_info* playlist,
static int add_indices_to_playlist(struct playlist_info* playlist,
char* buffer, size_t buflen)
{
- unsigned int nread;
+ ssize_t nread;
unsigned int i = 0;
unsigned int count = 0;
bool store_index;
@@ -572,7 +572,7 @@ static int add_indices_to_playlist(struct playlist_info* playlist,
p = (unsigned char *)buffer;
- for(count=0; count < nread; count++,p++) {
+ for(count=0; count < (unsigned int)nread; count++,p++) {
/* Are we on a new line? */
if((*p == '\n') || (*p == '\r'))
@@ -1493,8 +1493,8 @@ static int get_next_dir(char *dir, bool is_forward)
if (fd >= 0)
{
int folder_count = 0;
- read(fd,&folder_count,sizeof(int));
- if (folder_count)
+ ssize_t nread = read(fd,&folder_count,sizeof(int));
+ if ((nread == sizeof(int)) && folder_count)
{
char buffer[MAX_PATH];
/* give up looking for a directory after we've had four
@@ -2703,7 +2703,7 @@ int playlist_next(int steps)
{
index = get_next_index(playlist, i, -1);
- if (playlist->indices[index] & PLAYLIST_QUEUE_MASK)
+ if (index >= 0 && playlist->indices[index] & PLAYLIST_QUEUE_MASK)
{
remove_track_from_playlist(playlist, index, true);
steps--; /* one less track */
@@ -3151,7 +3151,11 @@ int playlist_insert_playlist(struct playlist_info* playlist, const char *filenam
{
if (playlist_remove_all_tracks(playlist) == 0)
position = PLAYLIST_INSERT_LAST;
- else return -1;
+ else
+ {
+ close(fd);
+ return -1;
+ }
}
cpu_boost(true);