Re: [PATCH 3/3] staging: rtl8723bs: os_dep: Replace sprintf with scnprintf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux