From 455ecf6997899c7eb6732830bb24607de83736cf Mon Sep 17 00:00:00 2001 From: Maschell Date: Mon, 17 Apr 2023 14:00:26 +0200 Subject: [PATCH] devoptab: Replace strncopy with snprintf --- source/devoptab/devoptab_fsa_dirnext.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/devoptab/devoptab_fsa_dirnext.cpp b/source/devoptab/devoptab_fsa_dirnext.cpp index 07ba3ab..9032696 100644 --- a/source/devoptab/devoptab_fsa_dirnext.cpp +++ b/source/devoptab/devoptab_fsa_dirnext.cpp @@ -31,7 +31,8 @@ int __fsa_dirnext(struct _reent *r, __fsa_translate_stat(&dir->entry_data.info, filestat); - memset(filename, 0, NAME_MAX); - strncpy(filename, dir->entry_data.name, NAME_MAX - 1); + if (snprintf(filename, NAME_MAX, "%s", dir->entry_data.name) >= NAME_MAX) { + DEBUG_FUNCTION_LINE_ERR("snprintf filename result was truncated\n"); + } return 0; }