From 66265a33430c35d68a1367103eeee3a701eed640 Mon Sep 17 00:00:00 2001 From: Karol Babioch Date: Fri, 4 May 2018 16:32:16 +0200 Subject: [PATCH] ykpamcfg: Use snprintf() instead of strncpy() strncpy() is _NOT_ a safe version of strcpy() and it should not be used (ineffective and dangerous since a NUL termination might be missing). Instead snprintf() the way to safely construct a string with a given limit. This commit implements this for the action parsing in ykpamcfg. --- ykpamcfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ykpamcfg.c b/ykpamcfg.c index 0a56d73..7feba9f 100644 --- a/ykpamcfg.c +++ b/ykpamcfg.c @@ -105,7 +105,7 @@ parse_args(int argc, char **argv, *slot = 2; break; case 'A': - strncpy(*action, optarg, ACTION_MAX_LEN); + snprintf(*action, ACTION_MAX_LEN, "%s", optarg); break; case 'p': *output_dir = optarg;