mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 18:56:38 +00:00
bhyve: fix buffer overflow in QemuFwCfg
We're accessing one element of the newly allocated and the old directory
too much.
Reported by: andy@omniosce.org
Reviewed by: markj
Fixes: 6f9ebb3d0f
("bhyve: add helper for adding fwcfg files")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42220
This commit is contained in:
parent
d8735eb7ac
commit
4a3810075f
|
@ -365,7 +365,7 @@ qemu_fwcfg_add_file(const char *name, const uint32_t size, void *const data)
|
|||
/* copy files above file_index to directory */
|
||||
memcpy(&new_directory->files[file_index + 1],
|
||||
&fwcfg_sc.directory->files[file_index],
|
||||
(count - file_index) * sizeof(struct qemu_fwcfg_file));
|
||||
(count - file_index - 1) * sizeof(struct qemu_fwcfg_file));
|
||||
|
||||
/* free old directory */
|
||||
free(fwcfg_sc.directory);
|
||||
|
|
Loading…
Reference in a new issue