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>
This commit is contained in:
parent
edb0a61be4
commit
440daf786a
|
@ -552,7 +552,8 @@ static void write_image(char *filename, char *image, int size)
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue