Skip to contentSkip to conversation

drivers/net/wireless/marvell/mwifiex/sdio: Use strscpy() to copy strings into arrays

PATCH In review [email protected] 3 participants 3 messages Jun 8 – Aug 11 Marvell mwifiex wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/net/wireless/marvell/mwifiex/sdio: Use strscpy() to copy strings into arrays

From: David Laight <[email protected]>

Replacing strcpy() with strscpy() ensures that overflow of the target buffer cannot happen.

---
This is one of a group of patches that remove potentially unbounded strcpy() calls.

They are mostly replaced by strscpy() or, when strlen() has just been called, with memcpy() (usually including the '\0').

Calls with copy string literals into arrays are left unchanged. They are safe and easily detected as such.

The changes were made by getting the compiler to detect the calls and then fixing the code by hand.

Note that all the changes are only compile tested.

Some Makefiles were changed to allow files to contain strcpy(). As well as 'difficult to fix' files, this included 'show' functions as they really need to use sysfs_emit() or seq_printf().

All the patches are being sent individually to avoid very long cc lists. Apologies for the terse commit messages and likely unexpected tags. (There are about 100 patches in total.)

 drivers/net/wireless/marvell/mwifiex/sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/marvell/mwifiex/sdio.c +1 -1
index f039d6f19183..d269bc4fdce2 100644
@@ -2512,7 +2512,7 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
 		if ((val & card->reg->host_strap_mask) == card->reg->host_strap_value)
 			firmware = card->firmware_sdiouart;
 	}
-	strcpy(adapter->fw_name, firmware);
+	strscpy(adapter->fw_name, firmware);
 
 	if (card->fw_dump_enh) {
 		adapter->mem_type_mapping_tbl = generic_mem_type_map;
Signature · 1 line
2.39.5
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to [email protected]

This isn't how driver patch subjects should be formed. It should be:

wifi: mwifiex: ...

Quoted 6 lines · On Mon, Jun 08, 2026 at 10:54:47AM +0100, [email protected] wrote:

From: David Laight <[email protected]>

Replacing strcpy() with strscpy() ensures that overflow of the target buffer cannot happen.