Skip to content

Commit cb18e2e

Browse files
VillemoesKalle Valo
authored andcommitted
brcmfmac: fix wrong strnchr usage
strnchr takes arguments in the order of its name: string, max bytes to read, character to search for. Here we're passing '\n' aka 10 as the buffer size, and searching for sizeof(buf) aka BRCMF_DCMD_SMLEN aka 256 (aka '\0', since it's implicitly converted to char) within those 10 bytes. Just interchanging the last two arguments would still leave a bug, because if we've been successful once, there are not sizeof(buf) characters left after the new value of p. Since clmver is immediately afterwards passed as a %s argument, I assume that it is actually a properly nul-terminated string. For that case, we have strreplace(). Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
1 parent f483039 commit cb18e2e

File tree

1 file changed

+1
-3
lines changed
  • drivers/net/wireless/broadcom/brcm80211/brcmfmac

1 file changed

+1
-3
lines changed

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
296296
/* Replace all newline/linefeed characters with space
297297
* character
298298
*/
299-
ptr = clmver;
300-
while ((ptr = strnchr(ptr, '\n', sizeof(buf))) != NULL)
301-
*ptr = ' ';
299+
strreplace(clmver, '\n', ' ');
302300

303301
brcmf_dbg(INFO, "CLM version = %s\n", clmver);
304302
}

0 commit comments

Comments
 (0)