tree.c use strlcpy to avoid buffer ovfl

Change-Id: I6ac4ec6306c2101b11bc0495edd7bbe2717acf9c
This commit is contained in:
William Wilgus 2021-07-23 10:31:56 -04:00 committed by William Wilgus
parent 26fd90bb49
commit 42ba117952

View file

@ -372,7 +372,7 @@ static int update_dir(void)
{ {
if (ft_load(&tc, NULL) < 0) if (ft_load(&tc, NULL) < 0)
return -1; return -1;
strcpy(lastdir, tc.currdir); strlcpy(lastdir, tc.currdir, MAX_PATH);
changed = true; changed = true;
} }
} }
@ -568,7 +568,7 @@ void set_current_file(const char *path)
name = path+1; name = path+1;
} }
strcpy(lastfile, name); strlcpy(lastfile, name, MAX_PATH);
/* If we changed dir we must recalculate the dirlevel /* If we changed dir we must recalculate the dirlevel
@ -987,7 +987,7 @@ int rockbox_browse(struct browse_context *browse)
if (dirfilter != SHOW_ID3DB) if (dirfilter != SHOW_ID3DB)
tc.dirfilter = &global_settings.dirfilter; tc.dirfilter = &global_settings.dirfilter;
tc.browse = browse; tc.browse = browse;
strcpy(current, browse->root); strlcpy(current, browse->root, MAX_PATH);
set_current_file(current); set_current_file(current);
if (browse->flags&BROWSE_RUNFILE) if (browse->flags&BROWSE_RUNFILE)
ret_val = ft_enter(&tc); ret_val = ft_enter(&tc);