ifdtool: Avoid potential buffer overflow

Filenames of 4091 bytes or more lead to a buffer overflow.

Change-Id: I1b4b3932af096f0fcbfb783ab708ed273d3a844e
Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/6476
Tested-by: build bot (Jenkins)
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c
index 0425b1c..deef1b1 100644
--- a/util/ifdtool/ifdtool.c
+++ b/util/ifdtool/ifdtool.c
@@ -552,7 +552,8 @@
 	char new_filename[FILENAME_MAX]; // allow long file names
 	int new_fd;
-	strncpy(new_filename, filename, FILENAME_MAX);
+	// - 5: leave room for ".new\0"
+	strncpy(new_filename, filename, FILENAME_MAX - 5);
 	strncat(new_filename, ".new", FILENAME_MAX - strlen(filename));
 	printf("Writing new image to %s\n", new_filename);