]> git.baikalelectronics.ru Git - kernel.git/commit
brcmfmac: fix wrong strnchr usage
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Wed, 22 Aug 2018 13:22:15 +0000 (15:22 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 31 Aug 2018 15:48:02 +0000 (18:48 +0300)
commitbf65c13819eeb021ee59f314af4b8aacb1ebaea8
tree08bea7cfad76fdbed3e57c107851bd36023b691d
parent3ee8fafbc9c5b1fdea5d17acd08d3c615ccbef96
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>
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c