aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/ctrl_iface_named_pipe.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2017-03-07 09:17:23 (GMT)
committerJouni Malinen <j@w1.fi>2017-03-07 11:19:10 (GMT)
commita1f11e34c4d6a10bdfef58cdba0b19e1335e087b (patch)
treef3ff7d078578a4b4a7ccf20058e65f1ddb96c622 /wpa_supplicant/ctrl_iface_named_pipe.c
parentdbdda355d0add3f7d96e3279321d3a63abfc4b32 (diff)
downloadhostap-a1f11e34c4d6a10bdfef58cdba0b19e1335e087b.zip
hostap-a1f11e34c4d6a10bdfef58cdba0b19e1335e087b.tar.gz
hostap-a1f11e34c4d6a10bdfef58cdba0b19e1335e087b.tar.bz2
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>
Diffstat (limited to 'wpa_supplicant/ctrl_iface_named_pipe.c')
-rw-r--r--wpa_supplicant/ctrl_iface_named_pipe.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/wpa_supplicant/ctrl_iface_named_pipe.c b/wpa_supplicant/ctrl_iface_named_pipe.c
index 54e0e2f..9c0a47e 100644
--- a/wpa_supplicant/ctrl_iface_named_pipe.c
+++ b/wpa_supplicant/ctrl_iface_named_pipe.c
@@ -319,13 +319,12 @@ static void wpa_supplicant_ctrl_iface_rx(struct wpa_ctrl_dst *dst, size_t len)
}
os_free(dst->rsp_buf);
- dst->rsp_buf = os_malloc(send_len);
+ dst->rsp_buf = os_memdup(send_buf, send_len);
if (dst->rsp_buf == NULL) {
ctrl_close_pipe(dst);
os_free(reply);
return;
}
- os_memcpy(dst->rsp_buf, send_buf, send_len);
os_free(reply);
if (!WriteFileEx(dst->pipe, dst->rsp_buf, send_len, &dst->overlap,
@@ -739,13 +738,12 @@ static void wpa_supplicant_global_iface_rx(struct wpa_global_dst *dst,
}
os_free(dst->rsp_buf);
- dst->rsp_buf = os_malloc(send_len);
+ dst->rsp_buf = os_memdup(send_buf, send_len);
if (dst->rsp_buf == NULL) {
global_close_pipe(dst);
os_free(reply);
return;
}
- os_memcpy(dst->rsp_buf, send_buf, send_len);
os_free(reply);
if (!WriteFileEx(dst->pipe, dst->rsp_buf, send_len, &dst->overlap,