From 3d4701a6e41616cf581a297bab1451cf2db70249 Mon Sep 17 00:00:00 2001 From: Nils Wallménius Date: Tue, 14 Jul 2009 13:57:45 +0000 Subject: FS#10080 * Move strncpy() from core to the pluginlib * Introduce strlcpy() and use that instead in most places (use memcpy in a few) in core and some plugins * Drop strncpy() from the codec api as no codec used it * Bump codec and plugin api versions git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21863 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/dir_uncached.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'firmware/common/dir_uncached.c') diff --git a/firmware/common/dir_uncached.c b/firmware/common/dir_uncached.c index c6af145930..25677a0903 100644 --- a/firmware/common/dir_uncached.c +++ b/firmware/common/dir_uncached.c @@ -58,8 +58,7 @@ int strip_volume(const char* name, char* namecopy) name = "/"; /* else this must be the root dir */ } - strncpy(namecopy, name, MAX_PATH); - namecopy[MAX_PATH-1] = '\0'; + strlcpy(namecopy, name, MAX_PATH); return volume; } @@ -120,8 +119,7 @@ DIR_UNCACHED* opendir_uncached(const char* name) volume = strip_volume(name, namecopy); pdir->volumecounter = 0; #else - strncpy(namecopy,name,sizeof(namecopy)); /* just copy */ - namecopy[sizeof(namecopy)-1] = '\0'; + strlcpy(namecopy, name, sizeof(namecopy)); /* just copy */ #endif if ( fat_opendir(IF_MV2(volume,) &pdir->fatdir, 0, NULL) < 0 ) { @@ -204,7 +202,7 @@ struct dirent_uncached* readdir_uncached(DIR_UNCACHED* dir) if ( !entry.name[0] ) return NULL; - strncpy(theent->d_name, entry.name, sizeof( theent->d_name ) ); + strlcpy(theent->d_name, entry.name, sizeof(theent->d_name)); theent->attribute = entry.attr; theent->size = entry.filesize; theent->startcluster = entry.firstcluster; @@ -230,8 +228,7 @@ int mkdir_uncached(const char *name) return -1; } - strncpy(namecopy,name,sizeof(namecopy)); - namecopy[sizeof(namecopy)-1] = 0; + strlcpy(namecopy, name, sizeof(namecopy)); /* Split the base name and the path */ end = strrchr(namecopy, '/'); -- cgit v1.2.3