From dcfd984d8e09db9d5a7b4d121d914442966c254f Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 25 Jan 2020 14:39:08 +0100 Subject: mtd-utils: Fix potentially unterminated strings This commit fixes some uses of strncpy that could leave the destination buffer unterminated. Signed-off-by: David Oberhollenzer --- tests/checkfs/checkfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/checkfs') diff --git a/tests/checkfs/checkfs.c b/tests/checkfs/checkfs.c index 3e34cc4..203ad5c 100644 --- a/tests/checkfs/checkfs.c +++ b/tests/checkfs/checkfs.c @@ -512,7 +512,8 @@ static void processCmdLine(int argc, char **argv) { if(strcmp(argv[cnt], CMDLINE_PORT) == 0) { - strncpy(SerialDevice, argv[++cnt], sizeof(SerialDevice)); + strncpy(SerialDevice, argv[++cnt], sizeof(SerialDevice) - 1); + SerialDevice[sizeof(SerialDevice) - 1] = '\0'; continue; }else if(strcmp(argv[cnt], CMDLINE_MAXFILEBYTES) == 0) -- cgit v1.2.3