[coreboot-gerrit] Patch set updated for coreboot: util/cbfstool: Handle error condition more carefully

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Thu Dec 15 22:31:25 CET 2016


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17861

-gerrit

commit 809ab0cb1a78c21c81056e7787feefdd94707ef7
Author: Patrick Georgi <pgeorgi at chromium.org>
Date:   Wed Dec 14 16:16:47 2016 +0100

    util/cbfstool: Handle error condition more carefully
    
    Change-Id: I72a7776d530d1cf0b8fa39e558990df3dc7f7805
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
    Found-by: Coverity Scan #1295494
---
 util/cbfstool/common.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c
index 3093ba1..5a47c2f 100644
--- a/util/cbfstool/common.c
+++ b/util/cbfstool/common.c
@@ -71,12 +71,13 @@ int buffer_from_file(struct buffer *buffer, const char *filename)
 		return -1;
 	}
 	buffer->offset = 0;
-	buffer->size = get_file_size(fp);
-	if (buffer->size == -1u) {
+	off_t file_size = get_file_size(fp);
+	if (file_size < 0) {
 		fprintf(stderr, "could not determine size of %s\n", filename);
 		fclose(fp);
 		return -1;
 	}
+	buffer->size = file_size;
 	buffer->name = strdup(filename);
 	buffer->data = (char *)malloc(buffer->size);
 	assert(buffer->data);



More information about the coreboot-gerrit mailing list