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@georgi-clan.de> Reviewed-on: http://review.coreboot.org/4088 Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Tested-by: build bot (Jenkins)
This commit is contained in:
parent
df29f1ba6f
commit
2a1d5b061d
|
@ -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 *cbfs_create_empty_file(uint32_t physaddr, uint32_t size)
|
||||||
{
|
{
|
||||||
struct cbfs_file *nextfile = (struct cbfs_file *)phys_to_virt(physaddr);
|
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->len = htonl(size);
|
||||||
nextfile->type = htonl(0xffffffff);
|
nextfile->type = htonl(0xffffffff);
|
||||||
nextfile->checksum = 0; // FIXME?
|
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);
|
memset(newdata, 0xff, *datasize + headersize);
|
||||||
struct cbfs_file *nextfile = (struct cbfs_file *)newdata;
|
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->len = htonl(*datasize);
|
||||||
nextfile->type = htonl(type);
|
nextfile->type = htonl(type);
|
||||||
nextfile->checksum = 0; // FIXME?
|
nextfile->checksum = 0; // FIXME?
|
||||||
|
|
Loading…
Reference in New Issue