Use os_memdup()
This leads to cleaner code overall, and also reduces the size of the hostapd and wpa_supplicant binaries (in hwsim test build on x86_64) by about 2.5 and 3.5KiB respectively. The mechanical conversions all over the code were done with the following spatch: @@ expression SIZE, SRC; expression a; @@ -a = os_malloc(SIZE); +a = os_memdup(SRC, SIZE); <... if (!a) {...} ...> -os_memcpy(a, SRC, SIZE); Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
dbdda355d0
commit
a1f11e34c4
73 changed files with 201 additions and 376 deletions
|
@ -2715,12 +2715,11 @@ static void handle_assoc(struct hostapd_data *hapd,
|
|||
/* The end of the payload is encrypted. Need to decrypt it
|
||||
* before parsing. */
|
||||
|
||||
tmp = os_malloc(left);
|
||||
tmp = os_memdup(pos, left);
|
||||
if (!tmp) {
|
||||
resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
goto fail;
|
||||
}
|
||||
os_memcpy(tmp, pos, left);
|
||||
|
||||
left = fils_decrypt_assoc(sta->wpa_sm, sta->fils_session, mgmt,
|
||||
len, tmp, left);
|
||||
|
@ -3188,10 +3187,9 @@ static int handle_action(struct hostapd_data *hapd,
|
|||
*/
|
||||
wpa_printf(MSG_DEBUG, "IEEE 802.11: Return unknown Action "
|
||||
"frame back to sender");
|
||||
resp = os_malloc(len);
|
||||
resp = os_memdup(mgmt, len);
|
||||
if (resp == NULL)
|
||||
return 0;
|
||||
os_memcpy(resp, mgmt, len);
|
||||
os_memcpy(resp->da, resp->sa, ETH_ALEN);
|
||||
os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
|
||||
os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue