Commit 59dfdd92 authored by Rickard Strandqvist's avatar Rickard Strandqvist Committed by John W. Linville

brcmfmac: dhd_sdio.c: Cleaning up missing null-terminate in conjunction with strncpy

Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
And changed from using strncat to strlcat to simplify code.
Signed-off-by: default avatarRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 47481d97
...@@ -670,7 +670,6 @@ static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci, ...@@ -670,7 +670,6 @@ static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci,
struct brcmf_sdio_dev *sdiodev) struct brcmf_sdio_dev *sdiodev)
{ {
int i; int i;
uint fw_len, nv_len;
char end; char end;
for (i = 0; i < ARRAY_SIZE(brcmf_fwname_data); i++) { for (i = 0; i < ARRAY_SIZE(brcmf_fwname_data); i++) {
...@@ -684,25 +683,25 @@ static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci, ...@@ -684,25 +683,25 @@ static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci,
return -ENODEV; return -ENODEV;
} }
fw_len = sizeof(sdiodev->fw_name) - 1;
nv_len = sizeof(sdiodev->nvram_name) - 1;
/* check if firmware path is provided by module parameter */ /* check if firmware path is provided by module parameter */
if (brcmf_firmware_path[0] != '\0') { if (brcmf_firmware_path[0] != '\0') {
strncpy(sdiodev->fw_name, brcmf_firmware_path, fw_len); strlcpy(sdiodev->fw_name, brcmf_firmware_path,
strncpy(sdiodev->nvram_name, brcmf_firmware_path, nv_len); sizeof(sdiodev->fw_name));
fw_len -= strlen(sdiodev->fw_name); strlcpy(sdiodev->nvram_name, brcmf_firmware_path,
nv_len -= strlen(sdiodev->nvram_name); sizeof(sdiodev->nvram_name));
end = brcmf_firmware_path[strlen(brcmf_firmware_path) - 1]; end = brcmf_firmware_path[strlen(brcmf_firmware_path) - 1];
if (end != '/') { if (end != '/') {
strncat(sdiodev->fw_name, "/", fw_len); strlcat(sdiodev->fw_name, "/",
strncat(sdiodev->nvram_name, "/", nv_len); sizeof(sdiodev->fw_name));
fw_len--; strlcat(sdiodev->nvram_name, "/",
nv_len--; sizeof(sdiodev->nvram_name));
} }
} }
strncat(sdiodev->fw_name, brcmf_fwname_data[i].bin, fw_len); strlcat(sdiodev->fw_name, brcmf_fwname_data[i].bin,
strncat(sdiodev->nvram_name, brcmf_fwname_data[i].nv, nv_len); sizeof(sdiodev->fw_name));
strlcat(sdiodev->nvram_name, brcmf_fwname_data[i].nv,
sizeof(sdiodev->nvram_name));
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment