[coreboot-gerrit] New patch to review for coreboot: 8820eb3 nvramtool: check for successful seek

Patrick Georgi (patrick@georgi-clan.de) gerrit at coreboot.org
Sat Aug 9 17:02:52 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/6560

-gerrit

commit 8820eb32dfa8d454ef4dd67127f22a05c4c9f446
Author: Patrick Georgi <patrick at georgi-clan.de>
Date:   Sat Aug 9 17:02:00 2014 +0200

    nvramtool: check for successful seek
    
    Otherwise the following write might end up anywhere.
    
    Change-Id: Ie42d984824e9308bd58b8bb905b6ea823543adf0
    Found-by: Coverity Scan
    Signed-off-by: Patrick Georgi <patrick at georgi-clan.de>
---
 util/nvramtool/cli/nvramtool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/util/nvramtool/cli/nvramtool.c b/util/nvramtool/cli/nvramtool.c
index d5acc58..bdfaaff 100644
--- a/util/nvramtool/cli/nvramtool.c
+++ b/util/nvramtool/cli/nvramtool.c
@@ -163,8 +163,8 @@ int main(int argc, char *argv[])
 		}
 
 		if (fd_stat.st_size < CMOS_SIZE) {
-			lseek(fd, CMOS_SIZE - 1, SEEK_SET);
-			if (write(fd, "\0", 1) != 1) {
+			if ((lseek(fd, CMOS_SIZE - 1, SEEK_SET) == -1) ||
+			    (write(fd, "\0", 1) != 1)) {
 				fprintf(stderr, "Unable to extended '%s' to its full size.\n",
 						nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_FILE].param);
 				exit(1);



More information about the coreboot-gerrit mailing list