forked from len0rd/rockbox
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
This commit is contained in:
parent
f9c5d1fccf
commit
ee05b8574a
1 changed files with 10 additions and 6 deletions
|
@ -542,7 +542,7 @@ static void update_playlist_filename(struct playlist_info* playlist,
|
||||||
static int add_indices_to_playlist(struct playlist_info* playlist,
|
static int add_indices_to_playlist(struct playlist_info* playlist,
|
||||||
char* buffer, size_t buflen)
|
char* buffer, size_t buflen)
|
||||||
{
|
{
|
||||||
unsigned int nread;
|
ssize_t nread;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
bool store_index;
|
bool store_index;
|
||||||
|
@ -572,7 +572,7 @@ static int add_indices_to_playlist(struct playlist_info* playlist,
|
||||||
|
|
||||||
p = (unsigned char *)buffer;
|
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? */
|
/* Are we on a new line? */
|
||||||
if((*p == '\n') || (*p == '\r'))
|
if((*p == '\n') || (*p == '\r'))
|
||||||
|
@ -1493,8 +1493,8 @@ static int get_next_dir(char *dir, bool is_forward)
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
int folder_count = 0;
|
int folder_count = 0;
|
||||||
read(fd,&folder_count,sizeof(int));
|
ssize_t nread = read(fd,&folder_count,sizeof(int));
|
||||||
if (folder_count)
|
if ((nread == sizeof(int)) && folder_count)
|
||||||
{
|
{
|
||||||
char buffer[MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
/* give up looking for a directory after we've had four
|
/* 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);
|
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);
|
remove_track_from_playlist(playlist, index, true);
|
||||||
steps--; /* one less track */
|
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)
|
if (playlist_remove_all_tracks(playlist) == 0)
|
||||||
position = PLAYLIST_INSERT_LAST;
|
position = PLAYLIST_INSERT_LAST;
|
||||||
else return -1;
|
else
|
||||||
|
{
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu_boost(true);
|
cpu_boost(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue