Skip to content
Permalink
Browse files

subsys/settings: Use strncpy instead of strcpy in settings_runtime

This fixes some Coverity warnings.

Coverity-CID: 198022
Coverity-CID: 198019
Coverity-CID: 198016
Fixes #15762
Fixes #15764
Fixes #15766

Signed-off-by: François Delawarde <fnde@oticon.com>
  • Loading branch information...
fnde-ot authored and nashif committed May 2, 2019
1 parent 873dd10 commit 2038365e9a9cab2322bc5319bf2e1d098e48d31c
Showing with 3 additions and 3 deletions.
  1. +3 −3 subsys/settings/src/settings_runtime.c
@@ -22,7 +22,7 @@ int settings_runtime_set(const char *name, void *data, size_t len)
char *name_argv[SETTINGS_MAX_DIR_DEPTH];
int name_argc;

strcpy(name1, name);
strncpy(name1, name, sizeof(name1));
ch = settings_parse_and_lookup(name1, &name_argc, name_argv);
if (!ch) {
return -EINVAL;
@@ -39,7 +39,7 @@ int settings_runtime_get(const char *name, void *data, size_t len)
char *name_argv[SETTINGS_MAX_DIR_DEPTH];
int name_argc;

strcpy(name1, name);
strncpy(name1, name, sizeof(name1));
ch = settings_parse_and_lookup(name1, &name_argc, name_argv);
if (!ch) {
return -EINVAL;
@@ -55,7 +55,7 @@ int settings_runtime_commit(const char *name)
char *name_argv[SETTINGS_MAX_DIR_DEPTH];
int name_argc;

strcpy(name1, name);
strncpy(name1, name, sizeof(name1));
ch = settings_parse_and_lookup(name1, &name_argc, name_argv);
if (!ch) {
return -EINVAL;

0 comments on commit 2038365

Please sign in to comment.
You can’t perform that action at this time.