From a9a267c1f7a5a6284398bd7ae6ac0c2a0643ece2 Mon Sep 17 00:00:00 2001 From: Johannes Totz Date: Mon, 3 Oct 2022 11:09:57 -0700 Subject: [PATCH] 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 --- sys/dev/acpica/acpi_thermal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c index 7a5cb8ebb64..bd9ecf455e2 100644 --- a/sys/dev/acpica/acpi_thermal.c +++ b/sys/dev/acpica/acpi_thermal.c @@ -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");