From 2a1d5b061db4e0019fa4a7f0a8c0fdca2c5c2242 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Mon, 11 Nov 2013 15:20:56 +0100 Subject: 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 Reviewed-on: http://review.coreboot.org/4088 Reviewed-by: Ronald G. Minnich Tested-by: build bot (Jenkins) --- util/cbfstool/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'util/cbfstool') diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c index aa986963c1..03345df1eb 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? -- cgit v1.2.3