freebsd-dev/usr.sbin/bhyve/qemu_fwcfg.h
John Baldwin 61482760a0 bhyve: Accept a variable-length string name for qemu_fwcfg_add_file.
It is illegal (UB?) to pass a shorter array to a function argument
that takes a fixed-length array.  Do a runtime check for names that
are too long via strlen() instead.

Reviewed by:	markj
Reported by:	GCC -Wstringop-overread
Differential Revision:	https://reviews.freebsd.org/D39211
2023-03-22 12:34:34 -07:00

24 lines
497 B
C

/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2021 Beckhoff Automation GmbH & Co. KG
* Author: Corvin Köhne <c.koehne@beckhoff.com>
*/
#pragma once
#include <vmmapi.h>
#define QEMU_FWCFG_MAX_ARCHS 0x2
#define QEMU_FWCFG_MAX_ENTRIES 0x4000
#define QEMU_FWCFG_MAX_NAME 56
struct qemu_fwcfg_item {
uint32_t size;
uint8_t *data;
};
int qemu_fwcfg_add_file(const char *name,
const uint32_t size, void *const data);
int qemu_fwcfg_init(struct vmctx *const ctx);