From 53f728a0aec357f22f04af2d8cceccac8ff4237b Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Sat, 27 Mar 2004 02:52:59 +0000 Subject: just to be carfile, make sure to null terminate when using strncpy git-svn-id: https://svn.musicpd.org/mpd/trunk@506 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 6fbb14d0b..ef6cf3a5e 100644 --- a/src/main.c +++ b/src/main.c @@ -331,11 +331,15 @@ int main(int argc, char * argv[]) { initTables(); initPlaylist(); - if(!options.dbFile) { + if(!options.dbFile) { strncpy(directorydb,playlistDir,MAXPATHLEN); + directorydb[MAXPATHLEN] = '\0'; strncat(directorydb,"/.mpddb",MAXPATHLEN-strlen(playlistDir)); } - else strncpy(directorydb,options.dbFile,MAXPATHLEN); + else { + strncpy(directorydb,options.dbFile,MAXPATHLEN); + directorydb[MAXPATHLEN] = '\0'; + } if(options.createDB>0 || readDirectoryDB()<0) { if(options.createDB<0) { ERROR("can't open db file and using \"--no-create-db\"" -- cgit v1.2.3