summaryrefslogtreecommitdiff
path: root/apps/playlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 1d291cf6d0..b70fdc8a1f 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -1349,8 +1349,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek,
1349 1349
1350 if (playlist->in_ram && !control_file && max < 0) 1350 if (playlist->in_ram && !control_file && max < 0)
1351 { 1351 {
1352 strncpy(tmp_buf, &playlist->buffer[seek], sizeof(tmp_buf)); 1352 strlcpy(tmp_buf, &playlist->buffer[seek], sizeof(tmp_buf));
1353 tmp_buf[MAX_PATH] = '\0';
1354 max = strlen(tmp_buf) + 1; 1353 max = strlen(tmp_buf) + 1;
1355 } 1354 }
1356 else if (max < 0) 1355 else if (max < 0)
@@ -1402,8 +1401,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek,
1402 } 1401 }
1403 } 1402 }
1404 1403
1405 strncpy(dir_buf, playlist->filename, playlist->dirlen-1); 1404 strlcpy(dir_buf, playlist->filename, playlist->dirlen);
1406 dir_buf[playlist->dirlen-1] = 0;
1407 1405
1408 return (format_track_path(buf, tmp_buf, buf_length, max, dir_buf)); 1406 return (format_track_path(buf, tmp_buf, buf_length, max, dir_buf));
1409} 1407}
@@ -1471,8 +1469,7 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion)
1471 else 1469 else
1472 { 1470 {
1473 /* start with current directory */ 1471 /* start with current directory */
1474 strncpy(dir, playlist->filename, playlist->dirlen-1); 1472 strlcpy(dir, playlist->filename, playlist->dirlen);
1475 dir[playlist->dirlen-1] = '\0';
1476 } 1473 }
1477 1474
1478 /* use the tree browser dircache to load files */ 1475 /* use the tree browser dircache to load files */
@@ -1671,13 +1668,13 @@ static int format_track_path(char *dest, char *src, int buf_length, int max,
1671 1668
1672 if('/' == src[0]) 1669 if('/' == src[0])
1673 { 1670 {
1674 strncpy(dest, src, buf_length); 1671 strlcpy(dest, src, buf_length);
1675 } 1672 }
1676 else 1673 else
1677 { 1674 {
1678 /* handle dos style drive letter */ 1675 /* handle dos style drive letter */
1679 if (':' == src[1]) 1676 if (':' == src[1])
1680 strncpy(dest, &src[2], buf_length); 1677 strlcpy(dest, &src[2], buf_length);
1681 else if (!strncmp(src, "../", 3)) 1678 else if (!strncmp(src, "../", 3))
1682 { 1679 {
1683 /* handle relative paths */ 1680 /* handle relative paths */
@@ -1904,7 +1901,7 @@ void playlist_init(void)
1904 struct playlist_info* playlist = &current_playlist; 1901 struct playlist_info* playlist = &current_playlist;
1905 1902
1906 playlist->current = true; 1903 playlist->current = true;
1907 strncpy(playlist->control_filename, PLAYLIST_CONTROL_FILE, 1904 strlcpy(playlist->control_filename, PLAYLIST_CONTROL_FILE,
1908 sizeof(playlist->control_filename)); 1905 sizeof(playlist->control_filename));
1909 playlist->fd = -1; 1906 playlist->fd = -1;
1910 playlist->control_fd = -1; 1907 playlist->control_fd = -1;
@@ -2721,7 +2718,7 @@ int playlist_set_current(struct playlist_info* playlist)
2721 2718
2722 empty_playlist(&current_playlist, false); 2719 empty_playlist(&current_playlist, false);
2723 2720
2724 strncpy(current_playlist.filename, playlist->filename, 2721 strlcpy(current_playlist.filename, playlist->filename,
2725 sizeof(current_playlist.filename)); 2722 sizeof(current_playlist.filename));
2726 2723
2727 current_playlist.utf8 = playlist->utf8; 2724 current_playlist.utf8 = playlist->utf8;
@@ -3240,7 +3237,7 @@ char *playlist_name(const struct playlist_info* playlist, char *buf,
3240 if (!playlist) 3237 if (!playlist)
3241 playlist = &current_playlist; 3238 playlist = &current_playlist;
3242 3239
3243 strncpy(buf, playlist->filename+playlist->dirlen, buf_size); 3240 strlcpy(buf, playlist->filename+playlist->dirlen, buf_size);
3244 3241
3245 if (!buf[0]) 3242 if (!buf[0])
3246 return NULL; 3243 return NULL;
@@ -3260,7 +3257,7 @@ char *playlist_get_name(const struct playlist_info* playlist, char *buf,
3260 if (!playlist) 3257 if (!playlist)
3261 playlist = &current_playlist; 3258 playlist = &current_playlist;
3262 3259
3263 strncpy(buf, playlist->filename, buf_size); 3260 strlcpy(buf, playlist->filename, buf_size);
3264 3261
3265 if (!buf[0]) 3262 if (!buf[0])
3266 return NULL; 3263 return NULL;