From 2fb6b2b4588ec1e22ca1043eaa12695ade9d7bf9 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 25 Jul 2018 18:33:10 +0200 Subject: Fix truncation warning playlist.c, tree.c Change-Id: I0c62f06fea3ccb55efa21b719a44a263dedc32e2 --- apps/playlist.c | 7 ++++--- apps/tree.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/playlist.c b/apps/playlist.c index 20bd048181..f566999212 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -416,7 +416,8 @@ static int check_control(struct playlist_info* playlist) */ static int recreate_control(struct playlist_info* playlist) { - char temp_file[MAX_PATH+1]; + const char file_suffix[] = "_temp\0"; + char temp_file[MAX_PATH + sizeof(file_suffix)]; int temp_fd = -1; int i; int result = 0; @@ -432,8 +433,8 @@ static int recreate_control(struct playlist_info* playlist) close(playlist->control_fd); playlist->control_fd = 0; - snprintf(temp_file, sizeof(temp_file), "%s_temp", - playlist->control_filename); + snprintf(temp_file, sizeof(temp_file), "%s%s", + playlist->control_filename, file_suffix); if (rename(playlist->control_filename, temp_file) < 0) return -1; diff --git a/apps/tree.c b/apps/tree.c index 8efccf5549..e03a494a54 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -908,7 +908,7 @@ static int dirbrowse(void) bool create_playlist(void) { - char filename[MAX_PATH]; + char filename[MAX_PATH + 16]; /* add enough space for extension */ if (tc.currdir[1]) snprintf(filename, sizeof filename, "%s.m3u8", tc.currdir); -- cgit v1.2.3