From 3f68b9891b207c1542f307881ea8ac4db5f86249 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 27 Apr 2020 09:45:04 -0400 Subject: [PATCH] Fix #37, termination on strncpy Fix possible non-termination of strings within command line parsing. This generated a warning in GCC9. --- elf2cfetbl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/elf2cfetbl.c b/elf2cfetbl.c index d1a3f01..3da9df3 100644 --- a/elf2cfetbl.c +++ b/elf2cfetbl.c @@ -936,13 +936,15 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) if ((Arguments[i][0] == '-') && (Arguments[i][1] == 't')) { // Extract the Table Name Override - strncpy(TableName, &Arguments[i][2], 38); + strncpy(TableName, &Arguments[i][2], sizeof(TableName)-1); + TableName[sizeof(TableName)-1] = 0; TableNameOverride = true; } else if ((Arguments[i][0] == '-') && (Arguments[i][1] == 'd')) { // Extract the Description Override - strncpy(Description, &Arguments[i][2], 32); + strncpy(Description, &Arguments[i][2], sizeof(Description)-1); + Description[sizeof(Description)-1] = 0; DescriptionOverride = true; } else if ((Arguments[i][0] == '-') && (Arguments[i][1] == 's'))