summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-08-01 21:31:10 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2021-08-02 02:27:43 +0000
commit2346a7aa6dbba06118d09220a9ec5893cfb5ff0c (patch)
treea2956554f7da4e504935ad97589afbdad5f3a899
parent83653023d4c25267a298d242ba1a9bee68db8ff3 (diff)
playlist_catalog fix strcpy overlap, potential buffer overrun
Change-Id: I7cd1302d2c905992078351a531a5d67fdb465809
-rw-r--r--apps/playlist_catalog.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index d100023b1b..ba12ff6d98 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -87,11 +87,14 @@ static int initialize_catalog(void)
mkdir(playlist_dir);
}
+ playlist_dir_length = strlen(playlist_dir);
+
/* remove duplicate leading '/' */
if (playlist_dir[0] == '/' && playlist_dir[1] == '/')
- strcpy(playlist_dir, &playlist_dir[1]);
-
- playlist_dir_length = strlen(playlist_dir);
+ {
+ memmove(&playlist_dir[0], &playlist_dir[1], playlist_dir_length); /* gets the \0 too */
+ playlist_dir_length--;
+ }
if (dir_exists(playlist_dir))
{
@@ -125,7 +128,8 @@ void catalog_set_directory(const char* directory)
}
else
{
- strcpy(global_settings.playlist_catalog_dir, directory);
+ strlcpy(global_settings.playlist_catalog_dir,
+ directory, sizeof(global_settings.playlist_catalog_dir));
}
initialized = false;
initialize_catalog();