[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y+JxcPOJiRl0qMo1@corigine.com>
Date: Tue, 7 Feb 2023 16:42:40 +0100
From: Simon Horman <simon.horman@...igine.com>
To: Alexandra Winter <wintera@...ux.ibm.com>
Cc: David Miller <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
linux-s390@...r.kernel.org, Heiko Carstens <hca@...ux.ibm.com>,
Thorsten Winkler <twinkler@...ux.ibm.com>,
Jules Irenge <jbi.octave@...il.com>
Subject: Re: [PATCH net-next 4/4] s390/qeth: Convert sprintf/snprintf to
scnprintf
On Mon, Feb 06, 2023 at 06:27:54PM +0100, Alexandra Winter wrote:
> From: Thorsten Winkler <twinkler@...ux.ibm.com>
>
> This LWN article explains the rationale for this change
> https: //lwn.net/Articles/69419/
https://lwn.net/Articles/69419/
> Ie. snprintf() returns what *would* be the resulting length,
> while scnprintf() returns the actual length.
Ok, but in most cases in this patch the return value is not checked.
Is there any value in this change in those cases?
> Reported-by: Jules Irenge <jbi.octave@...il.com>
> Reviewed-by: Alexandra Winkler <wintera@...ux.ibm.com>
s/Winkler/Winter/ ?
> Signed-off-by: Thorsten Winkler <twinkler@...ux.ibm.com>
> Signed-off-by: Alexandra Winter <wintera@...ux.ibm.com>
...
> diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
> index 1cf4e354693f..af4e60d2917e 100644
> --- a/drivers/s390/net/qeth_l3_main.c
> +++ b/drivers/s390/net/qeth_l3_main.c
> @@ -47,9 +47,9 @@ int qeth_l3_ipaddr_to_string(enum qeth_prot_versions proto, const u8 *addr,
> char *buf)
> {
> if (proto == QETH_PROT_IPV4)
> - return sprintf(buf, "%pI4", addr);
> + return scnprintf(buf, INET_ADDRSTRLEN, "%pI4", addr);
> else
> - return sprintf(buf, "%pI6", addr);
> + return scnprintf(buf, INET6_ADDRSTRLEN, "%pI6", addr);
> }
This seems to be the once case where the return value is not ignored.
Of the 4 callers of qeth_l3_ipaddr_to_string, two don't ignore the return
value. And I agree in those cases this change seems correct.
However, amongst other usages of the return value,
those callers also check for a return < 0 from this function.
Can that occur, in the sprintf or scnprintf case?
Powered by blists - more mailing lists