Re: [PATCH] scsi: target: iscsi: Replace strlcat() with snprintf()

From: Alejandro Colomar

Date: Tue Nov 10 2026 - 05:58:35 EST


Hi Mariia,

> Date: 2026-11-10 01:31:37-0800
> From: Mariia Nikitash <nikitash.mariiaw@xxxxxxxxx>
>
> 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@xxxxxxxxx>
> ---
> 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: signature.asc
Description: PGP signature