[coreboot-gerrit] New patch to review for coreboot: 39c4caa cbfstool: cleaner filling fields

Patrick Georgi (patrick@georgi-clan.de) gerrit at coreboot.org
Fri Nov 15 22:27:32 CET 2013


Patrick Georgi (patrick at georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4088

-gerrit

commit 39c4caa0eed9e5c0a6665450505e3bb725ceb265
Author: Patrick Georgi <patrick at georgi-clan.de>
Date:   Mon Nov 11 15:20:56 2013 +0100

    cbfstool: cleaner filling fields
    
    The LARCHIVE header isn't a string (not null terminated).
    It confused coverity, and while it should be obvious that
    we're not aiming for any null bytes after the header, we
    can also just not pretend it's a string.
    
    Change-Id: Ibd5333a27d8920b8a97de554f1cd27e28f4f7d0a
    Found-by: Coverity Scan
    Signed-off-by: Patrick Georgi <patrick at georgi-clan.de>
---
 util/cbfstool/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c
index aa98696..03345df 100644
--- a/util/cbfstool/common.c
+++ b/util/cbfstool/common.c
@@ -283,7 +283,7 @@ int cbfs_file_header(unsigned long physaddr)
 struct cbfs_file *cbfs_create_empty_file(uint32_t physaddr, uint32_t size)
 {
 	struct cbfs_file *nextfile = (struct cbfs_file *)phys_to_virt(physaddr);
-	strncpy((char *)(nextfile->magic), "LARCHIVE", 8);
+	memcpy((char *)(nextfile->magic), "LARCHIVE", 8);
 	nextfile->len = htonl(size);
 	nextfile->type = htonl(0xffffffff);
 	nextfile->checksum = 0;	// FIXME?
@@ -652,7 +652,7 @@ void *create_cbfs_file(const char *filename, void *data, uint32_t * datasize,
 	}
 	memset(newdata, 0xff, *datasize + headersize);
 	struct cbfs_file *nextfile = (struct cbfs_file *)newdata;
-	strncpy((char *)(nextfile->magic), "LARCHIVE", 8);
+	memcpy((char *)(nextfile->magic), "LARCHIVE", 8);
 	nextfile->len = htonl(*datasize);
 	nextfile->type = htonl(type);
 	nextfile->checksum = 0;	// FIXME?



More information about the coreboot-gerrit mailing list