lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0gKsG43isrXPezvAtkZ6juRnTkaorXE_7QO_RSvDq-www@mail.gmail.com>
Date: Tue, 16 Dec 2025 13:18:52 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Thorsten Blum <thorsten.blum@...ux.dev>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>, Daniel Lezcano <daniel.lezcano@...aro.org>, 
	Zhang Rui <rui.zhang@...el.com>, Lukasz Luba <lukasz.luba@....com>, linux-pm@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] thermal: core: Use strnlen in thermal_zone_device_register_with_trips

On Mon, Dec 15, 2025 at 1:16 PM Thorsten Blum <thorsten.blum@...ux.dev> wrote:
>
> Replace strlen() with the safer strnlen() and calculate the length of
> the thermal zone name 'type' only once.  No functional changes.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
> ---
>  drivers/thermal/thermal_core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 17ca5c082643..63eb35b449c6 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1505,15 +1505,17 @@ thermal_zone_device_register_with_trips(const char *type,
>         const struct thermal_trip *trip = trips;
>         struct thermal_zone_device *tz;
>         struct thermal_trip_desc *td;
> +       size_t type_len;

size_t type_len = 0;

>         int id;
>         int result;
>
> -       if (!type || strlen(type) == 0) {
> +       type_len = type ? strnlen(type, THERMAL_NAME_LENGTH) : 0;

if (type)
        type_len = strnlen(type, THERMAL_NAME_LENGTH);

Pretty please.

> +       if (type_len == 0) {
>                 pr_err("No thermal zone type defined\n");
>                 return ERR_PTR(-EINVAL);
>         }
>
> -       if (strlen(type) >= THERMAL_NAME_LENGTH) {
> +       if (type_len == THERMAL_NAME_LENGTH) {
>                 pr_err("Thermal zone name (%s) too long, should be under %d chars\n",
>                        type, THERMAL_NAME_LENGTH);
>                 return ERR_PTR(-EINVAL);
> --

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ