From: pwpiwi <pwpiwi@users.noreply.github.com>
Date: Fri, 3 Jan 2020 06:17:21 +0000 (+0100)
Subject: fix gcc8 compiler warnings on string overflows (#905)
X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/fef3084ec2cd5c58ff5bef95ef681e9476cd1d8e?ds=sidebyside;hp=-c

fix gcc8 compiler warnings on string overflows (#905)
---

fef3084ec2cd5c58ff5bef95ef681e9476cd1d8e
diff --git a/client/cmdhf14b.c b/client/cmdhf14b.c
index 577b4fc8..0c6ff4b3 100644
--- a/client/cmdhf14b.c
+++ b/client/cmdhf14b.c
@@ -679,7 +679,6 @@ int CmdSriWrite(const char *Cmd) {
 	uint8_t blockno = -1;
 	uint8_t data[4] = {0x00};
 	bool isSrix4k = true;
-	char str[20];
 
 	if (strlen(Cmd) < 1 || cmdp == 'h' || cmdp == 'H') {
 		PrintAndLog("Usage:  hf 14b write <1|2> <BLOCK> <DATA>");
@@ -725,6 +724,7 @@ int CmdSriWrite(const char *Cmd) {
 	else
 		PrintAndLog("[%s] Write block %02X [ %s ]", (isSrix4k)?"SRIX4K":"SRI512", blockno, sprint_hex(data, 4));
 
+	char str[22];
 	sprintf(str, "-ss -c 09 %02x %02x%02x%02x%02x", blockno, data[0], data[1], data[2], data[3]);
 
 	CmdHF14BCmdRaw(str);
diff --git a/client/cmdhflist.c b/client/cmdhflist.c
index c7e3dab8..4bca17a7 100644
--- a/client/cmdhflist.c
+++ b/client/cmdhflist.c
@@ -1119,11 +1119,11 @@ int CmdHFList(const char *Cmd) {
 		prev_EOT = &previous_EOT;
 	}
 	
-	char load_filename[FILE_PATH_SIZE] = {0};
+	char load_filename[FILE_PATH_SIZE+1] = {0};
 	if (loadFromFile) {
 		strncpy(load_filename, arg_get_str(5)->sval[0], FILE_PATH_SIZE);
 	}
-	char save_filename[FILE_PATH_SIZE] = {0};
+	char save_filename[FILE_PATH_SIZE+1] = {0};
 	if (saveToFile) {
 		strncpy(save_filename, arg_get_str(6)->sval[0], FILE_PATH_SIZE);
 	}