mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-09 15:24:32 +08:00
wifi: ray_cs: Utilize strnlen() in parse_addr()
[ Upstream commit9e8e918767
] Instead of doing simple operations and using an additional variable on stack, utilize strnlen() and reuse len variable. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20220603164414.48436-1-andriy.shevchenko@linux.intel.com Stable-dep-of:4f8d66a9fb
("wifi: ray_cs: Fix an error handling path in ray_probe()") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
93890d0573
commit
d696cbbe43
@ -1643,31 +1643,29 @@ static void authenticate_timeout(struct timer_list *t)
|
||||
/*===========================================================================*/
|
||||
static int parse_addr(char *in_str, UCHAR *out)
|
||||
{
|
||||
int i, k;
|
||||
int len;
|
||||
int i, j, k;
|
||||
int status;
|
||||
|
||||
if (in_str == NULL)
|
||||
return 0;
|
||||
if ((len = strlen(in_str)) < 2)
|
||||
len = strnlen(in_str, ADDRLEN * 2 + 1) - 1;
|
||||
if (len < 1)
|
||||
return 0;
|
||||
memset(out, 0, ADDRLEN);
|
||||
|
||||
status = 1;
|
||||
j = len - 1;
|
||||
if (j > 12)
|
||||
j = 12;
|
||||
i = 5;
|
||||
|
||||
while (j > 0) {
|
||||
if ((k = hex_to_bin(in_str[j--])) != -1)
|
||||
while (len > 0) {
|
||||
if ((k = hex_to_bin(in_str[len--])) != -1)
|
||||
out[i] = k;
|
||||
else
|
||||
return 0;
|
||||
|
||||
if (j == 0)
|
||||
if (len == 0)
|
||||
break;
|
||||
if ((k = hex_to_bin(in_str[j--])) != -1)
|
||||
if ((k = hex_to_bin(in_str[len--])) != -1)
|
||||
out[i] += k << 4;
|
||||
else
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user