* Re: [PATCH] scsi: target: iscsi: Replace strlcat() with snprintf()
2026-11-10 9:31 [PATCH] scsi: target: iscsi: Replace strlcat() with snprintf() Mariia Nikitash
@ 2026-11-10 10:53 ` Alejandro Colomar
0 siblings, 0 replies; 2+ messages in thread
From: Alejandro Colomar @ 2026-11-10 10:53 UTC (permalink / raw)
To: Mariia Nikitash
Cc: mkp, linux-scsi, target-devel, linux-kernel, morbo, justinstitt,
kees, linux-hardening
[-- Attachment #1: Type: text/plain, Size: 2187 bytes --]
Hi Mariia,
> Date: 2026-11-10 01:31:37-0800
> From: Mariia Nikitash <nikitash.mariiaw@gmail.com>
>
> In preparation for removing the deprecated strlcat() API[1], replace
> the strlcat() call with snprintf() to construct the AuthMethod value
> directly from param->value.
>
> Since buf1 contains unmodified copy of param->value, formatting
> original value and suffix together preserves the NUL-terminated
> output, including partial or omitted ",None" suffixes when the
> 256-byte buffer is too small.
>
> Link: https://github.com/KSPP/linux/issues/370 [1]
> Signed-off-by: Mariia Nikitash <nikitash.mariiaw@gmail.com>
> ---
> drivers/target/iscsi/iscsi_target_tpg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
> index 99772364c88e..aad82a37538f 100644
> --- a/drivers/target/iscsi/iscsi_target_tpg.c
> +++ b/drivers/target/iscsi/iscsi_target_tpg.c
> @@ -624,7 +624,7 @@ int iscsit_ta_authentication(struct iscsi_portal_group *tpg, u32 authentication)
> none = strstr(buf1, NONE);
> if (none)
> goto out;
> - strlcat(buf1, "," NONE, sizeof(buf1));
> + snprintf(buf1, sizeof(buf1), "%s," NONE, param->value);
This rewrites the string written a few lines above. It seems rather
confusing. I very much prefer strlcat(3) here. Of course, an
strscpy_at() would be better, but snprintf(3) seems wrong.
For other readers, here's the same diff with some more context:
@@ -622,11 +622,11 @@ int iscsit_ta_authentication(struct iscsi_portal_group *tpg, u32 authentication)
} else {
snprintf(buf1, sizeof(buf1), "%s", param->value);
none = strstr(buf1, NONE);
if (none)
goto out;
- strlcat(buf1, "," NONE, sizeof(buf1));
+ snprintf(buf1, sizeof(buf1), "%s," NONE, param->value);
if (iscsi_update_param_value(param, buf1) < 0)
return -EINVAL;
}
out:
So far, NAK by me.
Have a lovely day!
Alex
> if (iscsi_update_param_value(param, buf1) < 0)
> return -EINVAL;
> }
> --
> 2.43.0
>
>
--
<https://www.alejandro-colomar.es>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread