[PATCH 3/3] staging: rtl8723bs: os_dep: Replace sprintf with scnprintf
Dan Carpenter
dan.carpenter at oracle.com
Mon Mar 1 13:41:09 UTC 2021
On Mon, Mar 01, 2021 at 08:13:54PM +0700, Candy Febriyanto wrote:
> @@ -5082,7 +5084,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
> case IW_PRIV_TYPE_BYTE:
> /* Display args */
> for (j = 0; j < n; j++) {
> - sprintf(str, "%d ", extra[j]);
> + scnprintf(str, sizeof(str), "%d ", extra[j]);
> len = strlen(str);
You could save a little code and combine the two statements:
len = scnprintf(str, sizeof(str), "%d ", extra[j]);
For bonus points, you could write a Coccinelle script to look for that
pattern of calling strlen() on a freshly sprintfed string.
> output_len = strlen(output);
> if ((output_len + len + 1) > 4096) {
regards,
dan carpenter
More information about the devel
mailing list