acpi_thermal: Fix a potential stack buffer overflow.

While here, fix a typo as well.

Reviewed by:	jhb
Differential Revision: https://reviews.freebsd.org/D36495
This commit is contained in:
Johannes Totz 2022-10-03 11:09:57 -07:00 committed by John Baldwin
parent 6f8a182b15
commit a9a267c1f7

View File

@ -176,7 +176,7 @@ static int acpi_tz_min_runtime;
static int acpi_tz_polling_rate = TZ_POLLRATE;
static int acpi_tz_override;
/* Timezone polling thread */
/* Thermal zone polling thread */
static struct proc *acpi_tz_proc;
ACPI_LOCK_DECL(thermal, "ACPI thermal zone");
@ -201,7 +201,7 @@ acpi_tz_attach(device_t dev)
struct acpi_tz_softc *sc;
struct acpi_softc *acpi_sc;
int error;
char oidname[8];
char oidname[16];
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@ -257,7 +257,7 @@ acpi_tz_attach(device_t dev)
"allow override of thermal settings");
}
sysctl_ctx_init(&sc->tz_sysctl_ctx);
sprintf(oidname, "tz%d", device_get_unit(dev));
snprintf(oidname, sizeof(oidname), "tz%d", device_get_unit(dev));
sc->tz_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&sc->tz_sysctl_ctx,
SYSCTL_CHILDREN(acpi_tz_sysctl_tree), OID_AUTO, oidname,
CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "", "thermal_zone");