soc/intel/apollolake: Add file path check

Fixes Coverity Issue: 1372243

Change-Id: Ib7e43b195357c723e1ae51f609a8b07ad984380a
Signed-off-by: Hannah Williams <hannah.williams@intel.com>
Reviewed-on: https://review.coreboot.org/20867
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Hannah Williams 2017-08-02 18:13:33 -07:00 committed by Martin Roth
parent d0df1d7c4e
commit 58810c7af5
1 changed files with 4 additions and 0 deletions

View File

@ -92,6 +92,10 @@ static int read_cse_file(const char *path, void *buff, size_t *size,
return 0;
}
if (strnlen(path, sizeof(msg.file_name)) >= sizeof(msg.file_name)) {
printk(BIOS_ERR, "path too big for msg.file_name buffer\n");
return 0;
}
strncpy(msg.file_name, path, sizeof(msg.file_name));
msg.mkhi_hdr.fields.group_id = MKHI_GROUP_ID_MCA;
msg.mkhi_hdr.fields.command = READ_FILE;