Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strdup and kstrdup: null pointer checks #617

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions patches/driver/brcmfmac_5.15.y-nexmon/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type)
{
char alt_path[BRCMF_FW_NAME_LEN];
char suffix[5];
char *ret = NULL;

strscpy(alt_path, path, BRCMF_FW_NAME_LEN);
/* At least one character + suffix */
Expand All @@ -629,8 +630,13 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type)
strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
strlcat(alt_path, board_type, BRCMF_FW_NAME_LEN);
strlcat(alt_path, suffix, BRCMF_FW_NAME_LEN);

return kstrdup(alt_path, GFP_KERNEL);
ret = kstrdup(alt_path, GFP_KERNEL);
if (!ret) {
brcmf_err("failed to allocate memory for alt_path\n");
return NULL;
}

return ret;
}

static int brcmf_fw_request_firmware(const struct firmware **fw,
Expand Down
5 changes: 5 additions & 0 deletions patches/driver/brcmfmac_6.1.y-nexmon/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type)
{
char alt_path[BRCMF_FW_NAME_LEN];
char suffix[5];
char *ret = NULL;

strscpy(alt_path, path, BRCMF_FW_NAME_LEN);
/* At least one character + suffix */
Expand All @@ -620,6 +621,10 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type)
strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
strlcat(alt_path, board_type, BRCMF_FW_NAME_LEN);
strlcat(alt_path, suffix, BRCMF_FW_NAME_LEN);
if (!ret) {
brcmf_err("failed to allocate memory for alt_path\n");
return NULL;
}

return kstrdup(alt_path, GFP_KERNEL);
}
Expand Down
5 changes: 5 additions & 0 deletions patches/driver/brcmfmac_6.2.y-nexmon/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type)
{
char alt_path[BRCMF_FW_NAME_LEN];
char suffix[5];
char *ret = NULL;

strscpy(alt_path, path, BRCMF_FW_NAME_LEN);
/* At least one character + suffix */
Expand All @@ -620,6 +621,10 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type)
strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
strlcat(alt_path, board_type, BRCMF_FW_NAME_LEN);
strlcat(alt_path, suffix, BRCMF_FW_NAME_LEN);
if (!ret) {
brcmf_err("failed to allocate memory for alt_path\n");
return NULL;
}

return kstrdup(alt_path, GFP_KERNEL);
}
Expand Down
5 changes: 5 additions & 0 deletions patches/driver/brcmfmac_6.6.y-nexmon/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type)
{
char alt_path[BRCMF_FW_NAME_LEN];
char suffix[5];
char *ret;

strscpy(alt_path, path, BRCMF_FW_NAME_LEN);
/* At least one character + suffix */
Expand All @@ -620,6 +621,10 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type)
strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
strlcat(alt_path, board_type, BRCMF_FW_NAME_LEN);
strlcat(alt_path, suffix, BRCMF_FW_NAME_LEN);
if (!ret) {
brcmf_err("failed to allocate memory for alt_path\n");
return NULL;
}

return kstrdup(alt_path, GFP_KERNEL);
}
Expand Down
5 changes: 5 additions & 0 deletions utilities/aircrack-ng/src/aircrack-ng.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,11 @@ int mergebssids(char * bssidlist, unsigned char * bssid)
mac[17] = 0;

tmp2 = list = strdup(bssidlist);
if (list == NULL)
{
perror( "strdup failed" );
return -1;
}

// skip first element (because it doesn't have to be converted
// It already has the good value
Expand Down