From e294bb443cafe55e47b9f218f0c8064a1b86ee58 Mon Sep 17 00:00:00 2001 From: Hinko Kocevar Date: Sun, 6 Apr 2025 12:49:08 +0200 Subject: [PATCH] 2nd attempt to fix a linter error for step 49 of "Path" --- modules/libcom/src/iocsh/iocsh.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/libcom/src/iocsh/iocsh.cpp b/modules/libcom/src/iocsh/iocsh.cpp index 060511d01..82551c7d2 100644 --- a/modules/libcom/src/iocsh/iocsh.cpp +++ b/modules/libcom/src/iocsh/iocsh.cpp @@ -852,12 +852,13 @@ cvtArg (const char *filename, int lineno, char *arg, iocshArgBuf *argBuf, case iocshArgPersistentString: if (arg != NULL) { - argBuf->sval = (char *) malloc(strlen(arg) + 1); + size_t slen = strlen(arg); + argBuf->sval = (char *) malloc(slen + 1); if (argBuf->sval == NULL) { showError(filename, lineno, ANSI_RED("Out of memory!")); return 0; } - strcpy(argBuf->sval, arg); + strncpy(argBuf->sval, arg, slen); } else { argBuf->sval = NULL; }