Subject: Re: [PATCH net-next 2/4] s390/lcs: Convert sprintf to scnprintf

From: Simon Horman <[email-masked]>
Date: Tue, 20 Jun 2023 21:16:35 +0200

On Tue, Jun 20, 2023 at 10:34:09AM +0200, Alexandra Winter wrote:
> From: Thorsten Winkler <[email-masked]>
> 
> This LWN article explains the rationale for this change
> https: //lwn.net/Articles/69419/
> Ie. snprintf() returns what *would* be the resulting length,
> while scnprintf() returns the actual length.

Hi Alexandra,

Although I agree that it's nice to use scnprintf() the justification given
seems a bit odd: it talks of the return value but it is ignored both before
and after this patch.

Likewise for some of the changes in patch 4/4.

Also is it intentional that there is a space in the URL immediately
after 'http:' ? Maybe mangled by something. Not that it really maters
AFAIC.

> Reported-by: Jules Irenge <[email-masked]>
> Reviewed-by: Alexandra Winter <[email-masked]>
> Signed-off-by: Thorsten Winkler <[email-masked]>
> Signed-off-by: Alexandra Winter <[email-masked]>
> ---
>  drivers/s390/net/lcs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/s390/net/lcs.h b/drivers/s390/net/lcs.h
> index bd52caa3b11b..a2699b70b050 100644
> --- a/drivers/s390/net/lcs.h
> +++ b/drivers/s390/net/lcs.h
> @@ -21,7 +21,7 @@ do { \
>  #define LCS_DBF_TEXT_(level,name,text...) \
>  	do { \
>  		if (debug_level_enabled(lcs_dbf_##name, level)) { \
> -			sprintf(debug_buffer, text); \
> +			scnprintf(debug_buffer, sizeof(debug_buffer), text); \
>  			debug_text_event(lcs_dbf_##name, level, debug_buffer); \
>  		} \
>  	} while (0)
> -- 
> 2.39.2
> 
>