Permalink
Browse files

fileops: Ensure buf is terminated by a NULL character after strncpy

Signed-off-by: Francois Berder <fberder@outlook.fr>
  • Loading branch information...
francois-berder committed Jan 18, 2019
1 parent 21e0b37 commit 3fe4b14e0235822dcb43f0406112f0f7f2491bec
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/fileops.c
@@ -118,7 +118,8 @@ FRESULT check_or_create_folder(TCHAR *dir) {
fno.lfname = NULL;
TCHAR buf[256];
TCHAR *ptr = buf;
strncpy(buf, dir, sizeof(buf));
strncpy(buf, dir, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
while(*(ptr++)) {
if(*ptr == '/') {
*ptr = 0;

0 comments on commit 3fe4b14

Please sign in to comment.