aboutsummaryrefslogtreecommitdiffstats
path: root/src/ls.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ls.c b/src/ls.c
index 5cda6605e..376ebb058 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -128,12 +128,14 @@ int lsPlaylists(int fd, char *utf8path)
strcat(s, "/");
while ((ent = readdir(dir))) {
+ size_t len = strlen(ent->d_name) + 1;
dup = ent->d_name;
- if (dup[0] != '.' &&
+ if (mpd_likely(len <= maxlen) &&
+ dup[0] != '.' &&
(suff = strlen(dup) - suflen) > 0 &&
dup[suff] == '.' &&
strcmp(dup + suff + 1, PLAYLIST_FILE_SUFFIX) == 0) {
- strncpy(s + actlen, ent->d_name, maxlen);
+ memcpy(s + actlen, ent->d_name, len);
if (stat(s, &st) == 0) {
if (S_ISREG(st.st_mode)) {
if (list == NULL)