[coreboot-gerrit] New patch to review for coreboot: 591b6b2 ifdtool: Check if file was opened
Patrick Georgi (patrick@georgi-clan.de)
gerrit at coreboot.org
Sun Aug 3 12:19:48 CEST 2014
Patrick Georgi (patrick at georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6477
-gerrit
commit 591b6b2dfa1c92984ae680c275e396036cf7e54a
Author: Patrick Georgi <patrick at georgi-clan.de>
Date: Sun Aug 3 12:18:45 2014 +0200
ifdtool: Check if file was opened
Check if the new file could in fact be opened before
writing to it.
Change-Id: I6b2d31bf5c18f657fca4dc14fee2f2d5a2e33080
Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick at georgi-clan.de>
---
util/ifdtool/ifdtool.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c
index deef1b1..b68782d 100644
--- a/util/ifdtool/ifdtool.c
+++ b/util/ifdtool/ifdtool.c
@@ -562,6 +562,10 @@ static void write_image(char *filename, char *image, int size)
new_fd = open(new_filename,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (new_fd < 0) {
+ perror("Error while trying to open file");
+ exit(EXIT_FAILURE);
+ }
if (write(new_fd, image, size) != size)
perror("Error while writing");
close(new_fd);
More information about the coreboot-gerrit
mailing list