Skip to content

Commit

Permalink
lxcfs: use strlcpy when handle runtime-dir parameter
Browse files Browse the repository at this point in the history
Fixes: Coverity 451805
Signed-off-by: Alexander Mikhalitsyn <[email protected]>
  • Loading branch information
mihalicyn committed Jan 31, 2025
1 parent 139ef0e commit 1b1c6a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ static void sigusr2_toggle_virtualization(int signo, siginfo_t *info, void *extr
bool set_runtime_path(const char* new_path)
{
if (new_path && strlen(new_path) < PATH_MAX) {
strcpy(runtime_path, new_path);
strlcpy(runtime_path, new_path, sizeof(runtime_path));
lxcfs_info("Using runtime path %s", runtime_path);
return true;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/lxcfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,10 +1432,10 @@ int main(int argc, char *argv[])
}

if (runtime_path_arg) {
strcpy(runtime_path, runtime_path_arg);
strlcpy(runtime_path, runtime_path_arg, sizeof(runtime_path));
lxcfs_info("runtime path set to %s", runtime_path);
}
strcpy(opts->runtime_path, runtime_path);
strlcpy(opts->runtime_path, runtime_path, sizeof(opts->runtime_path));

fuse_argv[fuse_argc++] = argv[0];
if (debug)
Expand Down

0 comments on commit 1b1c6a0

Please sign in to comment.