summaryrefslogtreecommitdiff
path: root/firmware/common/dir_uncached.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common/dir_uncached.c')
-rw-r--r--firmware/common/dir_uncached.c11
1 files changed, 4 insertions, 7 deletions
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)
58 name = "/"; /* else this must be the root dir */ 58 name = "/"; /* else this must be the root dir */
59 } 59 }
60 60
61 strncpy(namecopy, name, MAX_PATH); 61 strlcpy(namecopy, name, MAX_PATH);
62 namecopy[MAX_PATH-1] = '\0';
63 62
64 return volume; 63 return volume;
65} 64}
@@ -120,8 +119,7 @@ DIR_UNCACHED* opendir_uncached(const char* name)
120 volume = strip_volume(name, namecopy); 119 volume = strip_volume(name, namecopy);
121 pdir->volumecounter = 0; 120 pdir->volumecounter = 0;
122#else 121#else
123 strncpy(namecopy,name,sizeof(namecopy)); /* just copy */ 122 strlcpy(namecopy, name, sizeof(namecopy)); /* just copy */
124 namecopy[sizeof(namecopy)-1] = '\0';
125#endif 123#endif
126 124
127 if ( fat_opendir(IF_MV2(volume,) &pdir->fatdir, 0, NULL) < 0 ) { 125 if ( fat_opendir(IF_MV2(volume,) &pdir->fatdir, 0, NULL) < 0 ) {
@@ -204,7 +202,7 @@ struct dirent_uncached* readdir_uncached(DIR_UNCACHED* dir)
204 if ( !entry.name[0] ) 202 if ( !entry.name[0] )
205 return NULL; 203 return NULL;
206 204
207 strncpy(theent->d_name, entry.name, sizeof( theent->d_name ) ); 205 strlcpy(theent->d_name, entry.name, sizeof(theent->d_name));
208 theent->attribute = entry.attr; 206 theent->attribute = entry.attr;
209 theent->size = entry.filesize; 207 theent->size = entry.filesize;
210 theent->startcluster = entry.firstcluster; 208 theent->startcluster = entry.firstcluster;
@@ -230,8 +228,7 @@ int mkdir_uncached(const char *name)
230 return -1; 228 return -1;
231 } 229 }
232 230
233 strncpy(namecopy,name,sizeof(namecopy)); 231 strlcpy(namecopy, name, sizeof(namecopy));
234 namecopy[sizeof(namecopy)-1] = 0;
235 232
236 /* Split the base name and the path */ 233 /* Split the base name and the path */
237 end = strrchr(namecopy, '/'); 234 end = strrchr(namecopy, '/');