From: Rohit Sarkar <rohitsarkar5398@gmail.com>
To: gregkh@linuxfoundation.org, Larry.Finger@lwfinger.net,
florian.c.schilhabel@googlemail.com,
driverdev-devel@linuxdriverproject.org
Subject: Re: [PATCH] staging: rtl8712: Replace snprintf with scnprintf
Date: Wed, 11 Sep 2019 00:25:03 +0530 [thread overview]
Message-ID: <20190910185503.GA8541@SARKAR> (raw)
In-Reply-To: <20190910184931.GA8228@SARKAR>
Resending as I made a typo in Larry's email id.
On Wed, Sep 11, 2019 at 12:19:31AM +0530, Rohit Sarkar wrote:
> When the number of bytes to be printed exceeds the limit snprintf
> returns the number of bytes that would have been printed (if there was
> no truncation). This might cause issues, hence use scnprintf which
> returns the actual number of bytes printed to buffer always.
>
> Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
> ---
> drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> index b08b9a191a34..ff5edcaba64d 100644
> --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> @@ -142,7 +142,7 @@ static noinline_for_stack char *translate_scan_wpa(struct iw_request_info *info,
> memset(buf, 0, MAX_WPA_IE_LEN);
> n = sprintf(buf, "wpa_ie=");
> for (i = 0; i < wpa_len; i++) {
> - n += snprintf(buf + n, MAX_WPA_IE_LEN - n,
> + n += scnprintf(buf + n, MAX_WPA_IE_LEN - n,
> "%02x", wpa_ie[i]);
> if (n >= MAX_WPA_IE_LEN)
> break;
> @@ -162,7 +162,7 @@ static noinline_for_stack char *translate_scan_wpa(struct iw_request_info *info,
> memset(buf, 0, MAX_WPA_IE_LEN);
> n = sprintf(buf, "rsn_ie=");
> for (i = 0; i < rsn_len; i++) {
> - n += snprintf(buf + n, MAX_WPA_IE_LEN - n,
> + n += scnprintf(buf + n, MAX_WPA_IE_LEN - n,
> "%02x", rsn_ie[i]);
> if (n >= MAX_WPA_IE_LEN)
> break;
> --
> 2.17.1
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2019-09-10 18:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-10 18:49 [PATCH] staging: rtl8712: Replace snprintf with scnprintf Rohit Sarkar
2019-09-10 18:55 ` Rohit Sarkar [this message]
2019-10-01 14:14 ` Dan Carpenter
2019-10-01 8:45 ` Dan Carpenter
2019-10-01 17:39 ` Rohit Sarkar
2019-10-01 19:00 ` Dan Carpenter
2019-10-02 4:33 ` Rohit Sarkar
2019-10-02 10:57 ` Dan Carpenter
2019-10-02 11:42 ` Rohit Sarkar
2019-10-02 12:06 ` Dan Carpenter
2019-10-02 12:10 ` Rohit Sarkar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190910185503.GA8541@SARKAR \
--to=rohitsarkar5398@gmail.com \
--cc=Larry.Finger@lwfinger.net \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=florian.c.schilhabel@googlemail.com \
--cc=gregkh@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).