aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hostapd/accounting.c42
-rw-r--r--hostapd/ap_list.c19
-rw-r--r--hostapd/beacon.c38
-rw-r--r--hostapd/config.c570
-rw-r--r--hostapd/ctrl_iface.c80
-rw-r--r--hostapd/eapol_sm.c14
-rw-r--r--hostapd/hostapd.c104
-rw-r--r--hostapd/hw_features.c14
-rw-r--r--hostapd/iapp.c24
-rw-r--r--hostapd/ieee802_11.c110
-rw-r--r--hostapd/ieee802_11_auth.c83
-rw-r--r--hostapd/ieee802_1x.c366
-rw-r--r--hostapd/peerkey.c30
-rw-r--r--hostapd/pmksa_cache.c31
-rw-r--r--hostapd/preauth.c28
-rw-r--r--hostapd/reconfig.c39
-rw-r--r--hostapd/sta_info.c62
-rw-r--r--hostapd/vlan_init.c87
-rw-r--r--hostapd/wme.c12
-rw-r--r--hostapd/wpa.c312
-rw-r--r--hostapd/wpa_ft.c6
-rw-r--r--src/eap_server/eap.c52
-rw-r--r--src/eap_server/eap_aka.c44
-rw-r--r--src/eap_server/eap_fast.c24
-rw-r--r--src/eap_server/eap_gpsk.c56
-rw-r--r--src/eap_server/eap_gtc.c8
-rw-r--r--src/eap_server/eap_identity.c10
-rw-r--r--src/eap_server/eap_md5.c6
-rw-r--r--src/eap_server/eap_methods.c6
-rw-r--r--src/eap_server/eap_mschapv2.c26
-rw-r--r--src/eap_server/eap_pax.c30
-rw-r--r--src/eap_server/eap_peap.c38
-rw-r--r--src/eap_server/eap_psk.c72
-rw-r--r--src/eap_server/eap_sake.c4
-rw-r--r--src/eap_server/eap_sim.c44
-rw-r--r--src/eap_server/eap_sim_db.c176
-rw-r--r--src/eap_server/eap_tls.c14
-rw-r--r--src/eap_server/eap_tls_common.c42
-rw-r--r--src/eap_server/eap_tlv.c4
-rw-r--r--src/eap_server/eap_ttls.c148
-rw-r--r--src/eap_server/eap_vendor_test.c10
-rw-r--r--src/radius/radius_client.c4
-rw-r--r--src/radius/radius_server.c173
43 files changed, 1538 insertions, 1524 deletions
diff --git a/hostapd/accounting.c b/hostapd/accounting.c
index 26bcd64..7fda7bc 100644
--- a/hostapd/accounting.c
+++ b/hostapd/accounting.c
@@ -53,10 +53,10 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
if (sta) {
radius_msg_make_authenticator(msg, (u8 *) sta, sizeof(*sta));
- snprintf(buf, sizeof(buf), "%08X-%08X",
- sta->acct_session_id_hi, sta->acct_session_id_lo);
+ os_snprintf(buf, sizeof(buf), "%08X-%08X",
+ sta->acct_session_id_hi, sta->acct_session_id_lo);
if (!radius_msg_add_attr(msg, RADIUS_ATTR_ACCT_SESSION_ID,
- (u8 *) buf, strlen(buf))) {
+ (u8 *) buf, os_strlen(buf))) {
printf("Could not add Acct-Session-Id\n");
goto fail;
}
@@ -81,10 +81,10 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
if (sta) {
val = ieee802_1x_get_identity(sta->eapol_sm, &len);
if (!val) {
- snprintf(buf, sizeof(buf), RADIUS_ADDR_FORMAT,
- MAC2STR(sta->addr));
+ os_snprintf(buf, sizeof(buf), RADIUS_ADDR_FORMAT,
+ MAC2STR(sta->addr));
val = (u8 *) buf;
- len = strlen(buf);
+ len = os_strlen(buf);
}
if (!radius_msg_add_attr(msg, RADIUS_ATTR_USER_NAME, val,
@@ -113,7 +113,7 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
if (hapd->conf->nas_identifier &&
!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IDENTIFIER,
(u8 *) hapd->conf->nas_identifier,
- strlen(hapd->conf->nas_identifier))) {
+ os_strlen(hapd->conf->nas_identifier))) {
printf("Could not add NAS-Identifier\n");
goto fail;
}
@@ -124,19 +124,19 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
goto fail;
}
- snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT ":%s",
- MAC2STR(hapd->own_addr), hapd->conf->ssid.ssid);
+ os_snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT ":%s",
+ MAC2STR(hapd->own_addr), hapd->conf->ssid.ssid);
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLED_STATION_ID,
- (u8 *) buf, strlen(buf))) {
+ (u8 *) buf, os_strlen(buf))) {
printf("Could not add Called-Station-Id\n");
goto fail;
}
if (sta) {
- snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT,
- MAC2STR(sta->addr));
+ os_snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT,
+ MAC2STR(sta->addr));
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLING_STATION_ID,
- (u8 *) buf, strlen(buf))) {
+ (u8 *) buf, os_strlen(buf))) {
printf("Could not add Calling-Station-Id\n");
goto fail;
}
@@ -148,12 +148,12 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
goto fail;
}
- snprintf(buf, sizeof(buf), "CONNECT %d%sMbps %s",
- radius_sta_rate(hapd, sta) / 2,
- (radius_sta_rate(hapd, sta) & 1) ? ".5" : "",
- radius_mode_txt(hapd));
+ os_snprintf(buf, sizeof(buf), "CONNECT %d%sMbps %s",
+ radius_sta_rate(hapd, sta) / 2,
+ (radius_sta_rate(hapd, sta) & 1) ? ".5" : "",
+ radius_mode_txt(hapd));
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CONNECT_INFO,
- (u8 *) buf, strlen(buf))) {
+ (u8 *) buf, os_strlen(buf))) {
printf("Could not add Connect-Info\n");
goto fail;
}
@@ -176,7 +176,7 @@ static struct radius_msg * accounting_msg(struct hostapd_data *hapd,
fail:
radius_msg_free(msg);
- free(msg);
+ os_free(msg);
return NULL;
}
@@ -354,7 +354,7 @@ void accounting_sta_report(struct hostapd_data *hapd, struct sta_info *sta,
fail:
radius_msg_free(msg);
- free(msg);
+ os_free(msg);
}
@@ -425,7 +425,7 @@ static void accounting_report_state(struct hostapd_data *hapd, int on)
{
printf("Could not add Acct-Terminate-Cause\n");
radius_msg_free(msg);
- free(msg);
+ os_free(msg);
return;
}
diff --git a/hostapd/ap_list.c b/hostapd/ap_list.c
index 4ba76f2..b249469 100644
--- a/hostapd/ap_list.c
+++ b/hostapd/ap_list.c
@@ -112,7 +112,7 @@ struct ap_info * ap_get_ap(struct hostapd_iface *iface, u8 *ap)
struct ap_info *s;
s = iface->ap_hash[STA_HASH(ap)];
- while (s != NULL && memcmp(s->addr, ap, ETH_ALEN) != 0)
+ while (s != NULL && os_memcmp(s->addr, ap, ETH_ALEN) != 0)
s = s->hnext;
return s;
}
@@ -185,13 +185,13 @@ static void ap_ap_hash_del(struct hostapd_iface *iface, struct ap_info *ap)
s = iface->ap_hash[STA_HASH(ap->addr)];
if (s == NULL) return;
- if (memcmp(s->addr, ap->addr, ETH_ALEN) == 0) {
+ if (os_memcmp(s->addr, ap->addr, ETH_ALEN) == 0) {
iface->ap_hash[STA_HASH(ap->addr)] = s->hnext;
return;
}
while (s->hnext != NULL &&
- memcmp(s->hnext->addr, ap->addr, ETH_ALEN) != 0)
+ os_memcmp(s->hnext->addr, ap->addr, ETH_ALEN) != 0)
s = s->hnext;
if (s->hnext != NULL)
s->hnext = s->hnext->hnext;
@@ -208,7 +208,7 @@ static void ap_free_ap(struct hostapd_iface *iface, struct ap_info *ap)
ap_ap_iter_list_del(iface, ap);
iface->num_ap--;
- free(ap);
+ os_free(ap);
}
@@ -256,7 +256,7 @@ static struct ap_info * ap_ap_add(struct hostapd_iface *iface, u8 *addr)
return NULL;
/* initialize AP info data */
- memcpy(ap->addr, addr, ETH_ALEN);
+ os_memcpy(ap->addr, addr, ETH_ALEN);
ap_ap_list_add(iface, ap);
iface->num_ap++;
ap_ap_hash_add(iface, ap);
@@ -303,18 +303,18 @@ void ap_list_process_beacon(struct hostapd_iface *iface,
len = elems->ssid_len;
if (len >= sizeof(ap->ssid))
len = sizeof(ap->ssid) - 1;
- memcpy(ap->ssid, elems->ssid, len);
+ os_memcpy(ap->ssid, elems->ssid, len);
ap->ssid[len] = '\0';
ap->ssid_len = len;
}
- memset(ap->supported_rates, 0, WLAN_SUPP_RATES_MAX);
+ os_memset(ap->supported_rates, 0, WLAN_SUPP_RATES_MAX);
len = 0;
if (elems->supp_rates) {
len = elems->supp_rates_len;
if (len > WLAN_SUPP_RATES_MAX)
len = WLAN_SUPP_RATES_MAX;
- memcpy(ap->supported_rates, elems->supp_rates, len);
+ os_memcpy(ap->supported_rates, elems->supp_rates, len);
}
if (elems->ext_supp_rates) {
int len2;
@@ -322,7 +322,8 @@ void ap_list_process_beacon(struct hostapd_iface *iface,
len2 = WLAN_SUPP_RATES_MAX - len;
else
len2 = elems->ext_supp_rates_len;
- memcpy(ap->supported_rates + len, elems->ext_supp_rates, len2);
+ os_memcpy(ap->supported_rates + len, elems->ext_supp_rates,
+ len2);
}
ap->wpa = elems->wpa_ie != NULL;
diff --git a/hostapd/beacon.c b/hostapd/beacon.c
index 9e7c4f8..4137973 100644
--- a/hostapd/beacon.c
+++ b/hostapd/beacon.c
@@ -105,7 +105,7 @@ static u8 * hostapd_eid_country(struct hostapd_data *hapd, u8 *eid,
*pos++ = WLAN_EID_COUNTRY;
pos++; /* length will be set later */
- memcpy(pos, hapd->iconf->country, 3); /* e.g., 'US ' */
+ os_memcpy(pos, hapd->iconf->country, 3); /* e.g., 'US ' */
pos += 3;
if ((pos - eid) & 1)
@@ -166,7 +166,7 @@ static u8 * hostapd_eid_wpa(struct hostapd_data *hapd, u8 *eid, size_t len,
if (ie == NULL || ielen > len)
return eid;
- memcpy(eid, ie, ielen);
+ os_memcpy(eid, ie, ielen);
return eid + ielen;
}
@@ -215,7 +215,8 @@ void handle_probe_req(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
if (elems.ssid_len == 0 ||
(elems.ssid_len == hapd->conf->ssid.ssid_len &&
- memcmp(elems.ssid, hapd->conf->ssid.ssid, elems.ssid_len) == 0)) {
+ os_memcmp(elems.ssid, hapd->conf->ssid.ssid, elems.ssid_len) ==
+ 0)) {
ssid = hapd->conf->ssid.ssid;
ssid_len = hapd->conf->ssid.ssid_len;
if (sta)
@@ -242,10 +243,10 @@ void handle_probe_req(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
resp->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
WLAN_FC_STYPE_PROBE_RESP);
- memcpy(resp->da, mgmt->sa, ETH_ALEN);
- memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
+ os_memcpy(resp->da, mgmt->sa, ETH_ALEN);
+ os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
- memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
+ os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
resp->u.probe_resp.beacon_int =
host_to_le16(hapd->iconf->beacon_int);
@@ -256,7 +257,7 @@ void handle_probe_req(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
pos = resp->u.probe_resp.variable;
*pos++ = WLAN_EID_SSID;
*pos++ = ssid_len;
- memcpy(pos, ssid, ssid_len);
+ os_memcpy(pos, ssid, ssid_len);
pos += ssid_len;
/* Supported rates */
@@ -285,7 +286,7 @@ void handle_probe_req(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
if (hostapd_send_mgmt_frame(hapd, resp, pos - (u8 *) resp, 0) < 0)
perror("handle_probe_req: send");
- free(resp);
+ os_free(resp);
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MSGDUMPS, "STA " MACSTR
" sent probe request for %s SSID\n",
@@ -307,21 +308,21 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
#define BEACON_HEAD_BUF_SIZE 256
#define BEACON_TAIL_BUF_SIZE 256
head = os_zalloc(BEACON_HEAD_BUF_SIZE);
- tailpos = tail = malloc(BEACON_TAIL_BUF_SIZE);
+ tailpos = tail = os_malloc(BEACON_TAIL_BUF_SIZE);
if (head == NULL || tail == NULL) {
printf("Failed to set beacon data\n");
- free(head);
- free(tail);
+ os_free(head);
+ os_free(tail);
return;
}
head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
WLAN_FC_STYPE_BEACON);
head->duration = host_to_le16(0);
- memset(head->da, 0xff, ETH_ALEN);
+ os_memset(head->da, 0xff, ETH_ALEN);
- memcpy(head->sa, hapd->own_addr, ETH_ALEN);
- memcpy(head->bssid, hapd->own_addr, ETH_ALEN);
+ os_memcpy(head->sa, hapd->own_addr, ETH_ALEN);
+ os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN);
head->u.beacon.beacon_int =
host_to_le16(hapd->iconf->beacon_int);
@@ -335,13 +336,14 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
if (hapd->conf->ignore_broadcast_ssid == 2) {
/* clear the data, but keep the correct length of the SSID */
*pos++ = hapd->conf->ssid.ssid_len;
- memset(pos, 0, hapd->conf->ssid.ssid_len);
+ os_memset(pos, 0, hapd->conf->ssid.ssid_len);
pos += hapd->conf->ssid.ssid_len;
} else if (hapd->conf->ignore_broadcast_ssid) {
*pos++ = 0; /* empty SSID */
} else {
*pos++ = hapd->conf->ssid.ssid_len;
- memcpy(pos, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len);
+ os_memcpy(pos, hapd->conf->ssid.ssid,
+ hapd->conf->ssid.ssid_len);
pos += hapd->conf->ssid.ssid_len;
}
@@ -379,8 +381,8 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
tail, tail_len))
printf("Failed to set beacon head/tail\n");
- free(tail);
- free(head);
+ os_free(tail);
+ os_free(head);
if (hostapd_set_cts_protect(hapd, cts_protection))
printf("Failed to set CTS protect in kernel driver\n");
diff --git a/hostapd/config.c b/hostapd/config.c
index 7ffdf78..e02712b 100644
--- a/hostapd/config.c
+++ b/hostapd/config.c
@@ -81,14 +81,14 @@ static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss,
while (*pos2 != ' ' && *pos2 != '\t' && *pos2 != '\0')
pos2++;
*pos2 = '\0';
- if (*pos == '\0' || strlen(pos) > IFNAMSIZ) {
+ if (*pos == '\0' || os_strlen(pos) > IFNAMSIZ) {
printf("Invalid VLAN ifname at line %d in '%s'\n",
line, fname);
fclose(f);
return -1;
}
- vlan = malloc(sizeof(*vlan));
+ vlan = os_malloc(sizeof(*vlan));
if (vlan == NULL) {
printf("Out of memory while reading VLAN interfaces "
"from '%s'\n", fname);
@@ -96,7 +96,7 @@ static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss,
return -1;
}
- memset(vlan, 0, sizeof(*vlan));
+ os_memset(vlan, 0, sizeof(*vlan));
vlan->vlan_id = vlan_id;
os_strlcpy(vlan->ifname, pos, sizeof(vlan->ifname));
if (bss->vlan_tail)
@@ -121,7 +121,7 @@ static void hostapd_config_free_vlan(struct hostapd_bss_config *bss)
while (vlan) {
prev = vlan;
vlan = vlan->next;
- free(prev);
+ os_free(prev);
}
bss->vlan = NULL;
@@ -136,7 +136,7 @@ static int hostapd_config_read_int10(const char *value)
char *pos;
i = atoi(value);
- pos = strchr(value, '.');
+ pos = os_strchr(value, '.');
d = 0;
if (pos) {
pos++;
@@ -199,8 +199,8 @@ static struct hostapd_config * hostapd_config_defaults(void)
bss = os_zalloc(sizeof(*bss));
if (conf == NULL || bss == NULL) {
printf("Failed to allocate memory for configuration data.\n");
- free(conf);
- free(bss);
+ os_free(conf);
+ os_free(bss);
return NULL;
}
@@ -208,15 +208,15 @@ static struct hostapd_config * hostapd_config_defaults(void)
conf->driver = hostapd_drivers[0];
if (conf->driver == NULL) {
printf("No driver wrappers registered!\n");
- free(conf);
- free(bss);
+ os_free(conf);
+ os_free(bss);
return NULL;
}
bss->radius = os_zalloc(sizeof(*bss->radius));
if (bss->radius == NULL) {
- free(conf);
- free(bss);
+ os_free(conf);
+ os_free(bss);
return NULL;
}
@@ -231,7 +231,7 @@ static struct hostapd_config * hostapd_config_defaults(void)
conf->send_probe_response = 1;
conf->bridge_packets = INTERNAL_BRIDGE_DO_NOT_CONTROL;
- memcpy(conf->country, "US ", 3);
+ os_memcpy(conf->country, "US ", 3);
for (i = 0; i < NUM_TX_QUEUES; i++)
conf->tx_queue[i].aifs = -1; /* use hw default */
@@ -247,14 +247,14 @@ static struct hostapd_config * hostapd_config_defaults(void)
int hostapd_mac_comp(const void *a, const void *b)
{
- return memcmp(a, b, sizeof(macaddr));
+ return os_memcmp(a, b, sizeof(macaddr));
}
int hostapd_mac_comp_empty(const void *a)
{
macaddr empty = { 0 };
- return memcmp(a, empty, sizeof(macaddr));
+ return os_memcmp(a, empty, sizeof(macaddr));
}
@@ -299,7 +299,7 @@ static int hostapd_config_read_maclist(const char *fname, macaddr **acl,
return -1;
}
- newacl = (macaddr *) realloc(*acl, (*num + 1) * ETH_ALEN);
+ newacl = os_realloc(*acl, (*num + 1) * ETH_ALEN);
if (newacl == NULL) {
printf("MAC list reallocation failed\n");
fclose(f);
@@ -307,7 +307,7 @@ static int hostapd_config_read_maclist(const char *fname, macaddr **acl,
}
*acl = newacl;
- memcpy((*acl)[*num], addr, ETH_ALEN);
+ os_memcpy((*acl)[*num], addr, ETH_ALEN);
(*num)++;
}
@@ -366,22 +366,22 @@ static int hostapd_config_read_wpa_psk(const char *fname,
ret = -1;
break;
}
- if (memcmp(addr, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
+ if (os_memcmp(addr, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
psk->group = 1;
else
- memcpy(psk->addr, addr, ETH_ALEN);
+ os_memcpy(psk->addr, addr, ETH_ALEN);
pos = buf + 17;
if (pos == '\0') {
printf("No PSK on line %d in '%s'\n", line, fname);
- free(psk);
+ os_free(psk);
ret = -1;
break;
}
pos++;
ok = 0;
- len = strlen(pos);
+ len = os_strlen(pos);
if (len == 64 && hexstr2bin(pos, psk->psk, PMK_LEN) == 0)
ok = 1;
else if (len >= 8 && len < 64) {
@@ -392,7 +392,7 @@ static int hostapd_config_read_wpa_psk(const char *fname,
if (!ok) {
printf("Invalid PSK '%s' on line %d in '%s'\n",
pos, line, fname);
- free(psk);
+ os_free(psk);
ret = -1;
break;
}
@@ -415,7 +415,7 @@ int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
if (ssid->wpa_psk != NULL) {
printf("Warning: both WPA PSK and passphrase set. "
"Using passphrase.\n");
- free(ssid->wpa_psk);
+ os_free(ssid->wpa_psk);
}
ssid->wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
if (ssid->wpa_psk == NULL) {
@@ -426,7 +426,7 @@ int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
(u8 *) ssid->ssid, ssid->ssid_len);
wpa_hexdump_ascii(MSG_DEBUG, "PSK (ASCII passphrase)",
(u8 *) ssid->wpa_passphrase,
- strlen(ssid->wpa_passphrase));
+ os_strlen(ssid->wpa_passphrase));
pbkdf2_sha1(ssid->wpa_passphrase,
ssid->ssid, ssid->ssid_len,
4096, ssid->wpa_psk->psk, PMK_LEN);
@@ -434,9 +434,9 @@ int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
ssid->wpa_psk->psk, PMK_LEN);
ssid->wpa_psk->group = 1;
- memset(ssid->wpa_passphrase, 0,
- strlen(ssid->wpa_passphrase));
- free(ssid->wpa_passphrase);
+ os_memset(ssid->wpa_passphrase, 0,
+ os_strlen(ssid->wpa_passphrase));
+ os_free(ssid->wpa_passphrase);
ssid->wpa_passphrase = NULL;
}
@@ -444,7 +444,7 @@ int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
if (hostapd_config_read_wpa_psk(ssid->wpa_psk_file,
&conf->ssid))
return -1;
- free(ssid->wpa_psk_file);
+ os_free(ssid->wpa_psk_file);
ssid->wpa_psk_file = NULL;
}
@@ -515,13 +515,13 @@ static int hostapd_config_read_eap_user(const char *fname,
goto failed;
}
- user->identity = malloc(pos - start);
+ user->identity = os_malloc(pos - start);
if (user->identity == NULL) {
printf("Failed to allocate memory for EAP "
"identity\n");
goto failed;
}
- memcpy(user->identity, start, pos - start);
+ os_memcpy(user->identity, start, pos - start);
user->identity_len = pos - start;
if (pos[0] == '"' && pos[1] == '*') {
@@ -550,7 +550,7 @@ static int hostapd_config_read_eap_user(const char *fname,
}
num_methods = 0;
while (*start) {
- char *pos3 = strchr(start, ',');
+ char *pos3 = os_strchr(start, ',');
if (pos3) {
*pos3++ = '\0';
}
@@ -588,17 +588,17 @@ static int hostapd_config_read_eap_user(const char *fname,
if (*pos == '\0')
goto done;
- if (strncmp(pos, "[ver=0]", 7) == 0) {
+ if (os_strncmp(pos, "[ver=0]", 7) == 0) {
user->force_version = 0;
goto done;
}
- if (strncmp(pos, "[ver=1]", 7) == 0) {
+ if (os_strncmp(pos, "[ver=1]", 7) == 0) {
user->force_version = 1;
goto done;
}
- if (strncmp(pos, "[2]", 3) == 0) {
+ if (os_strncmp(pos, "[2]", 3) == 0) {
user->phase2 = 1;
goto done;
}
@@ -614,17 +614,17 @@ static int hostapd_config_read_eap_user(const char *fname,
goto failed;
}
- user->password = malloc(pos - start);
+ user->password = os_malloc(pos - start);
if (user->password == NULL) {
printf("Failed to allocate memory for EAP "
"password\n");
goto failed;
}
- memcpy(user->password, start, pos - start);
+ os_memcpy(user->password, start, pos - start);
user->password_len = pos - start;
pos++;
- } else if (strncmp(pos, "hash:", 5) == 0) {
+ } else if (os_strncmp(pos, "hash:", 5) == 0) {
pos += 5;
pos2 = pos;
while (*pos2 != '\0' && *pos2 != ' ' &&
@@ -635,7 +635,7 @@ static int hostapd_config_read_eap_user(const char *fname,
"'%s'\n", line, fname);
goto failed;
}
- user->password = malloc(16);
+ user->password = os_malloc(16);
if (user->password == NULL) {
printf("Failed to allocate memory for EAP "
"password hash\n");
@@ -659,7 +659,7 @@ static int hostapd_config_read_eap_user(const char *fname,
"'%s'\n", line, fname);
goto failed;
}
- user->password = malloc((pos2 - pos) / 2);
+ user->password = os_malloc((pos2 - pos) / 2);
if (user->password == NULL) {
printf("Failed to allocate memory for EAP "
"password\n");
@@ -677,7 +677,7 @@ static int hostapd_config_read_eap_user(const char *fname,
while (*pos == ' ' || *pos == '\t')
pos++;
- if (strncmp(pos, "[2]", 3) == 0) {
+ if (os_strncmp(pos, "[2]", 3) == 0) {
user->phase2 = 1;
}
@@ -692,9 +692,9 @@ static int hostapd_config_read_eap_user(const char *fname,
failed:
if (user) {
- free(user->password);
- free(user->identity);
- free(user);
+ os_free(user->password);
+ os_free(user->identity);
+ os_free(user);
}
ret = -1;
break;
@@ -716,7 +716,7 @@ hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
int ret;
static int server_index = 1;
- nserv = realloc(*server, (*num_server + 1) * sizeof(*nserv));
+ nserv = os_realloc(*server, (*num_server + 1) * sizeof(*nserv));
if (nserv == NULL)
return -1;
@@ -725,7 +725,7 @@ hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
(*num_server)++;
(*curr_serv) = nserv;
- memset(nserv, 0, sizeof(*nserv));
+ os_memset(nserv, 0, sizeof(*nserv));
nserv->port = def_port;
ret = hostapd_parse_ip_addr(val, &nserv->addr);
nserv->index = server_index++;
@@ -739,7 +739,7 @@ static int hostapd_config_parse_key_mgmt(int line, const char *value)
int val = 0, last;
char *start, *end, *buf;
- buf = strdup(value);
+ buf = os_strdup(value);
if (buf == NULL)
return -1;
start = buf;
@@ -754,20 +754,20 @@ static int hostapd_config_parse_key_mgmt(int line, const char *value)
end++;
last = *end == '\0';
*end = '\0';
- if (strcmp(start, "WPA-PSK") == 0)
+ if (os_strcmp(start, "WPA-PSK") == 0)
val |= WPA_KEY_MGMT_PSK;
- else if (strcmp(start, "WPA-EAP") == 0)
+ else if (os_strcmp(start, "WPA-EAP") == 0)
val |= WPA_KEY_MGMT_IEEE8021X;
#ifdef CONFIG_IEEE80211R
- else if (strcmp(start, "FT-PSK") == 0)
+ else if (os_strcmp(start, "FT-PSK") == 0)
val |= WPA_KEY_MGMT_FT_PSK;
- else if (strcmp(start, "FT-EAP") == 0)
+ else if (os_strcmp(start, "FT-EAP") == 0)
val |= WPA_KEY_MGMT_FT_IEEE8021X;
#endif /* CONFIG_IEEE80211R */
else {
printf("Line %d: invalid key_mgmt '%s'\n",
line, start);
- free(buf);
+ os_free(buf);
return -1;
}
@@ -776,7 +776,7 @@ static int hostapd_config_parse_key_mgmt(int line, const char *value)
start = end + 1;
}
- free(buf);
+ os_free(buf);
if (val == 0) {
printf("Line %d: no key_mgmt values configured.\n", line);
return -1;
@@ -791,7 +791,7 @@ static int hostapd_config_parse_cipher(int line, const char *value)
int val = 0, last;
char *start, *end, *buf;
- buf = strdup(value);
+ buf = os_strdup(value);
if (buf == NULL)
return -1;
start = buf;
@@ -806,19 +806,19 @@ static int hostapd_config_parse_cipher(int line, const char *value)
end++;
last = *end == '\0';
*end = '\0';
- if (strcmp(start, "CCMP") == 0)
+ if (os_strcmp(start, "CCMP") == 0)
val |= WPA_CIPHER_CCMP;
- else if (strcmp(start, "TKIP") == 0)
+ else if (os_strcmp(start, "TKIP") == 0)
val |= WPA_CIPHER_TKIP;
- else if (strcmp(start, "WEP104") == 0)
+ else if (os_strcmp(start, "WEP104") == 0)
val |= WPA_CIPHER_WEP104;
- else if (strcmp(start, "WEP40") == 0)
+ else if (os_strcmp(start, "WEP40") == 0)
val |= WPA_CIPHER_WEP40;
- else if (strcmp(start, "NONE") == 0)
+ else if (os_strcmp(start, "NONE") == 0)
val |= WPA_CIPHER_NONE;
else {
printf("Line %d: invalid cipher '%s'.", line, start);
- free(buf);
+ os_free(buf);
return -1;
}
@@ -826,7 +826,7 @@ static int hostapd_config_parse_cipher(int line, const char *value)
break;
start = end + 1;
}
- free(buf);
+ os_free(buf);
if (val == 0) {
printf("Line %d: no cipher values configured.", line);
@@ -902,7 +902,7 @@ static int hostapd_config_check(struct hostapd_config *conf)
static int hostapd_config_read_wep(struct hostapd_wep_keys *wep, int keyidx,
char *val)
{
- size_t len = strlen(val);
+ size_t len = os_strlen(val);
if (keyidx < 0 || keyidx > 3 || wep->key[keyidx] != NULL)
return -1;
@@ -911,16 +911,16 @@ static int hostapd_config_read_wep(struct hostapd_wep_keys *wep, int keyidx,
if (len < 2 || val[len - 1] != '"')
return -1;
len -= 2;
- wep->key[keyidx] = malloc(len);
+ wep->key[keyidx] = os_malloc(len);
if (wep->key[keyidx] == NULL)
return -1;
- memcpy(wep->key[keyidx], val + 1, len);
+ os_memcpy(wep->key[keyidx], val + 1, len);
wep->len[keyidx] = len;
} else {
if (len & 1)
return -1;
len /= 2;
- wep->key[keyidx] = malloc(len);
+ wep->key[keyidx] = os_malloc(len);
if (wep->key[keyidx] == NULL)
return -1;
wep->len[keyidx] = len;
@@ -940,7 +940,7 @@ static int hostapd_parse_rates(int **rate_list, char *val)
int count;
char *pos, *end;
- free(*rate_list);
+ os_free(*rate_list);
*rate_list = NULL;
pos = val;
@@ -951,13 +951,13 @@ static int hostapd_parse_rates(int **rate_list, char *val)
pos++;
}
- list = malloc(sizeof(int) * (count + 2));
+ list = os_malloc(sizeof(int) * (count + 2));
if (list == NULL)
return -1;
pos = val;
count = 0;
while (*pos != '\0') {
- end = strchr(pos, ' ');
+ end = os_strchr(pos, ' ');
if (end)
*end = '\0';
@@ -980,8 +980,8 @@ static int hostapd_config_bss(struct hostapd_config *conf, const char *ifname)
if (*ifname == '\0')
return -1;
- bss = realloc(conf->bss, (conf->num_bss + 1) *
- sizeof(struct hostapd_bss_config));
+ bss = os_realloc(conf->bss, (conf->num_bss + 1) *
+ sizeof(struct hostapd_bss_config));
if (bss == NULL) {
printf("Failed to allocate memory for multi-BSS entry\n");
return -1;
@@ -989,7 +989,7 @@ static int hostapd_config_bss(struct hostapd_config *conf, const char *ifname)
conf->bss = bss;
bss = &(conf->bss[conf->num_bss]);
- memset(bss, 0, sizeof(*bss));
+ os_memset(bss, 0, sizeof(*bss));
bss->radius = os_zalloc(sizeof(*bss->radius));
if (bss->radius == NULL) {
printf("Failed to allocate memory for multi-BSS RADIUS "
@@ -1002,7 +1002,7 @@ static int hostapd_config_bss(struct hostapd_config *conf, const char *ifname)
hostapd_config_defaults_bss(bss);
os_strlcpy(bss->iface, ifname, sizeof(bss->iface));
- memcpy(bss->ssid.vlan, bss->iface, IFNAMSIZ + 1);
+ os_memcpy(bss->ssid.vlan, bss->iface, IFNAMSIZ + 1);
return 0;
}
@@ -1034,14 +1034,14 @@ static int hostapd_config_tx_queue(struct hostapd_config *conf, char *name,
/* skip 'tx_queue_' prefix */
pos = name + 9;
- if (strncmp(pos, "data", 4) == 0 &&
+ if (os_strncmp(pos, "data", 4) == 0 &&
pos[4] >= '0' && pos[4] <= '9' && pos[5] == '_') {
num = pos[4] - '0';
pos += 6;
- } else if (strncmp(pos, "after_beacon_", 13) == 0) {
+ } else if (os_strncmp(pos, "after_beacon_", 13) == 0) {
num = IEEE80211_TX_QUEUE_AFTER_BEACON;
pos += 13;
- } else if (strncmp(pos, "beacon_", 7) == 0) {
+ } else if (os_strncmp(pos, "beacon_", 7) == 0) {
num = IEEE80211_TX_QUEUE_BEACON;
pos += 7;
} else {
@@ -1051,25 +1051,25 @@ static int hostapd_config_tx_queue(struct hostapd_config *conf, char *name,
queue = &conf->tx_queue[num];
- if (strcmp(pos, "aifs") == 0) {
+ if (os_strcmp(pos, "aifs") == 0) {
queue->aifs = atoi(val);
if (queue->aifs < 0 || queue->aifs > 255) {
printf("Invalid AIFS value %d\n", queue->aifs);
return -1;
}
- } else if (strcmp(pos, "cwmin") == 0) {
+ } else if (os_strcmp(pos, "cwmin") == 0) {
queue->cwmin = atoi(val);
if (!valid_cw(queue->cwmin)) {
printf("Invalid cwMin value %d\n", queue->cwmin);
return -1;
}
- } else if (strcmp(pos, "cwmax") == 0) {
+ } else if (os_strcmp(pos, "cwmax") == 0) {
queue->cwmax = atoi(val);
if (!valid_cw(queue->cwmax)) {
printf("Invalid cwMax value %d\n", queue->cwmax);
return -1;
}
- } else if (strcmp(pos, "burst") == 0) {
+ } else if (os_strcmp(pos, "burst") == 0) {
queue->burst = hostapd_config_read_int10(val);
} else {
printf("Unknown tx_queue field '%s'\n", pos);
@@ -1091,16 +1091,16 @@ static int hostapd_config_wme_ac(struct hostapd_config *conf, char *name,
/* skip 'wme_ac_' prefix */
pos = name + 7;
- if (strncmp(pos, "be_", 3) == 0) {
+ if (os_strncmp(pos, "be_", 3) == 0) {
num = 0;
pos += 3;
- } else if (strncmp(pos, "bk_", 3) == 0) {
+ } else if (os_strncmp(pos, "bk_", 3) == 0) {
num = 1;
pos += 3;
- } else if (strncmp(pos, "vi_", 3) == 0) {
+ } else if (os_strncmp(pos, "vi_", 3) == 0) {
num = 2;
pos += 3;
- } else if (strncmp(pos, "vo_", 3) == 0) {
+ } else if (os_strncmp(pos, "vo_", 3) == 0) {
num = 3;
pos += 3;
} else {
@@ -1110,35 +1110,35 @@ static int hostapd_config_wme_ac(struct hostapd_config *conf, char *name,
ac = &conf->wme_ac_params[num];
- if (strcmp(pos, "aifs") == 0) {
+ if (os_strcmp(pos, "aifs") == 0) {
v = atoi(val);
if (v < 1 || v > 255) {
printf("Invalid AIFS value %d\n", v);
return -1;
}
ac->aifs = v;
- } else if (strcmp(pos, "cwmin") == 0) {
+ } else if (os_strcmp(pos, "cwmin") == 0) {
v = atoi(val);
if (v < 0 || v > 12) {
printf("Invalid cwMin value %d\n", v);
return -1;
}
ac->cwmin = v;
- } else if (strcmp(pos, "cwmax") == 0) {
+ } else if (os_strcmp(pos, "cwmax") == 0) {
v = atoi(val);
if (v < 0 || v > 12) {
printf("Invalid cwMax value %d\n", v);
return -1;
}
ac->cwmax = v;
- } else if (strcmp(pos, "txop_limit") == 0) {
+ } else if (os_strcmp(pos, "txop_limit") == 0) {
v = atoi(val);
if (v < 0 || v > 0xffff) {
printf("Invalid txop value %d\n", v);
return -1;
}
ac->txopLimit = v;
- } else if (strcmp(pos, "acm") == 0) {
+ } else if (os_strcmp(pos, "acm") == 0) {
v = atoi(val);
if (v < 0 || v > 1) {
printf("Invalid acm value %d\n", v);
@@ -1289,7 +1289,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
if (buf[0] == '\0')
continue;
- pos = strchr(buf, '=');
+ pos = os_strchr(buf, '=');
if (pos == NULL) {
printf("Line %d: invalid line '%s'\n", line, buf);
errors++;
@@ -1298,12 +1298,12 @@ struct hostapd_config * hostapd_config_read(const char *fname)
*pos = '\0';
pos++;
- if (strcmp(buf, "interface") == 0) {
+ if (os_strcmp(buf, "interface") == 0) {
os_strlcpy(conf->bss[0].iface, pos,
sizeof(conf->bss[0].iface));
- } else if (strcmp(buf, "bridge") == 0) {
+ } else if (os_strcmp(buf, "bridge") == 0) {
os_strlcpy(bss->bridge, pos, sizeof(bss->bridge));
- } else if (strcmp(buf, "driver") == 0) {
+ } else if (os_strcmp(buf, "driver") == 0) {
int i;
for (i = 0; hostapd_drivers[i]; i++) {
if (os_strcmp(pos, hostapd_drivers[i]->name) ==
@@ -1317,32 +1317,32 @@ struct hostapd_config * hostapd_config_read(const char *fname)
"'%s'\n", line, pos);
errors++;
}
- } else if (strcmp(buf, "debug") == 0) {
+ } else if (os_strcmp(buf, "debug") == 0) {
bss->debug = atoi(pos);
- } else if (strcmp(buf, "logger_syslog_level") == 0) {
+ } else if (os_strcmp(buf, "logger_syslog_level") == 0) {
bss->logger_syslog_level = atoi(pos);
- } else if (strcmp(buf, "logger_stdout_level") == 0) {
+ } else if (os_strcmp(buf, "logger_stdout_level") == 0) {
bss->logger_stdout_level = atoi(pos);
- } else if (strcmp(buf, "logger_syslog") == 0) {
+ } else if (os_strcmp(buf, "logger_syslog") == 0) {
bss->logger_syslog = atoi(pos);
- } else if (strcmp(buf, "logger_stdout") == 0) {
+ } else if (os_strcmp(buf, "logger_stdout") == 0) {
bss->logger_stdout = atoi(pos);
- } else if (strcmp(buf, "dump_file") == 0) {
- bss->dump_log_name = strdup(pos);
- } else if (strcmp(buf, "ssid") == 0) {
- bss->ssid.ssid_len = strlen(pos);
+ } else if (os_strcmp(buf, "dump_file") == 0) {
+ bss->dump_log_name = os_strdup(pos);
+ } else if (os_strcmp(buf, "ssid") == 0) {
+ bss->ssid.ssid_len = os_strlen(pos);
if (bss->ssid.ssid_len > HOSTAPD_MAX_SSID_LEN ||
bss->ssid.ssid_len < 1) {
printf("Line %d: invalid SSID '%s'\n", line,
pos);
errors++;
} else {
- memcpy(bss->ssid.ssid, pos,
- bss->ssid.ssid_len);
+ os_memcpy(bss->ssid.ssid, pos,
+ bss->ssid.ssid_len);
bss->ssid.ssid[bss->ssid.ssid_len] = '\0';
bss->ssid.ssid_set = 1;
}
- } else if (strcmp(buf, "macaddr_acl") == 0) {
+ } else if (os_strcmp(buf, "macaddr_acl") == 0) {
bss->macaddr_acl = atoi(pos);
if (bss->macaddr_acl != ACCEPT_UNLESS_DENIED &&
bss->macaddr_acl != DENY_UNLESS_ACCEPTED &&
@@ -1350,7 +1350,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
printf("Line %d: unknown macaddr_acl %d\n",
line, bss->macaddr_acl);
}
- } else if (strcmp(buf, "accept_mac_file") == 0) {
+ } else if (os_strcmp(buf, "accept_mac_file") == 0) {
if (hostapd_config_read_maclist(pos, &bss->accept_mac,
&bss->num_accept_mac))
{
@@ -1359,7 +1359,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
line, pos);
errors++;
}
- } else if (strcmp(buf, "deny_mac_file") == 0) {
+ } else if (os_strcmp(buf, "deny_mac_file") == 0) {
if (hostapd_config_read_maclist(pos, &bss->deny_mac,
&bss->num_deny_mac))
{
@@ -1368,26 +1368,26 @@ struct hostapd_config * hostapd_config_read(const char *fname)
line, pos);
errors++;
}
- } else if (strcmp(buf, "ap_max_inactivity") == 0) {
+ } else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
bss->ap_max_inactivity = atoi(pos);
- } else if (strcmp(buf, "country_code") == 0) {
- memcpy(conf->country, pos, 2);
+ } else if (os_strcmp(buf, "country_code") == 0) {
+ os_memcpy(conf->country, pos, 2);
/* FIX: make this configurable */
conf->country[2] = ' ';
- } else if (strcmp(buf, "ieee80211d") == 0) {
+ } else if (os_strcmp(buf, "ieee80211d") == 0) {
conf->ieee80211d = atoi(pos);
- } else if (strcmp(buf, "ieee80211h") == 0) {
+ } else if (os_strcmp(buf, "ieee80211h") == 0) {
conf->ieee80211h = atoi(pos);
- } else if (strcmp(buf, "assoc_ap_addr") == 0) {
+ } else if (os_strcmp(buf, "assoc_ap_addr") == 0) {
if (hwaddr_aton(pos, bss->assoc_ap_addr)) {
printf("Line %d: invalid MAC address '%s'\n",
line, pos);
errors++;
}
bss->assoc_ap = 1;
- } else if (strcmp(buf, "ieee8021x") == 0) {
+ } else if (os_strcmp(buf, "ieee8021x") == 0) {
bss->ieee802_1x = atoi(pos);
- } else if (strcmp(buf, "eapol_version") == 0) {
+ } else if (os_strcmp(buf, "eapol_version") == 0) {
bss->eapol_version = atoi(pos);
if (bss->eapol_version < 1 ||
bss->eapol_version > 2) {
@@ -1399,36 +1399,36 @@ struct hostapd_config * hostapd_config_read(const char *fname)
wpa_printf(MSG_DEBUG, "eapol_version=%d",
bss->eapol_version);
#ifdef EAP_SERVER
- } else if (strcmp(buf, "eap_authenticator") == 0) {
+ } else if (os_strcmp(buf, "eap_authenticator") == 0) {
bss->eap_server = atoi(pos);
printf("Line %d: obsolete eap_authenticator used; "
"this has been renamed to eap_server\n", line);
- } else if (strcmp(buf, "eap_server") == 0) {
+ } else if (os_strcmp(buf, "eap_server") == 0) {
bss->eap_server = atoi(pos);
- } else if (strcmp(buf, "eap_user_file") == 0) {
+ } else if (os_strcmp(buf, "eap_user_file") == 0) {
if (hostapd_config_read_eap_user(pos, bss))
errors++;
- } else if (strcmp(buf, "ca_cert") == 0) {
- free(bss->ca_cert);
- bss->ca_cert = strdup(pos);
- } else if (strcmp(buf, "server_cert") == 0) {
- free(bss->server_cert);
- bss->server_cert = strdup(pos);
- } else if (strcmp(buf, "private_key") == 0) {
- free(bss->private_key);
- bss->private_key = strdup(pos);
- } else if (strcmp(buf, "private_key_passwd") == 0) {
- free(bss->private_key_passwd);
- bss->private_key_passwd = strdup(pos);
- } else if (strcmp(buf, "check_crl") == 0) {
+ } else if (os_strcmp(buf, "ca_cert") == 0) {
+ os_free(bss->ca_cert);
+ bss->ca_cert = os_strdup(pos);
+ } else if (os_strcmp(buf, "server_cert") == 0) {
+ os_free(bss->server_cert);
+ bss->server_cert = os_strdup(pos);
+ } else if (os_strcmp(buf, "private_key") == 0) {
+ os_free(bss->private_key);
+ bss->private_key = os_strdup(pos);
+ } else if (os_strcmp(buf, "private_key_passwd") == 0) {
+ os_free(bss->private_key_passwd);
+ bss->private_key_passwd = os_strdup(pos);
+ } else if (os_strcmp(buf, "check_crl") == 0) {
bss->check_crl = atoi(pos);
- } else if (strcmp(buf, "dh_file") == 0) {
- free(bss->dh_file);
- bss->dh_file = strdup(pos);
+ } else if (os_strcmp(buf, "dh_file") == 0) {
+ os_free(bss->dh_file);
+ bss->dh_file = os_strdup(pos);
#ifdef EAP_FAST
- } else if (strcmp(buf, "pac_opaque_encr_key") == 0) {
- free(bss->pac_opaque_encr_key);
- bss->pac_opaque_encr_key = malloc(16);
+ } else if (os_strcmp(buf, "pac_opaque_encr_key") == 0) {
+ os_free(bss->pac_opaque_encr_key);
+ bss->pac_opaque_encr_key = os_malloc(16);
if (bss->pac_opaque_encr_key == NULL) {
printf("Line %d: No memory for "
"pac_opque_encr_key\n", line);
@@ -1439,19 +1439,19 @@ struct hostapd_config * hostapd_config_read(const char *fname)
line);
errors++;
}
- } else if (strcmp(buf, "eap_fast_a_id") == 0) {
- free(bss->eap_fast_a_id);
- bss->eap_fast_a_id = strdup(pos);
+ } else if (os_strcmp(buf, "eap_fast_a_id") == 0) {
+ os_free(bss->eap_fast_a_id);
+ bss->eap_fast_a_id = os_strdup(pos);
#endif /* EAP_FAST */
#ifdef EAP_SIM
- } else if (strcmp(buf, "eap_sim_db") == 0) {
- free(bss->eap_sim_db);
- bss->eap_sim_db = strdup(pos);
+ } else if (os_strcmp(buf, "eap_sim_db") == 0) {
+ os_free(bss->eap_sim_db);
+ bss->eap_sim_db = os_strdup(pos);
#endif /* EAP_SIM */
#endif /* EAP_SERVER */
- } else if (strcmp(buf, "eap_message") == 0) {
+ } else if (os_strcmp(buf, "eap_message") == 0) {
char *term;
- bss->eap_req_id_text = strdup(pos);
+ bss->eap_req_id_text = os_strdup(pos);
if (bss->eap_req_id_text == NULL) {
printf("Line %d: Failed to allocate memory "
"for eap_req_id_text\n", line);
@@ -1459,16 +1459,16 @@ struct hostapd_config * hostapd_config_read(const char *fname)
continue;
}
bss->eap_req_id_text_len =
- strlen(bss->eap_req_id_text);
- term = strstr(bss->eap_req_id_text, "\\0");
+ os_strlen(bss->eap_req_id_text);
+ term = os_strstr(bss->eap_req_id_text, "\\0");
if (term) {
*term++ = '\0';
- memmove(term, term + 1,
- bss->eap_req_id_text_len -
- (term - bss->eap_req_id_text) - 1);
+ os_memmove(term, term + 1,
+ bss->eap_req_id_text_len -
+ (term - bss->eap_req_id_text) - 1);
bss->eap_req_id_text_len--;
}
- } else if (strcmp(buf, "wep_key_len_broadcast") == 0) {
+ } else if (os_strcmp(buf, "wep_key_len_broadcast") == 0) {
bss->default_wep_key_len = atoi(pos);
if (bss->default_wep_key_len > 13) {
printf("Line %d: invalid WEP key len %lu "
@@ -1479,7 +1479,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
bss->default_wep_key_len * 8);
errors++;
}
- } else if (strcmp(buf, "wep_key_len_unicast") == 0) {
+ } else if (os_strcmp(buf, "wep_key_len_unicast") == 0) {
bss->individual_wep_key_len = atoi(pos);
if (bss->individual_wep_key_len < 0 ||
bss->individual_wep_key_len > 13) {
@@ -1489,37 +1489,37 @@ struct hostapd_config * hostapd_config_read(const char *fname)
bss->individual_wep_key_len * 8);
errors++;
}
- } else if (strcmp(buf, "wep_rekey_period") == 0) {
+ } else if (os_strcmp(buf, "wep_rekey_period") == 0) {
bss->wep_rekeying_period = atoi(pos);
if (bss->wep_rekeying_period < 0) {
printf("Line %d: invalid period %d\n",
line, bss->wep_rekeying_period);
errors++;
}
- } else if (strcmp(buf, "eap_reauth_period") == 0) {
+ } else if (os_strcmp(buf, "eap_reauth_period") == 0) {
bss->eap_reauth_period = atoi(pos);
if (bss->eap_reauth_period < 0) {
printf("Line %d: invalid period %d\n",
line, bss->eap_reauth_period);
errors++;
}
- } else if (strcmp(buf, "eapol_key_index_workaround") == 0) {
+ } else if (os_strcmp(buf, "eapol_key_index_workaround") == 0) {
bss->eapol_key_index_workaround = atoi(pos);
#ifdef CONFIG_IAPP
- } else if (strcmp(buf, "iapp_interface") == 0) {
+ } else if (os_strcmp(buf, "iapp_interface") == 0) {
bss->ieee802_11f = 1;
os_strlcpy(bss->iapp_iface, pos,
sizeof(bss->iapp_iface));
#endif /* CONFIG_IAPP */
- } else if (strcmp(buf, "own_ip_addr") == 0) {
+ } else if (os_strcmp(buf, "own_ip_addr") == 0) {
if (hostapd_parse_ip_addr(pos, &bss->own_ip_addr)) {
printf("Line %d: invalid IP address '%s'\n",
line, pos);
errors++;
}
- } else if (strcmp(buf, "nas_identifier") == 0) {
- bss->nas_identifier = strdup(pos);
- } else if (strcmp(buf, "auth_server_addr") == 0) {
+ } else if (os_strcmp(buf, "nas_identifier") == 0) {
+ bss->nas_identifier = os_strdup(pos);
+ } else if (os_strcmp(buf, "auth_server_addr") == 0) {
if (hostapd_config_read_radius_addr(
&bss->radius->auth_servers,
&bss->radius->num_auth_servers, pos, 1812,
@@ -1529,11 +1529,11 @@ struct hostapd_config * hostapd_config_read(const char *fname)
errors++;
}
} else if (bss->radius->auth_server &&
- strcmp(buf, "auth_server_port") == 0) {
+ os_strcmp(buf, "auth_server_port") == 0) {
bss->radius->auth_server->port = atoi(pos);
} else if (bss->radius->auth_server &&
- strcmp(buf, "auth_server_shared_secret") == 0) {
- int len = strlen(pos);
+ os_strcmp(buf, "auth_server_shared_secret") == 0) {
+ int len = os_strlen(pos);
if (len == 0) {
/* RFC 2865, Ch. 3 */
printf("Line %d: empty shared secret is not "
@@ -1541,9 +1541,9 @@ struct hostapd_config * hostapd_config_read(const char *fname)
errors++;
}
bss->radius->auth_server->shared_secret =
- (u8 *) strdup(pos);
+ (u8 *) os_strdup(pos);
bss->radius->auth_server->shared_secret_len = len;
- } else if (strcmp(buf, "acct_server_addr") == 0) {
+ } else if (os_strcmp(buf, "acct_server_addr") == 0) {
if (hostapd_config_read_radius_addr(
&bss->radius->acct_servers,
&bss->radius->num_acct_servers, pos, 1813,
@@ -1553,11 +1553,11 @@ struct hostapd_config * hostapd_config_read(const char *fname)
errors++;
}
} else if (bss->radius->acct_server &&
- strcmp(buf, "acct_server_port") == 0) {
+ os_strcmp(buf, "acct_server_port") == 0) {
bss->radius->acct_server->port = atoi(pos);
} else if (bss->radius->acct_server &&
- strcmp(buf, "acct_server_shared_secret") == 0) {
- int len = strlen(pos);
+ os_strcmp(buf, "acct_server_shared_secret") == 0) {
+ int len = os_strlen(pos);
if (len == 0) {
/* RFC 2865, Ch. 3 */
printf("Line %d: empty shared secret is not "
@@ -1565,13 +1565,15 @@ struct hostapd_config * hostapd_config_read(const char *fname)
errors++;
}
bss->radius->acct_server->shared_secret =
- (u8 *) strdup(pos);
+ (u8 *) os_strdup(pos);
bss->radius->acct_server->shared_secret_len = len;
- } else if (strcmp(buf, "radius_retry_primary_interval") == 0) {
+ } else if (os_strcmp(buf, "radius_retry_primary_interval") ==
+ 0) {
bss->radius->retry_primary_interval = atoi(pos);
- } else if (strcmp(buf, "radius_acct_interim_interval") == 0) {
+ } else if (os_strcmp(buf, "radius_acct_interim_interval") == 0)
+ {
bss->radius->acct_interim_interval = atoi(pos);
- } else if (strcmp(buf, "auth_algs") == 0) {
+ } else if (os_strcmp(buf, "auth_algs") == 0) {
bss->auth_algs = atoi(pos);
if (bss->auth_algs == 0) {
printf("Line %d: no authentication algorithms "
@@ -1579,7 +1581,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
line);
errors++;
}
- } else if (strcmp(buf, "max_num_sta") == 0) {
+ } else if (os_strcmp(buf, "max_num_sta") == 0) {
bss->max_num_sta = atoi(pos);
if (bss->max_num_sta < 0 ||
bss->max_num_sta > MAX_STA_COUNT) {
@@ -1588,26 +1590,26 @@ struct hostapd_config * hostapd_config_read(const char *fname)
bss->max_num_sta, MAX_STA_COUNT);
errors++;
}
- } else if (strcmp(buf, "wpa") == 0) {
+ } else if (os_strcmp(buf, "wpa") == 0) {
bss->wpa = atoi(pos);
- } else if (strcmp(buf, "wpa_group_rekey") == 0) {
+ } else if (os_strcmp(buf, "wpa_group_rekey") == 0) {
bss->wpa_group_rekey = atoi(pos);
- } else if (strcmp(buf, "wpa_strict_rekey") == 0) {
+ } else if (os_strcmp(buf, "wpa_strict_rekey") == 0) {
bss->wpa_strict_rekey = atoi(pos);
- } else if (strcmp(buf, "wpa_gmk_rekey") == 0) {
+ } else if (os_strcmp(buf, "wpa_gmk_rekey") == 0) {
bss->wpa_gmk_rekey = atoi(pos);
- } else if (strcmp(buf, "wpa_passphrase") == 0) {
- int len = strlen(pos);
+ } else if (os_strcmp(buf, "wpa_passphrase") == 0) {
+ int len = os_strlen(pos);
if (len < 8 || len > 63) {
printf("Line %d: invalid WPA passphrase length"
" %d (expected 8..63)\n", line, len);
errors++;
} else {
- free(bss->ssid.wpa_passphrase);
- bss->ssid.wpa_passphrase = strdup(pos);
+ os_free(bss->ssid.wpa_passphrase);
+ bss->ssid.wpa_passphrase = os_strdup(pos);
}
- } else if (strcmp(buf, "wpa_psk") == 0) {
- free(bss->ssid.wpa_psk);
+ } else if (os_strcmp(buf, "wpa_psk") == 0) {
+ os_free(bss->ssid.wpa_psk);
bss->ssid.wpa_psk =
os_zalloc(sizeof(struct hostapd_wpa_psk));
if (bss->ssid.wpa_psk == NULL)
@@ -1621,19 +1623,19 @@ struct hostapd_config * hostapd_config_read(const char *fname)
} else {
bss->ssid.wpa_psk->group = 1;
}
- } else if (strcmp(buf, "wpa_psk_file") == 0) {
- free(bss->ssid.wpa_psk_file);
- bss->ssid.wpa_psk_file = strdup(pos);
+ } else if (os_strcmp(buf, "wpa_psk_file") == 0) {
+ os_free(bss->ssid.wpa_psk_file);
+ bss->ssid.wpa_psk_file = os_strdup(pos);
if (!bss->ssid.wpa_psk_file) {
printf("Line %d: allocation failed\n", line);
errors++;
}
- } else if (strcmp(buf, "wpa_key_mgmt") == 0) {
+ } else if (os_strcmp(buf, "wpa_key_mgmt") == 0) {
bss->wpa_key_mgmt =
hostapd_config_parse_key_mgmt(line, pos);
if (bss->wpa_key_mgmt == -1)
errors++;
- } else if (strcmp(buf, "wpa_pairwise") == 0) {
+ } else if (os_strcmp(buf, "wpa_pairwise") == 0) {
bss->wpa_pairwise =
hostapd_config_parse_cipher(line, pos);
if (bss->wpa_pairwise == -1 ||
@@ -1647,7 +1649,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
bss->wpa_pairwise, pos);
errors++;
}
- } else if (strcmp(buf, "rsn_pairwise") == 0) {
+ } else if (os_strcmp(buf, "rsn_pairwise") == 0) {
bss->rsn_pairwise =
hostapd_config_parse_cipher(line, pos);
if (bss->rsn_pairwise == -1 ||
@@ -1662,18 +1664,18 @@ struct hostapd_config * hostapd_config_read(const char *fname)
errors++;
}
#ifdef CONFIG_RSN_PREAUTH
- } else if (strcmp(buf, "rsn_preauth") == 0) {
+ } else if (os_strcmp(buf, "rsn_preauth") == 0) {
bss->rsn_preauth = atoi(pos);
- } else if (strcmp(buf, "rsn_preauth_interfaces") == 0) {
- bss->rsn_preauth_interfaces = strdup(pos);
+ } else if (os_strcmp(buf, "rsn_preauth_interfaces") == 0) {
+ bss->rsn_preauth_interfaces = os_strdup(pos);
#endif /* CONFIG_RSN_PREAUTH */
#ifdef CONFIG_PEERKEY
- } else if (strcmp(buf, "peerkey") == 0) {
+ } else if (os_strcmp(buf, "peerkey") == 0) {
bss->peerkey = atoi(pos);
#endif /* CONFIG_PEERKEY */
#ifdef CONFIG_IEEE80211R
- } else if (strcmp(buf, "mobility_domain") == 0) {
- if (strlen(pos) != 2 * MOBILITY_DOMAIN_ID_LEN ||
+ } else if (os_strcmp(buf, "mobility_domain") == 0) {
+ if (os_strlen(pos) != 2 * MOBILITY_DOMAIN_ID_LEN ||
hexstr2bin(pos, bss->mobility_domain,
MOBILITY_DOMAIN_ID_LEN) != 0) {
wpa_printf(MSG_DEBUG, "Line %d: Invalid "
@@ -1681,8 +1683,8 @@ struct hostapd_config * hostapd_config_read(const char *fname)
errors++;
continue;
}
- } else if (strcmp(buf, "r1_key_holder") == 0) {
- if (strlen(pos) != 2 * FT_R1KH_ID_LEN ||
+ } else if (os_strcmp(buf, "r1_key_holder") == 0) {
+ if (os_strlen(pos) != 2 * FT_R1KH_ID_LEN ||
hexstr2bin(pos, bss->r1_key_holder,
FT_R1KH_ID_LEN) != 0) {
wpa_printf(MSG_DEBUG, "Line %d: Invalid "
@@ -1690,31 +1692,31 @@ struct hostapd_config * hostapd_config_read(const char *fname)
errors++;
continue;
}
- } else if (strcmp(buf, "r0_key_lifetime") == 0) {
+ } else if (os_strcmp(buf, "r0_key_lifetime") == 0) {
bss->r0_key_lifetime = atoi(pos);
- } else if (strcmp(buf, "reassociation_deadline") == 0) {
+ } else if (os_strcmp(buf, "reassociation_deadline") == 0) {
bss->reassociation_deadline = atoi(pos);
- } else if (strcmp(buf, "r0kh") == 0) {
+ } else if (os_strcmp(buf, "r0kh") == 0) {
if (add_r0kh(bss, pos) < 0) {
wpa_printf(MSG_DEBUG, "Line %d: Invalid "
"r0kh '%s'", line, pos);
errors++;
continue;
}
- } else if (strcmp(buf, "r1kh") == 0) {
+ } else if (os_strcmp(buf, "r1kh") == 0) {
if (add_r1kh(bss, pos) < 0) {
wpa_printf(MSG_DEBUG, "Line %d: Invalid "
"r1kh '%s'", line, pos);
errors++;
continue;
}
- } else if (strcmp(buf, "pmk_r1_push") == 0) {
+ } else if (os_strcmp(buf, "pmk_r1_push") == 0) {
bss->pmk_r1_push = atoi(pos);
#endif /* CONFIG_IEEE80211R */
- } else if (strcmp(buf, "ctrl_interface") == 0) {
- free(bss->ctrl_interface);
- bss->ctrl_interface = strdup(pos);
- } else if (strcmp(buf, "ctrl_interface_group") == 0) {
+ } else if (os_strcmp(buf, "ctrl_interface") == 0) {
+ os_free(bss->ctrl_interface);
+ bss->ctrl_interface = os_strdup(pos);
+ } else if (os_strcmp(buf, "ctrl_interface_group") == 0) {
#ifndef CONFIG_NATIVE_WINDOWS
struct group *grp;
char *endp;
@@ -1743,34 +1745,34 @@ struct hostapd_config * hostapd_config_read(const char *fname)
bss->ctrl_interface_gid);
#endif /* CONFIG_NATIVE_WINDOWS */
#ifdef RADIUS_SERVER
- } else if (strcmp(buf, "radius_server_clients") == 0) {
- free(bss->radius_server_clients);
- bss->radius_server_clients = strdup(pos);
- } else if (strcmp(buf, "radius_server_auth_port") == 0) {
+ } else if (os_strcmp(buf, "radius_server_clients") == 0) {
+ os_free(bss->radius_server_clients);
+ bss->radius_server_clients = os_strdup(pos);
+ } else if (os_strcmp(buf, "radius_server_auth_port") == 0) {
bss->radius_server_auth_port = atoi(pos);
- } else if (strcmp(buf, "radius_server_ipv6") == 0) {
+ } else if (os_strcmp(buf, "radius_server_ipv6") == 0) {
bss->radius_server_ipv6 = atoi(pos);
#endif /* RADIUS_SERVER */
- } else if (strcmp(buf, "test_socket") == 0) {
- free(bss->test_socket);
- bss->test_socket = strdup(pos);
- } else if (strcmp(buf, "use_pae_group_addr") == 0) {
+ } else if (os_strcmp(buf, "test_socket") == 0) {
+ os_free(bss->test_socket);
+ bss->test_socket = os_strdup(pos);
+ } else if (os_strcmp(buf, "use_pae_group_addr") == 0) {
bss->use_pae_group_addr = atoi(pos);
- } else if (strcmp(buf, "hw_mode") == 0) {
- if (strcmp(pos, "a") == 0)
+ } else if (os_strcmp(buf, "hw_mode") == 0) {
+ if (os_strcmp(pos, "a") == 0)
conf->hw_mode = HOSTAPD_MODE_IEEE80211A;
- else if (strcmp(pos, "b") == 0)
+ else if (os_strcmp(pos, "b") == 0)
conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
- else if (strcmp(pos, "g") == 0)
+ else if (os_strcmp(pos, "g") == 0)
conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
else {
printf("Line %d: unknown hw_mode '%s'\n",
line, pos);
errors++;
}
- } else if (strcmp(buf, "channel") == 0) {
+ } else if (os_strcmp(buf, "channel") == 0) {
conf->channel = atoi(pos);
- } else if (strcmp(buf, "beacon_int") == 0) {
+ } else if (os_strcmp(buf, "beacon_int") == 0) {
int val = atoi(pos);
/* MIB defines range as 1..65535, but very small values
* cause problems with the current implementation.
@@ -1784,14 +1786,14 @@ struct hostapd_config * hostapd_config_read(const char *fname)
errors++;
} else
conf->beacon_int = val;
- } else if (strcmp(buf, "dtim_period") == 0) {
+ } else if (os_strcmp(buf, "dtim_period") == 0) {
bss->dtim_period = atoi(pos);
if (bss->dtim_period < 1 || bss->dtim_period > 255) {
printf("Line %d: invalid dtim_period %d\n",
line, bss->dtim_period);
errors++;
}
- } else if (strcmp(buf, "rts_threshold") == 0) {
+ } else if (os_strcmp(buf, "rts_threshold") == 0) {
conf->rts_threshold = atoi(pos);
if (conf->rts_threshold < 0 ||
conf->rts_threshold > 2347) {
@@ -1799,7 +1801,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
line, conf->rts_threshold);
errors++;
}
- } else if (strcmp(buf, "fragm_threshold") == 0) {
+ } else if (os_strcmp(buf, "fragm_threshold") == 0) {
conf->fragm_threshold = atoi(pos);
if (conf->fragm_threshold < 256 ||
conf->fragm_threshold > 2346) {
@@ -1807,86 +1809,86 @@ struct hostapd_config * hostapd_config_read(const char *fname)
line, conf->fragm_threshold);
errors++;
}
- } else if (strcmp(buf, "send_probe_response") == 0) {
+ } else if (os_strcmp(buf, "send_probe_response") == 0) {
int val = atoi(pos);
if (val != 0 && val != 1) {
printf("Line %d: invalid send_probe_response "
"%d (expected 0 or 1)\n", line, val);
} else
conf->send_probe_response = val;
- } else if (strcmp(buf, "supported_rates") == 0) {
+ } else if (os_strcmp(buf, "supported_rates") == 0) {
if (hostapd_parse_rates(&conf->supported_rates, pos)) {
printf("Line %d: invalid rate list\n", line);
errors++;
}
- } else if (strcmp(buf, "basic_rates") == 0) {
+ } else if (os_strcmp(buf, "basic_rates") == 0) {
if (hostapd_parse_rates(&conf->basic_rates, pos)) {
printf("Line %d: invalid rate list\n", line);
errors++;
}
- } else if (strcmp(buf, "ignore_broadcast_ssid") == 0) {
+ } else if (os_strcmp(buf, "ignore_broadcast_ssid") == 0) {
bss->ignore_broadcast_ssid = atoi(pos);
- } else if (strcmp(buf, "bridge_packets") == 0) {
+ } else if (os_strcmp(buf, "bridge_packets") == 0) {
conf->bridge_packets = atoi(pos);
- } else if (strcmp(buf, "wep_default_key") == 0) {
+ } else if (os_strcmp(buf, "wep_default_key") == 0) {
bss->ssid.wep.idx = atoi(pos);
if (bss->ssid.wep.idx > 3) {
printf("Invalid wep_default_key index %d\n",
bss->ssid.wep.idx);
errors++;
}
- } else if (strcmp(buf, "wep_key0") == 0 ||
- strcmp(buf, "wep_key1") == 0 ||
- strcmp(buf, "wep_key2") == 0 ||
- strcmp(buf, "wep_key3") == 0) {
+ } else if (os_strcmp(buf, "wep_key0") == 0 ||
+ os_strcmp(buf, "wep_key1") == 0 ||
+ os_strcmp(buf, "wep_key2") == 0 ||
+ os_strcmp(buf, "wep_key3") == 0) {
if (hostapd_config_read_wep(&bss->ssid.wep,
buf[7] - '0', pos)) {
printf("Line %d: invalid WEP key '%s'\n",
line, buf);
errors++;
}
- } else if (strcmp(buf, "dynamic_vlan") == 0) {
+ } else if (os_strcmp(buf, "dynamic_vlan") == 0) {
bss->ssid.dynamic_vlan = atoi(pos);
- } else if (strcmp(buf, "vlan_file") == 0) {
+ } else if (os_strcmp(buf, "vlan_file") == 0) {
if (hostapd_config_read_vlan_file(bss, pos)) {
printf("Line %d: failed to read VLAN file "
"'%s'\n", line, pos);
errors++;
}
#ifdef CONFIG_FULL_DYNAMIC_VLAN
- } else if (strcmp(buf, "vlan_tagged_interface") == 0) {
- bss->ssid.vlan_tagged_interface = strdup(pos);
+ } else if (os_strcmp(buf, "vlan_tagged_interface") == 0) {
+ bss->ssid.vlan_tagged_interface = os_strdup(pos);
#endif /* CONFIG_FULL_DYNAMIC_VLAN */
- } else if (strcmp(buf, "passive_scan_interval") == 0) {
+ } else if (os_strcmp(buf, "passive_scan_interval") == 0) {
conf->passive_scan_interval = atoi(pos);
- } else if (strcmp(buf, "passive_scan_listen") == 0) {
+ } else if (os_strcmp(buf, "passive_scan_listen") == 0) {
conf->passive_scan_listen = atoi(pos);
- } else if (strcmp(buf, "passive_scan_mode") == 0) {
+ } else if (os_strcmp(buf, "passive_scan_mode") == 0) {
conf->passive_scan_mode = atoi(pos);
- } else if (strcmp(buf, "ap_table_max_size") == 0) {
+ } else if (os_strcmp(buf, "ap_table_max_size") == 0) {
conf->ap_table_max_size = atoi(pos);
- } else if (strcmp(buf, "ap_table_expiration_time") == 0) {
+ } else if (os_strcmp(buf, "ap_table_expiration_time") == 0) {
conf->ap_table_expiration_time = atoi(pos);
- } else if (strncmp(buf, "tx_queue_", 9) == 0) {
+ } else if (os_strncmp(buf, "tx_queue_", 9) == 0) {
if (hostapd_config_tx_queue(conf, buf, pos)) {
printf("Line %d: invalid TX queue item\n",
line);
errors++;
}
- } else if (strcmp(buf, "wme_enabled") == 0) {
+ } else if (os_strcmp(buf, "wme_enabled") == 0) {
bss->wme_enabled = atoi(pos);
- } else if (strncmp(buf, "wme_ac_", 7) == 0) {
+ } else if (os_strncmp(buf, "wme_ac_", 7) == 0) {
if (hostapd_config_wme_ac(conf, buf, pos)) {
printf("Line %d: invalid wme ac item\n",
line);
errors++;
}
- } else if (strcmp(buf, "bss") == 0) {
+ } else if (os_strcmp(buf, "bss") == 0) {
if (hostapd_config_bss(conf, pos)) {
printf("Line %d: invalid bss item\n", line);
errors++;
}
- } else if (strcmp(buf, "bssid") == 0) {
+ } else if (os_strcmp(buf, "bssid") == 0) {
if (bss == conf->bss) {
printf("Line %d: bssid item not allowed "
"for the default interface\n", line);
@@ -1896,7 +1898,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
errors++;
}
#ifdef CONFIG_IEEE80211W
- } else if (strcmp(buf, "ieee80211w") == 0) {
+ } else if (os_strcmp(buf, "ieee80211w") == 0) {
bss->ieee80211w = atoi(pos);
#endif /* CONFIG_IEEE80211W */
} else {
@@ -1969,7 +1971,7 @@ int hostapd_wep_key_cmp(struct hostapd_wep_keys *a, struct hostapd_wep_keys *b)
return 1;
for (i = 0; i < NUM_WEP_KEYS; i++)
if (a->len[i] != b->len[i] ||
- memcmp(a->key[i], b->key[i], a->len[i]) != 0)
+ os_memcmp(a->key[i], b->key[i], a->len[i]) != 0)
return 1;
return 0;
}
@@ -1981,17 +1983,17 @@ static void hostapd_config_free_radius(struct hostapd_radius_server *servers,
int i;
for (i = 0; i < num_servers; i++) {
- free(servers[i].shared_secret);
+ os_free(servers[i].shared_secret);
}
- free(servers);
+ os_free(servers);
}
static void hostapd_config_free_eap_user(struct hostapd_eap_user *user)
{
- free(user->identity);
- free(user->password);
- free(user);
+ os_free(user->identity);
+ os_free(user->password);
+ os_free(user);
}
@@ -1999,7 +2001,7 @@ static void hostapd_config_free_wep(struct hostapd_wep_keys *keys)
{
int i;
for (i = 0; i < NUM_WEP_KEYS; i++) {
- free(keys->key[i]);
+ os_free(keys->key[i]);
keys->key[i] = NULL;
}
}
@@ -2017,13 +2019,13 @@ static void hostapd_config_free_bss(struct hostapd_bss_config *conf)
while (psk) {
prev = psk;
psk = psk->next;
- free(prev);
+ os_free(prev);
}
- free(conf->ssid.wpa_passphrase);
- free(conf->ssid.wpa_psk_file);
+ os_free(conf->ssid.wpa_passphrase);
+ os_free(conf->ssid.wpa_psk_file);
#ifdef CONFIG_FULL_DYNAMIC_VLAN
- free(conf->ssid.vlan_tagged_interface);
+ os_free(conf->ssid.vlan_tagged_interface);
#endif /* CONFIG_FULL_DYNAMIC_VLAN */
user = conf->eap_user;
@@ -2033,28 +2035,28 @@ static void hostapd_config_free_bss(struct hostapd_bss_config *conf)
hostapd_config_free_eap_user(prev_user);
}
- free(conf->dump_log_name);
- free(conf->eap_req_id_text);
- free(conf->accept_mac);
- free(conf->deny_mac);
- free(conf->nas_identifier);
+ os_free(conf->dump_log_name);
+ os_free(conf->eap_req_id_text);
+ os_free(conf->accept_mac);
+ os_free(conf->deny_mac);
+ os_free(conf->nas_identifier);
hostapd_config_free_radius(conf->radius->auth_servers,
conf->radius->num_auth_servers);
hostapd_config_free_radius(conf->radius->acct_servers,
conf->radius->num_acct_servers);
- free(conf->rsn_preauth_interfaces);
- free(conf->ctrl_interface);
- free(conf->ca_cert);
- free(conf->server_cert);
- free(conf->private_key);
- free(conf->private_key_passwd);
- free(conf->dh_file);
- free(conf->pac_opaque_encr_key);
- free(conf->eap_fast_a_id);
- free(conf->eap_sim_db);
- free(conf->radius_server_clients);
- free(conf->test_socket);
- free(conf->radius);
+ os_free(conf->rsn_preauth_interfaces);
+ os_free(conf->ctrl_interface);
+ os_free(conf->ca_cert);
+ os_free(conf->server_cert);
+ os_free(conf->private_key);
+ os_free(conf->private_key_passwd);
+ os_free(conf->dh_file);
+ os_free(conf->pac_opaque_encr_key);
+ os_free(conf->eap_fast_a_id);
+ os_free(conf->eap_sim_db);
+ os_free(conf->radius_server_clients);
+ os_free(conf->test_socket);
+ os_free(conf->radius);
hostapd_config_free_vlan(conf);
if (conf->ssid.dyn_vlan_keys) {
struct hostapd_ssid *ssid = &conf->ssid;
@@ -2063,9 +2065,9 @@ static void hostapd_config_free_bss(struct hostapd_bss_config *conf)
if (ssid->dyn_vlan_keys[i] == NULL)
continue;
hostapd_config_free_wep(ssid->dyn_vlan_keys[i]);
- free(ssid->dyn_vlan_keys[i]);
+ os_free(ssid->dyn_vlan_keys[i]);
}
- free(ssid->dyn_vlan_keys);
+ os_free(ssid->dyn_vlan_keys);
ssid->dyn_vlan_keys = NULL;
}
@@ -2103,9 +2105,9 @@ void hostapd_config_free(struct hostapd_config *conf)
for (i = 0; i < conf->num_bss; i++)
hostapd_config_free_bss(&conf->bss[i]);
- free(conf->bss);
+ os_free(conf->bss);
- free(conf);
+ os_free(conf);
}
@@ -2120,7 +2122,7 @@ int hostapd_maclist_found(macaddr *list, int num_entries, const u8 *addr)
while (start <= end) {
middle = (start + end) / 2;
- res = memcmp(list[middle], addr, ETH_ALEN);
+ res = os_memcmp(list[middle], addr, ETH_ALEN);
if (res == 0)
return 1;
if (res < 0)
@@ -2168,7 +2170,7 @@ const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) {
if (next_ok &&
- (psk->group || memcmp(psk->addr, addr, ETH_ALEN) == 0))
+ (psk->group || os_memcmp(psk->addr, addr, ETH_ALEN) == 0))
return psk->psk;
if (psk->psk == prev_psk)
@@ -2193,15 +2195,15 @@ hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
if (!phase2 && user->wildcard_prefix &&
identity_len >= user->identity_len &&
- memcmp(user->identity, identity, user->identity_len) == 0)
- {
+ os_memcmp(user->identity, identity, user->identity_len) ==
+ 0) {
/* Wildcard prefix match */
break;
}
if (user->phase2 == !!phase2 &&
user->identity_len == identity_len &&
- memcmp(user->identity, identity, identity_len) == 0)
+ os_memcmp(user->identity, identity, identity_len) == 0)
break;
user = user->next;
}
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 0df9ef0..e2df04f 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -49,7 +49,7 @@ static int hostapd_ctrl_iface_attach(struct hostapd_data *hapd,
dst = os_zalloc(sizeof(*dst));
if (dst == NULL)
return -1;
- memcpy(&dst->addr, from, sizeof(struct sockaddr_un));
+ os_memcpy(&dst->addr, from, sizeof(struct sockaddr_un));
dst->addrlen = fromlen;
dst->debug_level = MSG_INFO;
dst->next = hapd->ctrl_dst;
@@ -69,12 +69,13 @@ static int hostapd_ctrl_iface_detach(struct hostapd_data *hapd,
dst = hapd->ctrl_dst;
while (dst) {
if (fromlen == dst->addrlen &&
- memcmp(from->sun_path, dst->addr.sun_path, fromlen) == 0) {
+ os_memcmp(from->sun_path, dst->addr.sun_path, fromlen) ==
+ 0) {
if (prev == NULL)
hapd->ctrl_dst = dst->next;
else
prev->next = dst->next;
- free(dst);
+ os_free(dst);
wpa_hexdump(MSG_DEBUG, "CTRL_IFACE monitor detached",
(u8 *) from->sun_path, fromlen);
return 0;
@@ -98,7 +99,8 @@ static int hostapd_ctrl_iface_level(struct hostapd_data *hapd,
dst = hapd->ctrl_dst;
while (dst) {
if (fromlen == dst->addrlen &&
- memcmp(from->sun_path, dst->addr.sun_path, fromlen) == 0) {
+ os_memcmp(from->sun_path, dst->addr.sun_path, fromlen) ==
+ 0) {
wpa_hexdump(MSG_DEBUG, "CTRL_IFACE changed monitor "
"level", (u8 *) from->sun_path, fromlen);
dst->debug_level = atoi(level);
@@ -118,15 +120,15 @@ static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
int len, res, ret;
if (sta == NULL) {
- ret = snprintf(buf, buflen, "FAIL\n");
+ ret = os_snprintf(buf, buflen, "FAIL\n");
if (ret < 0 || (size_t) ret >= buflen)
return 0;
return ret;
}
len = 0;
- ret = snprintf(buf + len, buflen - len, MACSTR "\n",
- MAC2STR(sta->addr));
+ ret = os_snprintf(buf + len, buflen - len, MACSTR "\n",
+ MAC2STR(sta->addr));
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
@@ -160,7 +162,7 @@ static int hostapd_ctrl_iface_sta(struct hostapd_data *hapd,
int ret;
if (hwaddr_aton(txtaddr, addr)) {
- ret = snprintf(buf, buflen, "FAIL\n");
+ ret = os_snprintf(buf, buflen, "FAIL\n");
if (ret < 0 || (size_t) ret >= buflen)
return 0;
return ret;
@@ -180,7 +182,7 @@ static int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd,
if (hwaddr_aton(txtaddr, addr) ||
(sta = ap_get_sta(hapd, addr)) == NULL) {
- ret = snprintf(buf, buflen, "FAIL\n");
+ ret = os_snprintf(buf, buflen, "FAIL\n");
if (ret < 0 || (size_t) ret >= buflen)
return 0;
return ret;
@@ -237,20 +239,20 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
buf[res] = '\0';
wpa_hexdump_ascii(MSG_DEBUG, "RX ctrl_iface", (u8 *) buf, res);
- reply = malloc(reply_size);
+ reply = os_malloc(reply_size);
if (reply == NULL) {
sendto(sock, "FAIL\n", 5, 0, (struct sockaddr *) &from,
fromlen);
return;
}
- memcpy(reply, "OK\n", 3);
+ os_memcpy(reply, "OK\n", 3);
reply_len = 3;
- if (strcmp(buf, "PING") == 0) {
- memcpy(reply, "PONG\n", 5);
+ if (os_strcmp(buf, "PING") == 0) {
+ os_memcpy(reply, "PONG\n", 5);
reply_len = 5;
- } else if (strcmp(buf, "MIB") == 0) {
+ } else if (os_strcmp(buf, "MIB") == 0) {
reply_len = ieee802_11_get_mib(hapd, reply, reply_size);
if (reply_len >= 0) {
res = wpa_get_mib(hapd->wpa_auth, reply + reply_len,
@@ -277,39 +279,39 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
else
reply_len += res;
}
- } else if (strcmp(buf, "STA-FIRST") == 0) {
+ } else if (os_strcmp(buf, "STA-FIRST") == 0) {
reply_len = hostapd_ctrl_iface_sta_first(hapd, reply,
reply_size);
- } else if (strncmp(buf, "STA ", 4) == 0) {
+ } else if (os_strncmp(buf, "STA ", 4) == 0) {
reply_len = hostapd_ctrl_iface_sta(hapd, buf + 4, reply,
reply_size);
- } else if (strncmp(buf, "STA-NEXT ", 9) == 0) {
+ } else if (os_strncmp(buf, "STA-NEXT ", 9) == 0) {
reply_len = hostapd_ctrl_iface_sta_next(hapd, buf + 9, reply,
reply_size);
- } else if (strcmp(buf, "ATTACH") == 0) {
+ } else if (os_strcmp(buf, "ATTACH") == 0) {
if (hostapd_ctrl_iface_attach(hapd, &from, fromlen))
reply_len = -1;
- } else if (strcmp(buf, "DETACH") == 0) {
+ } else if (os_strcmp(buf, "DETACH") == 0) {
if (hostapd_ctrl_iface_detach(hapd, &from, fromlen))
reply_len = -1;
- } else if (strncmp(buf, "LEVEL ", 6) == 0) {
+ } else if (os_strncmp(buf, "LEVEL ", 6) == 0) {
if (hostapd_ctrl_iface_level(hapd, &from, fromlen,
buf + 6))
reply_len = -1;
- } else if (strncmp(buf, "NEW_STA ", 8) == 0) {
+ } else if (os_strncmp(buf, "NEW_STA ", 8) == 0) {
if (hostapd_ctrl_iface_new_sta(hapd, buf + 8))
reply_len = -1;
} else {
- memcpy(reply, "UNKNOWN COMMAND\n", 16);
+ os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
reply_len = 16;
}
if (reply_len < 0) {
- memcpy(reply, "FAIL\n", 5);
+ os_memcpy(reply, "FAIL\n", 5);
reply_len = 5;
}
sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from, fromlen);
- free(reply);
+ os_free(reply);
}
@@ -321,14 +323,14 @@ static char * hostapd_ctrl_iface_path(struct hostapd_data *hapd)
if (hapd->conf->ctrl_interface == NULL)
return NULL;
- len = strlen(hapd->conf->ctrl_interface) + strlen(hapd->conf->iface) +
- 2;
- buf = malloc(len);
+ len = os_strlen(hapd->conf->ctrl_interface) +
+ os_strlen(hapd->conf->iface) + 2;
+ buf = os_malloc(len);
if (buf == NULL)
return NULL;
- snprintf(buf, len, "%s/%s",
- hapd->conf->ctrl_interface, hapd->conf->iface);
+ os_snprintf(buf, len, "%s/%s",
+ hapd->conf->ctrl_interface, hapd->conf->iface);
buf[len - 1] = '\0';
return buf;
}
@@ -362,8 +364,8 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
return -1;
}
- if (strlen(hapd->conf->ctrl_interface) + 1 + strlen(hapd->conf->iface)
- >= sizeof(addr.sun_path))
+ if (os_strlen(hapd->conf->ctrl_interface) + 1 +
+ os_strlen(hapd->conf->iface) >= sizeof(addr.sun_path))
goto fail;
s = socket(PF_UNIX, SOCK_DGRAM, 0);
@@ -372,7 +374,7 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
goto fail;
}
- memset(&addr, 0, sizeof(addr));
+ os_memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
fname = hostapd_ctrl_iface_path(hapd);
if (fname == NULL)
@@ -393,7 +395,7 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
perror("chmod[ctrl_interface/ifname]");
goto fail;
}
- free(fname);
+ os_free(fname);
hapd->ctrl_sock = s;
eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd,
@@ -406,7 +408,7 @@ fail:
close(s);
if (fname) {
unlink(fname);
- free(fname);
+ os_free(fname);
}
return -1;
}
@@ -424,7 +426,7 @@ void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
fname = hostapd_ctrl_iface_path(hapd);
if (fname)
unlink(fname);
- free(fname);
+ os_free(fname);
if (hapd->conf->ctrl_interface &&
rmdir(hapd->conf->ctrl_interface) < 0) {
@@ -442,7 +444,7 @@ void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd)
while (dst) {
prev = dst;
dst = dst->next;
- free(prev);
+ os_free(prev);
}
}
@@ -460,12 +462,12 @@ void hostapd_ctrl_iface_send(struct hostapd_data *hapd, int level,
if (hapd->ctrl_sock < 0 || dst == NULL)
return;
- snprintf(levelstr, sizeof(levelstr), "<%d>", level);
+ os_snprintf(levelstr, sizeof(levelstr), "<%d>", level);
io[0].iov_base = levelstr;
- io[0].iov_len = strlen(levelstr);
+ io[0].iov_len = os_strlen(levelstr);
io[1].iov_base = buf;
io[1].iov_len = len;
- memset(&msg, 0, sizeof(msg));
+ os_memset(&msg, 0, sizeof(msg));
msg.msg_iov = io;
msg.msg_iovlen = 2;
diff --git a/hostapd/eapol_sm.c b/hostapd/eapol_sm.c
index 0b1a9f7..a49f1b2 100644
--- a/hostapd/eapol_sm.c
+++ b/hostapd/eapol_sm.c
@@ -71,8 +71,8 @@ static void eapol_auth_vlogger(struct eapol_authenticator *eapol,
if (eapol->cb.logger == NULL)
return;
- maxlen = strlen(fmt) + 100;
- format = malloc(maxlen);
+ maxlen = os_strlen(fmt) + 100;
+ format = os_malloc(maxlen);
if (!format)
return;
@@ -82,7 +82,7 @@ static void eapol_auth_vlogger(struct eapol_authenticator *eapol,
eapol_auth_logger(eapol, addr, level, format);
- free(format);
+ os_free(format);
}
@@ -759,7 +759,7 @@ eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
return NULL;
}
sm->radius_identifier = -1;
- memcpy(sm->addr, addr, ETH_ALEN);
+ os_memcpy(sm->addr, addr, ETH_ALEN);
if (preauth)
sm->flags |= EAPOL_SM_PREAUTH;
@@ -797,7 +797,7 @@ eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
else
sm->portValid = TRUE;
- memset(&eap_conf, 0, sizeof(eap_conf));
+ os_memset(&eap_conf, 0, sizeof(eap_conf));
eap_conf.eap_server = eapol->conf.eap_server;
eap_conf.ssl_ctx = eapol->conf.ssl_ctx;
eap_conf.eap_sim_db_priv = eapol->conf.eap_sim_db_priv;
@@ -825,7 +825,7 @@ void eapol_auth_free(struct eapol_state_machine *sm)
eloop_cancel_timeout(eapol_sm_step_cb, sm, NULL);
if (sm->eap)
eap_server_sm_deinit(sm->eap);
- free(sm);
+ os_free(sm);
}
@@ -844,7 +844,7 @@ static void eapol_sm_step_run(struct eapol_state_machine *sm)
prev_auth_key_tx, prev_key_rx, prev_ctrl_dir;
int max_steps = 100;
- memcpy(addr, sm->addr, ETH_ALEN);
+ os_memcpy(addr, sm->addr, ETH_ALEN);
/*
* Allow EAPOL state machines to run as long as there are state
diff --git a/hostapd/hostapd.c b/hostapd/hostapd.c
index 42fe072..07329ce 100644
--- a/hostapd/hostapd.c
+++ b/hostapd/hostapd.c
@@ -68,7 +68,7 @@ static void hostapd_logger_cb(void *ctx, const u8 *addr, unsigned int module,
unsigned int conf_syslog, conf_stdout;
maxlen = len + 100;
- format = malloc(maxlen);
+ format = os_malloc(maxlen);
if (!format)
return;
@@ -110,20 +110,20 @@ static void hostapd_logger_cb(void *ctx, const u8 *addr, unsigned int module,
}
if (hapd && hapd->conf && addr)
- snprintf(format, maxlen, "%s: STA " MACSTR "%s%s: %s",
- hapd->conf->iface, MAC2STR(addr),
- module_str ? " " : "", module_str, txt);
+ os_snprintf(format, maxlen, "%s: STA " MACSTR "%s%s: %s",
+ hapd->conf->iface, MAC2STR(addr),
+ module_str ? " " : "", module_str, txt);
else if (hapd && hapd->conf)
- snprintf(format, maxlen, "%s:%s%s %s",
- hapd->conf->iface, module_str ? " " : "",
- module_str, txt);
+ os_snprintf(format, maxlen, "%s:%s%s %s",
+ hapd->conf->iface, module_str ? " " : "",
+ module_str, txt);
else if (addr)
- snprintf(format, maxlen, "STA " MACSTR "%s%s: %s",
- MAC2STR(addr), module_str ? " " : "",
- module_str, txt);
+ os_snprintf(format, maxlen, "STA " MACSTR "%s%s: %s",
+ MAC2STR(addr), module_str ? " " : "",
+ module_str, txt);
else
- snprintf(format, maxlen, "%s%s%s",
- module_str, module_str ? ": " : "", txt);
+ os_snprintf(format, maxlen, "%s%s%s",
+ module_str, module_str ? ": " : "", txt);
if ((conf_stdout & module) && level >= conf_stdout_level) {
wpa_debug_print_timestamp();
@@ -155,7 +155,7 @@ static void hostapd_logger_cb(void *ctx, const u8 *addr, unsigned int module,
}
#endif /* CONFIG_NATIVE_WINDOWS */
- free(format);
+ os_free(format);
}
@@ -164,7 +164,7 @@ static void hostapd_deauth_all_stas(struct hostapd_data *hapd)
#if 0
u8 addr[ETH_ALEN];
- memset(addr, 0xff, ETH_ALEN);
+ os_memset(addr, 0xff, ETH_ALEN);
hostapd_sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
#else
/* New Prism2.5/3 STA firmware versions seem to have issues with this
@@ -299,16 +299,16 @@ static void hostapd_wpa_auth_conf(struct hostapd_bss_config *conf,
wconf->ssid_len = conf->ssid.ssid_len;
if (wconf->ssid_len > SSID_LEN)
wconf->ssid_len = SSID_LEN;
- memcpy(wconf->ssid, conf->ssid.ssid, wconf->ssid_len);
- memcpy(wconf->mobility_domain, conf->mobility_domain,
- MOBILITY_DOMAIN_ID_LEN);
+ os_memcpy(wconf->ssid, conf->ssid.ssid, wconf->ssid_len);
+ os_memcpy(wconf->mobility_domain, conf->mobility_domain,
+ MOBILITY_DOMAIN_ID_LEN);
if (conf->nas_identifier &&
os_strlen(conf->nas_identifier) <= FT_R0KH_ID_MAX_LEN) {
wconf->r0_key_holder_len = os_strlen(conf->nas_identifier);
- memcpy(wconf->r0_key_holder, conf->nas_identifier,
- wconf->r0_key_holder_len);
+ os_memcpy(wconf->r0_key_holder, conf->nas_identifier,
+ wconf->r0_key_holder_len);
}
- memcpy(wconf->r1_key_holder, conf->r1_key_holder, FT_R1KH_ID_LEN);
+ os_memcpy(wconf->r1_key_holder, conf->r1_key_holder, FT_R1KH_ID_LEN);
wconf->r0_key_lifetime = conf->r0_key_lifetime;
wconf->reassociation_deadline = conf->reassociation_deadline;
wconf->r0kh_list = conf->r0kh_list;
@@ -426,7 +426,7 @@ static void hostapd_dump_state(struct hostapd_data *hapd)
ieee802_1x_dump_state(f, " ", sta);
}
- buf = malloc(4096);
+ buf = os_malloc(4096);
if (buf) {
int count = radius_client_get_mib(hapd->radius, buf, 4096);
if (count < 0)
@@ -443,7 +443,7 @@ static void hostapd_dump_state(struct hostapd_data *hapd)
count = 4095;
buf[count] = '\0';
fprintf(f, "%s", buf);
- free(buf);
+ os_free(buf);
}
fclose(f);
}
@@ -544,7 +544,7 @@ static void hostapd_cleanup(struct hostapd_data *hapd)
{
hostapd_ctrl_iface_deinit(hapd);
- free(hapd->default_wep_key);
+ os_free(hapd->default_wep_key);
hapd->default_wep_key = NULL;
iapp_deinit(hapd->iapp);
hapd->iapp = NULL;
@@ -625,15 +625,15 @@ static void hostapd_cleanup_iface(struct hostapd_iface *iface)
{
hostapd_free_hw_features(iface->hw_features, iface->num_hw_features);
iface->hw_features = NULL;
- free(iface->current_rates);
+ os_free(iface->current_rates);
iface->current_rates = NULL;
ap_list_deinit(iface);
hostapd_config_free(iface->conf);
iface->conf = NULL;
- free(iface->config_fname);
- free(iface->bss);
- free(iface);
+ os_free(iface->config_fname);
+ os_free(iface->bss);
+ os_free(iface);
}
@@ -817,7 +817,7 @@ static int hostapd_wpa_auth_get_msk(void *ctx, const u8 *addr, u8 *msk,
if (keylen > *len)
keylen = *len;
- memcpy(msk, key, keylen);
+ os_memcpy(msk, key, keylen);
*len = keylen;
return 0;
@@ -1014,7 +1014,7 @@ static int hostapd_validate_bssid_configuration(struct hostapd_iface *iface)
if (bits > 40)
return -1;
- memset(mask, 0xff, ETH_ALEN);
+ os_memset(mask, 0xff, ETH_ALEN);
j = bits / 8;
for (i = 5; i > 5 - j; i--)
mask[i] = 0;
@@ -1091,7 +1091,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
} while (mac_in_conf(hapd->iconf, hapd->own_addr));
} else {
/* Allocate the configured BSSID. */
- memcpy(hapd->own_addr, hapd->conf->bssid, ETH_ALEN);
+ os_memcpy(hapd->own_addr, hapd->conf->bssid, ETH_ALEN);
if (hostapd_mac_comp(hapd->own_addr,
hapd->iface->bss[0]->own_addr) ==
@@ -1129,7 +1129,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
* new SSID.
*/
set_ssid = (conf->ssid.ssid_len != (size_t) ssid_len ||
- memcmp(conf->ssid.ssid, ssid, ssid_len) != 0);
+ os_memcmp(conf->ssid.ssid, ssid, ssid_len) != 0);
} else {
/*
* No SSID in the config file; just use the one we got
@@ -1137,7 +1137,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
*/
set_ssid = 0;
conf->ssid.ssid_len = ssid_len;
- memcpy(conf->ssid.ssid, ssid, conf->ssid.ssid_len);
+ os_memcpy(conf->ssid.ssid, ssid, conf->ssid.ssid_len);
conf->ssid.ssid[conf->ssid.ssid_len] = '\0';
}
@@ -1195,7 +1195,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
size_t wpa_ie_len;
hostapd_wpa_auth_conf(hapd->conf, &_conf);
- memset(&cb, 0, sizeof(cb));
+ os_memset(&cb, 0, sizeof(cb));
cb.ctx = hapd;
cb.logger = hostapd_wpa_auth_logger;
cb.disconnect = hostapd_wpa_auth_disconnect;
@@ -1333,7 +1333,7 @@ static int setup_interface2(struct hostapd_iface *iface)
for (j = 0; j < iface->num_bss; j++) {
hapd = iface->bss[j];
if (j)
- memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
+ os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
if (hostapd_setup_bss(hapd, j == 0))
return -1;
if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
@@ -1428,7 +1428,7 @@ static int hostapd_radius_get_eap_user(void *ctx, const u8 *identity,
if (user == NULL)
return 0;
- memset(user, 0, sizeof(*user));
+ os_memset(user, 0, sizeof(*user));
count = EAP_USER_MAX_METHODS;
if (count > EAP_MAX_METHODS)
count = EAP_MAX_METHODS;
@@ -1438,11 +1438,11 @@ static int hostapd_radius_get_eap_user(void *ctx, const u8 *identity,
}
if (eap_user->password) {
- user->password = malloc(eap_user->password_len);
+ user->password = os_malloc(eap_user->password_len);
if (user->password == NULL)
return -1;
- memcpy(user->password, eap_user->password,
- eap_user->password_len);
+ os_memcpy(user->password, eap_user->password,
+ eap_user->password_len);
user->password_len = eap_user->password_len;
user->password_hash = eap_user->password_hash;
}
@@ -1486,7 +1486,7 @@ static int setup_interface1(struct hostapd_iface *iface)
if (hostapd_validate_bssid_configuration(iface))
return -1;
- memcpy(country, hapd->iconf->country, 3);
+ os_memcpy(country, hapd->iconf->country, 3);
country[3] = '\0';
if (hostapd_set_country(hapd, country) < 0) {
printf("Failed to set country code\n");
@@ -1509,7 +1509,7 @@ static int setup_interface1(struct hostapd_iface *iface)
if (conf->radius_server_clients) {
struct radius_server_conf srv;
- memset(&srv, 0, sizeof(srv));
+ os_memset(&srv, 0, sizeof(srv));
srv.client_file = conf->radius_server_clients;
srv.auth_port = conf->radius_server_auth_port;
srv.conf_ctx = conf;
@@ -1680,7 +1680,7 @@ hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
goto fail;
}
- memset(&params, 0, sizeof(params));
+ os_memset(&params, 0, sizeof(params));
params.ca_cert = hapd->conf->ca_cert;
params.client_cert = hapd->conf->server_cert;
params.private_key = hapd->conf->private_key;
@@ -1724,7 +1724,7 @@ hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
fail:
#endif
/* TODO: cleanup allocated resources(?) */
- free(hapd);
+ os_free(hapd);
return NULL;
}
@@ -1749,7 +1749,7 @@ static struct hostapd_iface * hostapd_init(const char *config_file)
if (hapd_iface == NULL)
goto fail;
- hapd_iface->config_fname = strdup(config_file);
+ hapd_iface->config_fname = os_strdup(config_file);
if (hapd_iface->config_fname == NULL)
goto fail;
@@ -1784,9 +1784,9 @@ fail:
tls_deinit(hapd->ssl_ctx);
}
- free(hapd_iface->config_fname);
- free(hapd_iface->bss);
- free(hapd_iface);
+ os_free(hapd_iface->config_fname);
+ os_free(hapd_iface->bss);
+ os_free(hapd_iface);
}
return NULL;
}
@@ -1874,11 +1874,11 @@ int main(int argc, char *argv[])
interfaces.count = argc - optind;
- interfaces.iface = malloc(interfaces.count *
- sizeof(struct hostapd_iface *));
+ interfaces.iface = os_malloc(interfaces.count *
+ sizeof(struct hostapd_iface *));
if (interfaces.iface == NULL) {
- printf("malloc failed\n");
- exit(1);
+ wpa_printf(MSG_ERROR, "malloc failed\n");
+ return -1;
}
if (eloop_init(&interfaces)) {
@@ -1951,10 +1951,10 @@ int main(int argc, char *argv[])
hostapd_driver_deinit(hapd);
}
for (j = 0; j < interfaces.iface[i]->num_bss; j++)
- free(interfaces.iface[i]->bss[j]);
+ os_free(interfaces.iface[i]->bss[j]);
hostapd_cleanup_iface(interfaces.iface[i]);
}
- free(interfaces.iface);
+ os_free(interfaces.iface);
eloop_destroy();
diff --git a/hostapd/hw_features.c b/hostapd/hw_features.c
index b3dad7c..0a4d0f4 100644
--- a/hostapd/hw_features.c
+++ b/hostapd/hw_features.c
@@ -31,11 +31,11 @@ void hostapd_free_hw_features(struct hostapd_hw_modes *hw_features,
return;
for (i = 0; i < num_hw_features; i++) {
- free(hw_features[i].channels);
- free(hw_features[i].rates);
+ os_free(hw_features[i].channels);
+ os_free(hw_features[i].rates);
}
- free(hw_features);
+ os_free(hw_features);
}
@@ -123,11 +123,11 @@ static int hostapd_prepare_rates(struct hostapd_data *hapd,
printf("Failed to update rate sets in kernel module\n");
}
- free(hapd->iface->current_rates);
+ os_free(hapd->iface->current_rates);
hapd->iface->num_rates = 0;
hapd->iface->current_rates =
- malloc(mode->num_rates * sizeof(struct hostapd_rate_data));
+ os_malloc(mode->num_rates * sizeof(struct hostapd_rate_data));
if (!hapd->iface->current_rates) {
printf("Failed to allocate memory for rate table.\n");
return -1;
@@ -142,8 +142,8 @@ static int hostapd_prepare_rates(struct hostapd_data *hapd,
continue;
rate = &hapd->iface->current_rates[hapd->iface->num_rates];
- memcpy(rate, &mode->rates[i],
- sizeof(struct hostapd_rate_data));
+ os_memcpy(rate, &mode->rates[i],
+ sizeof(struct hostapd_rate_data));
if (hostapd_rate_found(basic_rates, rate->rate)) {
rate->flags |= HOSTAPD_RATE_BASIC;
num_basic_rates++;
diff --git a/hostapd/iapp.c b/hostapd/iapp.c
index 8c9e9cd..18f3b99 100644
--- a/hostapd/iapp.c
+++ b/hostapd/iapp.c
@@ -197,11 +197,11 @@ static void iapp_send_add(struct iapp_data *iapp, u8 *mac_addr, u16 seq_num)
add = (struct iapp_add_notify *) (hdr + 1);
add->addr_len = ETH_ALEN;
add->reserved = 0;
- memcpy(add->mac_addr, mac_addr, ETH_ALEN);
+ os_memcpy(add->mac_addr, mac_addr, ETH_ALEN);
add->seq_num = host_to_be16(seq_num);
- memset(&addr, 0, sizeof(addr));
+ os_memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = iapp->multicast.s_addr;
addr.sin_port = htons(IAPP_UDP_PORT);
@@ -221,8 +221,8 @@ static void iapp_send_layer2_update(struct iapp_data *iapp, u8 *addr)
/* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
* Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
- memset(msg.da, 0xff, ETH_ALEN);
- memcpy(msg.sa, addr, ETH_ALEN);
+ os_memset(msg.da, 0xff, ETH_ALEN);
+ os_memcpy(msg.sa, addr, ETH_ALEN);
msg.len = host_to_be16(6);
msg.dsap = 0; /* NULL DSAP address */
msg.ssap = 0x01; /* NULL SSAP address, CR Bit: Response */
@@ -403,7 +403,7 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
return NULL;
}
- memset(&ifr, 0, sizeof(ifr));
+ os_memset(&ifr, 0, sizeof(ifr));
os_strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
if (ioctl(iapp->udp_sock, SIOCGIFINDEX, &ifr) != 0) {
perror("ioctl(SIOCGIFINDEX)");
@@ -440,7 +440,7 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
}
inet_aton(IAPP_MULTICAST, &iapp->multicast);
- memset(&uaddr, 0, sizeof(uaddr));
+ os_memset(&uaddr, 0, sizeof(uaddr));
uaddr.sin_family = AF_INET;
uaddr.sin_port = htons(IAPP_UDP_PORT);
if (bind(iapp->udp_sock, (struct sockaddr *) &uaddr,
@@ -450,7 +450,7 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
return NULL;
}
- memset(&mreq, 0, sizeof(mreq));
+ os_memset(&mreq, 0, sizeof(mreq));
mreq.imr_multiaddr = iapp->multicast;
mreq.imr_address.s_addr = INADDR_ANY;
mreq.imr_ifindex = 0;
@@ -468,7 +468,7 @@ struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface)
return NULL;
}
- memset(&addr, 0, sizeof(addr));
+ os_memset(&addr, 0, sizeof(addr));
addr.sll_family = AF_PACKET;
addr.sll_ifindex = ifindex;
if (bind(iapp->packet_sock, (struct sockaddr *) &addr,
@@ -504,7 +504,7 @@ void iapp_deinit(struct iapp_data *iapp)
return;
if (iapp->udp_sock >= 0) {
- memset(&mreq, 0, sizeof(mreq));
+ os_memset(&mreq, 0, sizeof(mreq));
mreq.imr_multiaddr = iapp->multicast;
mreq.imr_address.s_addr = INADDR_ANY;
mreq.imr_ifindex = 0;
@@ -520,21 +520,19 @@ void iapp_deinit(struct iapp_data *iapp)
eloop_unregister_read_sock(iapp->packet_sock);
close(iapp->packet_sock);
}
- free(iapp);
+ os_free(iapp);
}
int iapp_reconfig(struct hostapd_data *hapd, struct hostapd_config *oldconf,
struct hostapd_bss_config *oldbss)
{
if (hapd->conf->ieee802_11f != oldbss->ieee802_11f ||
- strcmp(hapd->conf->iapp_iface, oldbss->iapp_iface) != 0) {
-
+ os_strcmp(hapd->conf->iapp_iface, oldbss->iapp_iface) != 0) {
iapp_deinit(hapd->iapp);
hapd->iapp = NULL;
if (hapd->conf->ieee802_11f) {
hapd->iapp = iapp_init(hapd, hapd->conf->iapp_iface);
-
if (hapd->iapp == NULL)
return -1;
}
diff --git a/hostapd/ieee802_11.c b/hostapd/ieee802_11.c
index 1f06fb4..dd8df79 100644
--- a/hostapd/ieee802_11.c
+++ b/hostapd/ieee802_11.c
@@ -240,7 +240,7 @@ ParseRes ieee802_11_parse_elems(struct hostapd_data *hapd, u8 *start,
u8 *pos = start;
int unknown = 0;
- memset(elems, 0, sizeof(*elems));
+ os_memset(elems, 0, sizeof(*elems));
while (left >= 2) {
u8 id, elen;
@@ -370,13 +370,13 @@ void ieee802_11_send_deauth(struct hostapd_data *hapd, u8 *addr, u16 reason)
hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG,
"deauthenticate - reason %d", reason);
- snprintf(buf, sizeof(buf), "SEND-DEAUTHENTICATE %d", reason);
- memset(&mgmt, 0, sizeof(mgmt));
+ os_snprintf(buf, sizeof(buf), "SEND-DEAUTHENTICATE %d", reason);
+ os_memset(&mgmt, 0, sizeof(mgmt));
mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
WLAN_FC_STYPE_DEAUTH);
- memcpy(mgmt.da, addr, ETH_ALEN);
- memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN);
- memcpy(mgmt.bssid, hapd->own_addr, ETH_ALEN);
+ os_memcpy(mgmt.da, addr, ETH_ALEN);
+ os_memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN);
+ os_memcpy(mgmt.bssid, hapd->own_addr, ETH_ALEN);
mgmt.u.deauth.reason_code = host_to_le16(reason);
if (hostapd_send_mgmt_frame(hapd, &mgmt, IEEE80211_HDRLEN +
sizeof(mgmt.u.deauth), 0) < 0)
@@ -400,14 +400,14 @@ static void ieee802_11_sta_authenticate(void *eloop_ctx, void *timeout_ctx)
hapd->assoc_ap_ssid_len);
printf(" (as station)\n");
- memset(&mgmt, 0, sizeof(mgmt));
+ os_memset(&mgmt, 0, sizeof(mgmt));
mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
WLAN_FC_STYPE_AUTH);
/* Request TX callback */
mgmt.frame_control |= host_to_le16(BIT(1));
- memcpy(mgmt.da, hapd->conf->assoc_ap_addr, ETH_ALEN);
- memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN);
- memcpy(mgmt.bssid, hapd->conf->assoc_ap_addr, ETH_ALEN);
+ os_memcpy(mgmt.da, hapd->conf->assoc_ap_addr, ETH_ALEN);
+ os_memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN);
+ os_memcpy(mgmt.bssid, hapd->conf->assoc_ap_addr, ETH_ALEN);
mgmt.u.auth.auth_alg = host_to_le16(WLAN_AUTH_OPEN);
mgmt.u.auth.auth_transaction = host_to_le16(1);
mgmt.u.auth.status_code = host_to_le16(0);
@@ -438,21 +438,21 @@ static void ieee802_11_sta_associate(void *eloop_ctx, void *timeout_ctx)
hapd->assoc_ap_ssid_len);
printf(" (as station)\n");
- memset(mgmt, 0, sizeof(*mgmt));
+ os_memset(mgmt, 0, sizeof(*mgmt));
mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
WLAN_FC_STYPE_ASSOC_REQ);
/* Request TX callback */
mgmt->frame_control |= host_to_le16(BIT(1));
- memcpy(mgmt->da, hapd->conf->assoc_ap_addr, ETH_ALEN);
- memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
- memcpy(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN);
+ os_memcpy(mgmt->da, hapd->conf->assoc_ap_addr, ETH_ALEN);
+ os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
+ os_memcpy(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN);
mgmt->u.assoc_req.capab_info = host_to_le16(0);
mgmt->u.assoc_req.listen_interval = host_to_le16(1);
p = &mgmt->u.assoc_req.variable[0];
*p++ = WLAN_EID_SSID;
*p++ = hapd->assoc_ap_ssid_len;
- memcpy(p, hapd->assoc_ap_ssid, hapd->assoc_ap_ssid_len);
+ os_memcpy(p, hapd->assoc_ap_ssid, hapd->assoc_ap_ssid_len);
p += hapd->assoc_ap_ssid_len;
p = hostapd_eid_supp_rates(hapd, p);
@@ -486,8 +486,8 @@ static u16 auth_shared_key(struct hostapd_data *hapd, struct sta_info *sta,
now = time(NULL);
r = random();
- memcpy(key, &now, 4);
- memcpy(key + 4, &r, 4);
+ os_memcpy(key, &now, 4);
+ os_memcpy(key + 4, &r, 4);
rc4(sta->challenge, WLAN_AUTH_CHALLENGE_LEN,
key, sizeof(key));
}
@@ -499,7 +499,7 @@ static u16 auth_shared_key(struct hostapd_data *hapd, struct sta_info *sta,
/* Transaction 3 */
if (!iswep || !sta->challenge || !challenge ||
- memcmp(sta->challenge, challenge, WLAN_AUTH_CHALLENGE_LEN)) {
+ os_memcmp(sta->challenge, challenge, WLAN_AUTH_CHALLENGE_LEN)) {
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_INFO,
"shared key authentication - invalid "
@@ -517,7 +517,7 @@ static u16 auth_shared_key(struct hostapd_data *hapd, struct sta_info *sta,
sta->flags |= WLAN_STA_AUTH;
wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH);
#endif
- free(sta->challenge);
+ os_free(sta->challenge);
sta->challenge = NULL;
return 0;
@@ -543,16 +543,16 @@ static void send_auth_reply(struct hostapd_data *hapd,
WLAN_FC_STYPE_AUTH);
/* Request TX callback */
reply->frame_control |= host_to_le16(BIT(1));
- memcpy(reply->da, dst, ETH_ALEN);
- memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
- memcpy(reply->bssid, bssid, ETH_ALEN);
+ os_memcpy(reply->da, dst, ETH_ALEN);
+ os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
+ os_memcpy(reply->bssid, bssid, ETH_ALEN);
reply->u.auth.auth_alg = host_to_le16(auth_alg);
reply->u.auth.auth_transaction = host_to_le16(auth_transaction);
reply->u.auth.status_code = host_to_le16(resp);
if (ies && ies_len)
- memcpy(reply->u.auth.variable, ies, ies_len);
+ os_memcpy(reply->u.auth.variable, ies, ies_len);
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL,
"authentication reply: STA=" MACSTR " auth_alg=%d "
@@ -631,8 +631,8 @@ static void handle_auth(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
challenge ? " challenge" : "");
if (hapd->assoc_ap_state == AUTHENTICATE && auth_transaction == 2 &&
- memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0 &&
- memcmp(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
+ os_memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0 &&
+ os_memcmp(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
if (status_code != 0) {
printf("Authentication (as station) with AP "
MACSTR " failed (status_code=%d)\n",
@@ -675,7 +675,7 @@ static void handle_auth(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
goto fail;
}
- if (memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) {
+ if (os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) {
printf("Station " MACSTR " not allowed to authenticate.\n",
MAC2STR(mgmt->sa));
resp = WLAN_STATUS_UNSPECIFIED_FAILURE;
@@ -756,8 +756,8 @@ static void handle_auth(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
if (sta->challenge && auth_transaction == 1) {
resp_ies[0] = WLAN_EID_CHALLENGE;
resp_ies[1] = WLAN_AUTH_CHALLENGE_LEN;
- memcpy(resp_ies + 2, sta->challenge,
- WLAN_AUTH_CHALLENGE_LEN);
+ os_memcpy(resp_ies + 2, sta->challenge,
+ WLAN_AUTH_CHALLENGE_LEN);
resp_ies_len = 2 + WLAN_AUTH_CHALLENGE_LEN;
}
break;
@@ -860,8 +860,8 @@ static void handle_assoc(struct hostapd_data *hapd,
}
if (reassoc) {
- memcpy(sta->previous_ap, mgmt->u.reassoc_req.current_ap,
- ETH_ALEN);
+ os_memcpy(sta->previous_ap, mgmt->u.reassoc_req.current_ap,
+ ETH_ALEN);
}
sta->capability = capab_info;
@@ -876,7 +876,8 @@ static void handle_assoc(struct hostapd_data *hapd,
}
if (elems.ssid_len != hapd->conf->ssid.ssid_len ||
- memcmp(elems.ssid, hapd->conf->ssid.ssid, elems.ssid_len) != 0) {
+ os_memcmp(elems.ssid, hapd->conf->ssid.ssid, elems.ssid_len) != 0)
+ {
printf("Station " MACSTR " tried to associate with "
"unknown SSID '", MAC2STR(sta->addr));
ieee802_11_print_ssid(elems.ssid, elems.ssid_len);
@@ -914,8 +915,9 @@ static void handle_assoc(struct hostapd_data *hapd,
goto fail;
}
- memset(sta->supported_rates, 0, sizeof(sta->supported_rates));
- memcpy(sta->supported_rates, elems.supp_rates, elems.supp_rates_len);
+ os_memset(sta->supported_rates, 0, sizeof(sta->supported_rates));
+ os_memcpy(sta->supported_rates, elems.supp_rates,
+ elems.supp_rates_len);
sta->supported_rates_len = elems.supp_rates_len;
if (elems.ext_supp_rates) {
@@ -931,8 +933,8 @@ static void handle_assoc(struct hostapd_data *hapd,
goto fail;
}
- memcpy(sta->supported_rates + elems.supp_rates_len,
- elems.ext_supp_rates, elems.ext_supp_rates_len);
+ os_memcpy(sta->supported_rates + elems.supp_rates_len,
+ elems.ext_supp_rates, elems.ext_supp_rates_len);
sta->supported_rates_len += elems.ext_supp_rates_len;
}
@@ -1088,26 +1090,26 @@ static void handle_assoc(struct hostapd_data *hapd,
*/
if (sta->last_assoc_req)
- free(sta->last_assoc_req);
- sta->last_assoc_req = (struct ieee80211_mgmt *) malloc(len);
+ os_free(sta->last_assoc_req);
+ sta->last_assoc_req = os_malloc(len);
if (sta->last_assoc_req)
- memcpy(sta->last_assoc_req, mgmt, len);
+ os_memcpy(sta->last_assoc_req, mgmt, len);
/* Make sure that the previously registered inactivity timer will not
* remove the STA immediately. */
sta->timeout_next = STA_NULLFUNC;
fail:
- memset(buf, 0, sizeof(buf));
+ os_memset(buf, 0, sizeof(buf));
reply = (struct ieee80211_mgmt *) buf;
reply->frame_control =
IEEE80211_FC(WLAN_FC_TYPE_MGMT,
(send_deauth ? WLAN_FC_STYPE_DEAUTH :
(reassoc ? WLAN_FC_STYPE_REASSOC_RESP :
WLAN_FC_STYPE_ASSOC_RESP)));
- memcpy(reply->da, mgmt->sa, ETH_ALEN);
- memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
- memcpy(reply->bssid, mgmt->bssid, ETH_ALEN);
+ os_memcpy(reply->da, mgmt->sa, ETH_ALEN);
+ os_memcpy(reply->sa, hapd->own_addr, ETH_ALEN);
+ os_memcpy(reply->bssid, mgmt->bssid, ETH_ALEN);
send_len = IEEE80211_HDRLEN;
if (send_deauth) {
@@ -1166,8 +1168,8 @@ static void handle_assoc_resp(struct hostapd_data *hapd,
return;
}
- if (memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) != 0 ||
- memcmp(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN) != 0) {
+ if (os_memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) != 0 ||
+ os_memcmp(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN) != 0) {
printf("Received association response from unexpected address "
"(SA=" MACSTR " BSSID=" MACSTR "\n",
MAC2STR(mgmt->sa), MAC2STR(mgmt->bssid));
@@ -1217,7 +1219,7 @@ static void handle_disassoc(struct hostapd_data *hapd,
le_to_host16(mgmt->u.disassoc.reason_code));
if (hapd->assoc_ap_state != DO_NOT_ASSOC &&
- memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
+ os_memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
printf("Assoc AP " MACSTR " sent disassociation "
"(reason_code=%d) - try to authenticate\n",
MAC2STR(hapd->conf->assoc_ap_addr),
@@ -1278,7 +1280,7 @@ static void handle_deauth(struct hostapd_data *hapd,
le_to_host16(mgmt->u.deauth.reason_code));
if (hapd->assoc_ap_state != DO_NOT_ASSOC &&
- memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
+ os_memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
printf("Assoc AP " MACSTR " sent deauthentication "
"(reason_code=%d) - try to authenticate\n",
MAC2STR(hapd->conf->assoc_ap_addr),
@@ -1326,10 +1328,10 @@ static void handle_beacon(struct hostapd_data *hapd,
0);
if (hapd->assoc_ap_state == WAIT_BEACON &&
- memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
+ os_memcmp(mgmt->sa, hapd->conf->assoc_ap_addr, ETH_ALEN) == 0) {
if (elems.ssid && elems.ssid_len <= 32) {
- memcpy(hapd->assoc_ap_ssid, elems.ssid,
- elems.ssid_len);
+ os_memcpy(hapd->assoc_ap_ssid, elems.ssid,
+ elems.ssid_len);
hapd->assoc_ap_ssid[elems.ssid_len] = '\0';
hapd->assoc_ap_ssid_len = elems.ssid_len;
}
@@ -1446,9 +1448,11 @@ void ieee802_11_mgmt(struct hostapd_data *hapd, u8 *buf, size_t len, u16 stype,
mgmt->bssid[2] == 0xff && mgmt->bssid[3] == 0xff &&
mgmt->bssid[4] == 0xff && mgmt->bssid[5] == 0xff;
- if (!broadcast && memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0 &&
+ if (!broadcast &&
+ os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0 &&
(hapd->assoc_ap_state == DO_NOT_ASSOC ||
- memcmp(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN) != 0)) {
+ os_memcmp(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN) != 0))
+ {
printf("MGMT: BSSID=" MACSTR " not our address\n",
MAC2STR(mgmt->bssid));
return;
@@ -1461,7 +1465,7 @@ void ieee802_11_mgmt(struct hostapd_data *hapd, u8 *buf, size_t len, u16 stype,
return;
}
- if (memcmp(mgmt->da, hapd->own_addr, ETH_ALEN) != 0) {
+ if (os_memcmp(mgmt->da, hapd->own_addr, ETH_ALEN) != 0) {
hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG,
"MGMT: DA=" MACSTR " not our address",
@@ -1643,7 +1647,7 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
fail:
/* Copy of the association request is not needed anymore */
if (sta->last_assoc_req) {
- free(sta->last_assoc_req);
+ os_free(sta->last_assoc_req);
sta->last_assoc_req = NULL;
}
}
diff --git a/hostapd/ieee802_11_auth.c b/hostapd/ieee802_11_auth.c
index 02a06be..6797f66 100644
--- a/hostapd/ieee802_11_auth.c
+++ b/hostapd/ieee802_11_auth.c
@@ -54,7 +54,7 @@ static void hostapd_acl_cache_free(struct hostapd_cached_radius_acl *acl_cache)
while (acl_cache) {
prev = acl_cache;
acl_cache = acl_cache->next;
- free(prev);
+ os_free(prev);
}
}
@@ -70,7 +70,7 @@ static int hostapd_acl_cache_get(struct hostapd_data *hapd, const u8 *addr,
entry = hapd->acl_cache;
while (entry) {
- if (memcmp(entry->addr, addr, ETH_ALEN) == 0) {
+ if (os_memcmp(entry->addr, addr, ETH_ALEN) == 0) {
if (now - entry->timestamp > RADIUS_ACL_TIMEOUT)
return -1; /* entry has expired */
if (entry->accepted == HOSTAPD_ACL_ACCEPT_TIMEOUT)
@@ -92,8 +92,8 @@ static void hostapd_acl_query_free(struct hostapd_acl_query_data *query)
{
if (query == NULL)
return;
- free(query->auth_msg);
- free(query);
+ os_free(query->auth_msg);
+ os_free(query);
}
@@ -110,25 +110,25 @@ static int hostapd_radius_acl_query(struct hostapd_data *hapd, const u8 *addr,
radius_msg_make_authenticator(msg, addr, ETH_ALEN);
- snprintf(buf, sizeof(buf), RADIUS_ADDR_FORMAT, MAC2STR(addr));
+ os_snprintf(buf, sizeof(buf), RADIUS_ADDR_FORMAT, MAC2STR(addr));
if (!radius_msg_add_attr(msg, RADIUS_ATTR_USER_NAME, (u8 *) buf,
- strlen(buf))) {
- printf("Could not add User-Name\n");
+ os_strlen(buf))) {
+ wpa_printf(MSG_DEBUG, "Could not add User-Name");
goto fail;
}
if (!radius_msg_add_attr_user_password(
- msg, (u8 *) buf, strlen(buf),
+ msg, (u8 *) buf, os_strlen(buf),
hapd->conf->radius->auth_server->shared_secret,
hapd->conf->radius->auth_server->shared_secret_len)) {
- printf("Could not add User-Password\n");
+ wpa_printf(MSG_DEBUG, "Could not add User-Password");
goto fail;
}
if (hapd->conf->own_ip_addr.af == AF_INET &&
!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IP_ADDRESS,
(u8 *) &hapd->conf->own_ip_addr.u.v4, 4)) {
- printf("Could not add NAS-IP-Address\n");
+ wpa_printf(MSG_DEBUG, "Could not add NAS-IP-Address");
goto fail;
}
@@ -136,7 +136,7 @@ static int hostapd_radius_acl_query(struct hostapd_data *hapd, const u8 *addr,
if (hapd->conf->own_ip_addr.af == AF_INET6 &&
!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IPV6_ADDRESS,
(u8 *) &hapd->conf->own_ip_addr.u.v6, 16)) {
- printf("Could not add NAS-IPv6-Address\n");
+ wpa_printf(MSG_DEBUG, "Could not add NAS-IPv6-Address");
goto fail;
}
#endif /* CONFIG_IPV6 */
@@ -144,37 +144,37 @@ static int hostapd_radius_acl_query(struct hostapd_data *hapd, const u8 *addr,
if (hapd->conf->nas_identifier &&
!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IDENTIFIER,
(u8 *) hapd->conf->nas_identifier,
- strlen(hapd->conf->nas_identifier))) {
- printf("Could not add NAS-Identifier\n");
+ os_strlen(hapd->conf->nas_identifier))) {
+ wpa_printf(MSG_DEBUG, "Could not add NAS-Identifier");
goto fail;
}
- snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT ":%s",
- MAC2STR(hapd->own_addr), hapd->conf->ssid.ssid);
+ os_snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT ":%s",
+ MAC2STR(hapd->own_addr), hapd->conf->ssid.ssid);
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLED_STATION_ID,
- (u8 *) buf, strlen(buf))) {
- printf("Could not add Called-Station-Id\n");
+ (u8 *) buf, os_strlen(buf))) {
+ wpa_printf(MSG_DEBUG, "Could not add Called-Station-Id");
goto fail;
}
- snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT,
- MAC2STR(addr));
+ os_snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT,
+ MAC2STR(addr));
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLING_STATION_ID,
- (u8 *) buf, strlen(buf))) {
- printf("Could not add Calling-Station-Id\n");
+ (u8 *) buf, os_strlen(buf))) {
+ wpa_printf(MSG_DEBUG, "Could not add Calling-Station-Id");
goto fail;
}
if (!radius_msg_add_attr_int32(msg, RADIUS_ATTR_NAS_PORT_TYPE,
RADIUS_NAS_PORT_TYPE_IEEE_802_11)) {
- printf("Could not add NAS-Port-Type\n");
+ wpa_printf(MSG_DEBUG, "Could not add NAS-Port-Type");
goto fail;
}
- snprintf(buf, sizeof(buf), "CONNECT 11Mbps 802.11b");
+ os_snprintf(buf, sizeof(buf), "CONNECT 11Mbps 802.11b");
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CONNECT_INFO,
- (u8 *) buf, strlen(buf))) {
- printf("Could not add Connect-Info\n");
+ (u8 *) buf, os_strlen(buf))) {
+ wpa_printf(MSG_DEBUG, "Could not add Connect-Info");
goto fail;
}
@@ -183,7 +183,7 @@ static int hostapd_radius_acl_query(struct hostapd_data *hapd, const u8 *addr,
fail:
radius_msg_free(msg);
- free(msg);
+ os_free(msg);
return -1;
}
@@ -225,7 +225,7 @@ int hostapd_allowed_address(struct hostapd_data *hapd, const u8 *addr,
query = hapd->acl_queries;
while (query) {
- if (memcmp(query->addr, addr, ETH_ALEN) == 0) {
+ if (os_memcmp(query->addr, addr, ETH_ALEN) == 0) {
/* pending query in RADIUS retransmit queue;
* do not generate a new one */
return HOSTAPD_ACL_PENDING;
@@ -239,25 +239,26 @@ int hostapd_allowed_address(struct hostapd_data *hapd, const u8 *addr,
/* No entry in the cache - query external RADIUS server */
query = os_zalloc(sizeof(*query));
if (query == NULL) {
- printf("malloc for query data failed\n");
+ wpa_printf(MSG_ERROR, "malloc for query data failed");
return HOSTAPD_ACL_REJECT;
}
time(&query->timestamp);
- memcpy(query->addr, addr, ETH_ALEN);
+ os_memcpy(query->addr, addr, ETH_ALEN);
if (hostapd_radius_acl_query(hapd, addr, query)) {
- printf("Failed to send Access-Request for ACL "
- "query.\n");
+ wpa_printf(MSG_DEBUG, "Failed to send Access-Request "
+ "for ACL query.");
hostapd_acl_query_free(query);
return HOSTAPD_ACL_REJECT;
}
- query->auth_msg = malloc(len);
+ query->auth_msg = os_malloc(len);
if (query->auth_msg == NULL) {
- printf("Failed to allocate memory for auth frame.\n");
+ wpa_printf(MSG_ERROR, "Failed to allocate memory for "
+ "auth frame.");
hostapd_acl_query_free(query);
return HOSTAPD_ACL_REJECT;
}
- memcpy(query->auth_msg, msg, len);
+ os_memcpy(query->auth_msg, msg, len);
query->auth_msg_len = len;
query->next = hapd->acl_queries;
hapd->acl_queries = query;
@@ -290,7 +291,7 @@ static void hostapd_acl_expire_cache(struct hostapd_data *hapd, time_t now)
tmp = entry;
entry = entry->next;
- free(tmp);
+ os_free(tmp);
continue;
}
@@ -368,26 +369,26 @@ hostapd_acl_recv_radius(struct radius_msg *msg, struct radius_msg *req,
"for RADIUS message (id=%d)\n", query->radius_id);
if (radius_msg_verify(msg, shared_secret, shared_secret_len, req, 0)) {
- printf("Incoming RADIUS packet did not have correct "
- "authenticator - dropped\n");
+ wpa_printf(MSG_INFO, "Incoming RADIUS packet did not have "
+ "correct authenticator - dropped\n");
return RADIUS_RX_INVALID_AUTHENTICATOR;
}
if (msg->hdr->code != RADIUS_CODE_ACCESS_ACCEPT &&
msg->hdr->code != RADIUS_CODE_ACCESS_REJECT) {
- printf("Unknown RADIUS message code %d to ACL query\n",
- msg->hdr->code);
+ wpa_printf(MSG_DEBUG, "Unknown RADIUS message code %d to ACL "
+ "query", msg->hdr->code);
return RADIUS_RX_UNKNOWN;
}
/* Insert Accept/Reject info into ACL cache */
cache = os_zalloc(sizeof(*cache));
if (cache == NULL) {
- printf("Failed to add ACL cache entry\n");
+ wpa_printf(MSG_DEBUG, "Failed to add ACL cache entry");
goto done;
}
time(&cache->timestamp);
- memcpy(cache->addr, query->addr, sizeof(cache->addr));
+ os_memcpy(cache->addr, query->addr, sizeof(cache->addr));
if (msg->hdr->code == RADIUS_CODE_ACCESS_ACCEPT) {
if (radius_msg_get_attr_int32(msg, RADIUS_ATTR_SESSION_TIMEOUT,
&cache->session_timeout) == 0)
diff --git a/hostapd/ieee802_1x.c b/hostapd/ieee802_1x.c
index 4974e7b..ff78768 100644
--- a/hostapd/ieee802_1x.c
+++ b/hostapd/ieee802_1x.c
@@ -47,8 +47,9 @@ static void ieee802_1x_send(struct hostapd_data *hapd, struct sta_info *sta,
len = sizeof(*xhdr) + datalen;
buf = os_zalloc(len);
if (buf == NULL) {
- printf("malloc() failed for ieee802_1x_send(len=%lu)\n",
- (unsigned long) len);
+ wpa_printf(MSG_ERROR, "malloc() failed for "
+ "ieee802_1x_send(len=%lu)",
+ (unsigned long) len);
return;
}
@@ -58,7 +59,7 @@ static void ieee802_1x_send(struct hostapd_data *hapd, struct sta_info *sta,
xhdr->length = host_to_be16(datalen);
if (datalen > 0 && data != NULL)
- memcpy(xhdr + 1, data, datalen);
+ os_memcpy(xhdr + 1, data, datalen);
if (wpa_auth_pairwise_set(sta->wpa_sm))
encrypt = 1;
@@ -68,7 +69,7 @@ static void ieee802_1x_send(struct hostapd_data *hapd, struct sta_info *sta,
hostapd_send_eapol(hapd, sta->addr, buf, len, encrypt);
}
- free(buf);
+ os_free(buf);
}
@@ -143,8 +144,8 @@ static void ieee802_1x_tx_key_one(struct hostapd_data *hapd,
wpa_get_ntp_timestamp(key->replay_counter);
if (os_get_random(key->key_iv, sizeof(key->key_iv))) {
- printf("Could not get random numbers\n");
- free(buf);
+ wpa_printf(MSG_ERROR, "Could not get random numbers");
+ os_free(buf);
return;
}
@@ -162,21 +163,21 @@ static void ieee802_1x_tx_key_one(struct hostapd_data *hapd,
if (sm->eap_if->eapKeyData == NULL || sm->eap_if->eapKeyDataLen < 64) {
wpa_printf(MSG_ERROR, "No eapKeyData available for encrypting "
"and signing EAPOL-Key");
- free(buf);
+ os_free(buf);
return;
}
- memcpy((u8 *) (key + 1), key_data, key_len);
+ os_memcpy((u8 *) (key + 1), key_data, key_len);
ekey_len = sizeof(key->key_iv) + 32;
- ekey = malloc(ekey_len);
+ ekey = os_malloc(ekey_len);
if (ekey == NULL) {
- printf("Could not encrypt key\n");
- free(buf);
+ wpa_printf(MSG_ERROR, "Could not encrypt key");
+ os_free(buf);
return;
}
- memcpy(ekey, key->key_iv, sizeof(key->key_iv));
- memcpy(ekey + sizeof(key->key_iv), sm->eap_if->eapKeyData, 32);
+ os_memcpy(ekey, key->key_iv, sizeof(key->key_iv));
+ os_memcpy(ekey + sizeof(key->key_iv), sm->eap_if->eapKeyData, 32);
rc4((u8 *) (key + 1), key_len, ekey, ekey_len);
- free(ekey);
+ os_free(ekey);
/* This header is needed here for HMAC-MD5, but it will be regenerated
* in ieee802_1x_send() */
@@ -193,7 +194,7 @@ static void ieee802_1x_tx_key_one(struct hostapd_data *hapd,
ieee802_1x_send(hapd, sta, IEEE802_1X_TYPE_EAPOL_KEY, (u8 *) key, len);
if (sta->eapol_sm)
sta->eapol_sm->dot1xAuthEapolFramesTx++;
- free(buf);
+ os_free(buf);
}
@@ -215,13 +216,13 @@ ieee802_1x_group_alloc(struct hostapd_data *hapd, const char *ifname)
key->idx++;
if (!key->key[key->idx])
- key->key[key->idx] = malloc(key->default_len);
+ key->key[key->idx] = os_malloc(key->default_len);
if (key->key[key->idx] == NULL ||
os_get_random(key->key[key->idx], key->default_len)) {
printf("Could not generate random WEP key (dynamic VLAN).\n");
- free(key->key[key->idx]);
+ os_free(key->key[key->idx]);
key->key[key->idx] = NULL;
- free(key);
+ os_free(key);
return NULL;
}
key->len[key->idx] = key->default_len;
@@ -279,13 +280,13 @@ ieee802_1x_get_group(struct hostapd_data *hapd, struct hostapd_ssid *ssid,
if (ssid->max_dyn_vlan_keys < vlan_id) {
struct hostapd_wep_keys **na;
int size = (vlan_id + 1) * sizeof(ssid->dyn_vlan_keys[0]);
- na = realloc(ssid->dyn_vlan_keys, size);
+ na = os_realloc(ssid->dyn_vlan_keys, size);
if (na == NULL)
return NULL;
ssid->dyn_vlan_keys = na;
- memset(&ssid->dyn_vlan_keys[ssid->max_dyn_vlan_keys + 1], 0,
- (vlan_id - ssid->max_dyn_vlan_keys) *
- sizeof(ssid->dyn_vlan_keys[0]));
+ os_memset(&ssid->dyn_vlan_keys[ssid->max_dyn_vlan_keys + 1], 0,
+ (vlan_id - ssid->max_dyn_vlan_keys) *
+ sizeof(ssid->dyn_vlan_keys[0]));
ssid->max_dyn_vlan_keys = vlan_id;
}
@@ -326,12 +327,12 @@ void ieee802_1x_tx_key(struct hostapd_data *hapd, struct sta_info *sta)
if (hapd->conf->individual_wep_key_len > 0) {
u8 *ikey;
- ikey = malloc(hapd->conf->individual_wep_key_len);
+ ikey = os_malloc(hapd->conf->individual_wep_key_len);
if (ikey == NULL ||
os_get_random(ikey, hapd->conf->individual_wep_key_len)) {
- printf("Could not generate random individual WEP "
- "key.\n");
- free(ikey);
+ wpa_printf(MSG_ERROR, "Could not generate random "
+ "individual WEP key.");
+ os_free(ikey);
return;
}
@@ -347,10 +348,11 @@ void ieee802_1x_tx_key(struct hostapd_data *hapd, struct sta_info *sta)
sta->addr, 0, ikey,
hapd->conf->individual_wep_key_len,
1)) {
- printf("Could not set individual WEP encryption.\n");
+ wpa_printf(MSG_ERROR, "Could not set individual WEP "
+ "encryption.");
}
- free(ikey);
+ os_free(ikey);
}
}
@@ -469,7 +471,7 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
if (hapd->conf->nas_identifier &&
!radius_msg_add_attr(msg, RADIUS_ATTR_NAS_IDENTIFIER,
(u8 *) hapd->conf->nas_identifier,
- strlen(hapd->conf->nas_identifier))) {
+ os_strlen(hapd->conf->nas_identifier))) {
printf("Could not add NAS-Identifier\n");
goto fail;
}
@@ -479,20 +481,20 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
goto fail;
}
- snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT ":%s",
- MAC2STR(hapd->own_addr), hapd->conf->ssid.ssid);
+ os_snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT ":%s",
+ MAC2STR(hapd->own_addr), hapd->conf->ssid.ssid);
buf[sizeof(buf) - 1] = '\0';
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLED_STATION_ID,
- (u8 *) buf, strlen(buf))) {
+ (u8 *) buf, os_strlen(buf))) {
printf("Could not add Called-Station-Id\n");
goto fail;
}
- snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT,
- MAC2STR(sta->addr));
+ os_snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT,
+ MAC2STR(sta->addr));
buf[sizeof(buf) - 1] = '\0';
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLING_STATION_ID,
- (u8 *) buf, strlen(buf))) {
+ (u8 *) buf, os_strlen(buf))) {
printf("Could not add Calling-Station-Id\n");
goto fail;
}
@@ -515,14 +517,14 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
os_strlcpy(buf, "IEEE 802.11i Pre-Authentication",
sizeof(buf));
} else {
- snprintf(buf, sizeof(buf), "CONNECT %d%sMbps %s",
- radius_sta_rate(hapd, sta) / 2,
- (radius_sta_rate(hapd, sta) & 1) ? ".5" : "",
- radius_mode_txt(hapd));
+ os_snprintf(buf, sizeof(buf), "CONNECT %d%sMbps %s",
+ radius_sta_rate(hapd, sta) / 2,
+ (radius_sta_rate(hapd, sta) & 1) ? ".5" : "",
+ radius_mode_txt(hapd));
buf[sizeof(buf) - 1] = '\0';
}
if (!radius_msg_add_attr(msg, RADIUS_ATTR_CONNECT_INFO,
- (u8 *) buf, strlen(buf))) {
+ (u8 *) buf, os_strlen(buf))) {
printf("Could not add Connect-Info\n");
goto fail;
}
@@ -554,7 +556,7 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
fail:
radius_msg_free(msg);
- free(msg);
+ os_free(msg);
}
@@ -876,8 +878,8 @@ void ieee802_1x_free_radius_class(struct radius_class_data *class)
if (class == NULL)
return;
for (i = 0; i < class->count; i++)
- free(class->attr[i].data);
- free(class->attr);
+ os_free(class->attr[i].data);
+ os_free(class->attr);
class->attr = NULL;
class->count = 0;
}
@@ -898,11 +900,12 @@ int ieee802_1x_copy_radius_class(struct radius_class_data *dst,
dst->count = 0;
for (i = 0; i < src->count; i++) {
- dst->attr[i].data = malloc(src->attr[i].len);
+ dst->attr[i].data = os_malloc(src->attr[i].len);
if (dst->attr[i].data == NULL)
break;
dst->count++;
- memcpy(dst->attr[i].data, src->attr[i].data, src->attr[i].len);
+ os_memcpy(dst->attr[i].data, src->attr[i].data,
+ src->attr[i].len);
dst->attr[i].len = src->attr[i].len;
}
@@ -923,10 +926,10 @@ void ieee802_1x_free_station(struct sta_info *sta)
if (sm->last_recv_radius) {
radius_msg_free(sm->last_recv_radius);
- free(sm->last_recv_radius);
+ os_free(sm->last_recv_radius);
}
- free(sm->identity);
+ os_free(sm->identity);
ieee802_1x_free_radius_class(&sm->radius_class);
eapol_auth_free(sm);
}
@@ -967,7 +970,7 @@ static void ieee802_1x_decapsulate_radius(struct hostapd_data *hapd,
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
HOSTAPD_LEVEL_WARNING, "too short EAP packet "
"received from authentication server");
- free(eap);
+ os_free(eap);
sm->eap_if->aaaEapNoReq = TRUE;
return;
}
@@ -980,14 +983,14 @@ static void ieee802_1x_decapsulate_radius(struct hostapd_data *hapd,
case EAP_CODE_REQUEST:
if (eap_type >= 0)
sm->eap_type_authsrv = eap_type;
- snprintf(buf, sizeof(buf), "EAP-Request-%s (%d)",
- eap_type >= 0 ? eap_type_text(eap_type) : "??",
- eap_type);
+ os_snprintf(buf, sizeof(buf), "EAP-Request-%s (%d)",
+ eap_type >= 0 ? eap_type_text(eap_type) : "??",
+ eap_type);
break;
case EAP_CODE_RESPONSE:
- snprintf(buf, sizeof(buf), "EAP Response-%s (%d)",
- eap_type >= 0 ? eap_type_text(eap_type) : "??",
- eap_type);
+ os_snprintf(buf, sizeof(buf), "EAP Response-%s (%d)",
+ eap_type >= 0 ? eap_type_text(eap_type) : "??",
+ eap_type);
break;
case EAP_CODE_SUCCESS:
os_strlcpy(buf, "EAP Success", sizeof(buf));
@@ -1050,9 +1053,9 @@ static void ieee802_1x_get_keys(struct hostapd_data *hapd,
}
if (keys) {
- free(keys->send);
- free(keys->recv);
- free(keys);
+ os_free(keys->send);
+ os_free(keys->recv);
+ os_free(keys);
}
}
@@ -1094,11 +1097,11 @@ static void ieee802_1x_store_radius_class(struct hostapd_data *hapd,
}
} while (class_len < 1);
- nclass[nclass_count].data = malloc(class_len);
+ nclass[nclass_count].data = os_malloc(class_len);
if (nclass[nclass_count].data == NULL)
break;
- memcpy(nclass[nclass_count].data, class, class_len);
+ os_memcpy(nclass[nclass_count].data, class, class_len);
nclass[nclass_count].len = class_len;
nclass_count++;
}
@@ -1128,11 +1131,11 @@ static void ieee802_1x_update_sta_identity(struct hostapd_data *hapd,
NULL) < 0)
return;
- identity = malloc(len + 1);
+ identity = os_malloc(len + 1);
if (identity == NULL)
return;
- memcpy(identity, buf, len);
+ os_memcpy(identity, buf, len);
identity[len] = '\0';
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
@@ -1141,7 +1144,7 @@ static void ieee802_1x_update_sta_identity(struct hostapd_data *hapd,
sm->identity ? (char *) sm->identity : "N/A",
(char *) identity);
- free(sm->identity);
+ os_free(sm->identity);
sm->identity = identity;
sm->identity_len = len;
}
@@ -1233,7 +1236,7 @@ ieee802_1x_receive_auth(struct radius_msg *msg, struct radius_msg *req,
if (sm->last_recv_radius) {
radius_msg_free(sm->last_recv_radius);
- free(sm->last_recv_radius);
+ os_free(sm->last_recv_radius);
}
sm->last_recv_radius = msg;
@@ -1354,7 +1357,7 @@ void ieee802_1x_abort_auth(struct hostapd_data *hapd, struct sta_info *sta)
if (sm->last_recv_radius) {
radius_msg_free(sm->last_recv_radius);
- free(sm->last_recv_radius);
+ os_free(sm->last_recv_radius);
sm->last_recv_radius = NULL;
}
}
@@ -1404,13 +1407,13 @@ static int ieee802_1x_rekey_broadcast(struct hostapd_data *hapd)
if (hapd->conf->default_wep_key_len < 1)
return 0;
- free(hapd->default_wep_key);
- hapd->default_wep_key = malloc(hapd->conf->default_wep_key_len);
+ os_free(hapd->default_wep_key);
+ hapd->default_wep_key = os_malloc(hapd->conf->default_wep_key_len);
if (hapd->default_wep_key == NULL ||
os_get_random(hapd->default_wep_key,
hapd->conf->default_wep_key_len)) {
printf("Could not generate random WEP key.\n");
- free(hapd->default_wep_key);
+ os_free(hapd->default_wep_key);
hapd->default_wep_key = NULL;
return -1;
}
@@ -1451,7 +1454,7 @@ static void ieee802_1x_rekey(void *eloop_ctx, void *timeout_ctx)
hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE8021X,
HOSTAPD_LEVEL_WARNING, "failed to generate a "
"new broadcast key");
- free(hapd->default_wep_key);
+ os_free(hapd->default_wep_key);
hapd->default_wep_key = NULL;
return;
}
@@ -1465,7 +1468,7 @@ static void ieee802_1x_rekey(void *eloop_ctx, void *timeout_ctx)
hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE8021X,
HOSTAPD_LEVEL_WARNING, "failed to configure a "
"new broadcast key");
- free(hapd->default_wep_key);
+ os_free(hapd->default_wep_key);
hapd->default_wep_key = NULL;
return;
}
@@ -1521,7 +1524,7 @@ static int ieee802_1x_get_eap_user(void *ctx, const u8 *identity,
if (eap_user == NULL)
return -1;
- memset(user, 0, sizeof(*user));
+ os_memset(user, 0, sizeof(*user));
user->phase2 = phase2;
count = EAP_USER_MAX_METHODS;
if (count > EAP_MAX_METHODS)
@@ -1532,11 +1535,11 @@ static int ieee802_1x_get_eap_user(void *ctx, const u8 *identity,
}
if (eap_user->password) {
- user->password = malloc(eap_user->password_len);
+ user->password = os_malloc(eap_user->password_len);
if (user->password == NULL)
return -1;
- memcpy(user->password, eap_user->password,
- eap_user->password_len);
+ os_memcpy(user->password, eap_user->password,
+ eap_user->password_len);
user->password_len = eap_user->password_len;
}
user->force_version = eap_user->force_version;
@@ -1703,7 +1706,7 @@ int ieee802_1x_tx_status(struct hostapd_data *hapd, struct sta_info *sta,
hdr = (struct ieee80211_hdr *) buf;
pos = (u8 *) (hdr + 1);
- if (memcmp(pos, rfc1042_hdr, sizeof(rfc1042_hdr)) != 0)
+ if (os_memcmp(pos, rfc1042_hdr, sizeof(rfc1042_hdr)) != 0)
return 0;
pos += sizeof(rfc1042_hdr);
if (WPA_GET_BE16(pos) != ETH_P_PAE)
@@ -1831,133 +1834,134 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
if (sm == NULL)
return 0;
- ret = snprintf(buf + len, buflen - len,
- "dot1xPaePortNumber=%d\n"
- "dot1xPaePortProtocolVersion=%d\n"
- "dot1xPaePortCapabilities=1\n"
- "dot1xPaePortInitialize=%d\n"
- "dot1xPaePortReauthenticate=FALSE\n",
- sta->aid,
- EAPOL_VERSION,
- sm->initialize);
+ ret = os_snprintf(buf + len, buflen - len,
+ "dot1xPaePortNumber=%d\n"
+ "dot1xPaePortProtocolVersion=%d\n"
+ "dot1xPaePortCapabilities=1\n"
+ "dot1xPaePortInitialize=%d\n"
+ "dot1xPaePortReauthenticate=FALSE\n",
+ sta->aid,
+ EAPOL_VERSION,
+ sm->initialize);
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
/* dot1xAuthConfigTable */
- ret = snprintf(buf + len, buflen - len,
- "dot1xAuthPaeState=%d\n"
- "dot1xAuthBackendAuthState=%d\n"
- "dot1xAuthAdminControlledDirections=%d\n"
- "dot1xAuthOperControlledDirections=%d\n"
- "dot1xAuthAuthControlledPortStatus=%d\n"
- "dot1xAuthAuthControlledPortControl=%d\n"
- "dot1xAuthQuietPeriod=%u\n"
- "dot1xAuthServerTimeout=%u\n"
- "dot1xAuthReAuthPeriod=%u\n"
- "dot1xAuthReAuthEnabled=%s\n"
- "dot1xAuthKeyTxEnabled=%s\n",
- sm->auth_pae_state + 1,
- sm->be_auth_state + 1,
- sm->adminControlledDirections,
- sm->operControlledDirections,
- sm->authPortStatus,
- sm->portControl,
- sm->quietPeriod,
- sm->serverTimeout,
- sm->reAuthPeriod,
- bool_txt(sm->reAuthEnabled),
- bool_txt(sm->keyTxEnabled));
+ ret = os_snprintf(buf + len, buflen - len,
+ "dot1xAuthPaeState=%d\n"
+ "dot1xAuthBackendAuthState=%d\n"
+ "dot1xAuthAdminControlledDirections=%d\n"
+ "dot1xAuthOperControlledDirections=%d\n"
+ "dot1xAuthAuthControlledPortStatus=%d\n"
+ "dot1xAuthAuthControlledPortControl=%d\n"
+ "dot1xAuthQuietPeriod=%u\n"
+ "dot1xAuthServerTimeout=%u\n"
+ "dot1xAuthReAuthPeriod=%u\n"
+ "dot1xAuthReAuthEnabled=%s\n"
+ "dot1xAuthKeyTxEnabled=%s\n",
+ sm->auth_pae_state + 1,
+ sm->be_auth_state + 1,
+ sm->adminControlledDirections,
+ sm->operControlledDirections,
+ sm->authPortStatus,
+ sm->portControl,
+ sm->quietPeriod,
+ sm->serverTimeout,
+ sm->reAuthPeriod,
+ bool_txt(sm->reAuthEnabled),
+ bool_txt(sm->keyTxEnabled));
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
/* dot1xAuthStatsTable */
- ret = snprintf(buf + len, buflen - len,
- "dot1xAuthEapolFramesRx=%u\n"
- "dot1xAuthEapolFramesTx=%u\n"
- "dot1xAuthEapolStartFramesRx=%u\n"
- "dot1xAuthEapolLogoffFramesRx=%u\n"
- "dot1xAuthEapolRespIdFramesRx=%u\n"
- "dot1xAuthEapolRespFramesRx=%u\n"
- "dot1xAuthEapolReqIdFramesTx=%u\n"
- "dot1xAuthEapolReqFramesTx=%u\n"
- "dot1xAuthInvalidEapolFramesRx=%u\n"
- "dot1xAuthEapLengthErrorFramesRx=%u\n"
- "dot1xAuthLastEapolFrameVersion=%u\n"
- "dot1xAuthLastEapolFrameSource=" MACSTR "\n",
- sm->dot1xAuthEapolFramesRx,
- sm->dot1xAuthEapolFramesTx,
- sm->dot1xAuthEapolStartFramesRx,
- sm->dot1xAuthEapolLogoffFramesRx,
- sm->dot1xAuthEapolRespIdFramesRx,
- sm->dot1xAuthEapolRespFramesRx,
- sm->dot1xAuthEapolReqIdFramesTx,
- sm->dot1xAuthEapolReqFramesTx,
- sm->dot1xAuthInvalidEapolFramesRx,
- sm->dot1xAuthEapLengthErrorFramesRx,
- sm->dot1xAuthLastEapolFrameVersion,
- MAC2STR(sm->addr));
+ ret = os_snprintf(buf + len, buflen - len,
+ "dot1xAuthEapolFramesRx=%u\n"
+ "dot1xAuthEapolFramesTx=%u\n"
+ "dot1xAuthEapolStartFramesRx=%u\n"
+ "dot1xAuthEapolLogoffFramesRx=%u\n"
+ "dot1xAuthEapolRespIdFramesRx=%u\n"
+ "dot1xAuthEapolRespFramesRx=%u\n"
+ "dot1xAuthEapolReqIdFramesTx=%u\n"
+ "dot1xAuthEapolReqFramesTx=%u\n"
+ "dot1xAuthInvalidEapolFramesRx=%u\n"
+ "dot1xAuthEapLengthErrorFramesRx=%u\n"
+ "dot1xAuthLastEapolFrameVersion=%u\n"
+ "dot1xAuthLastEapolFrameSource=" MACSTR "\n",
+ sm->dot1xAuthEapolFramesRx,
+ sm->dot1xAuthEapolFramesTx,
+ sm->dot1xAuthEapolStartFramesRx,
+ sm->dot1xAuthEapolLogoffFramesRx,
+ sm->dot1xAuthEapolRespIdFramesRx,
+ sm->dot1xAuthEapolRespFramesRx,
+ sm->dot1xAuthEapolReqIdFramesTx,
+ sm->dot1xAuthEapolReqFramesTx,
+ sm->dot1xAuthInvalidEapolFramesRx,
+ sm->dot1xAuthEapLengthErrorFramesRx,
+ sm->dot1xAuthLastEapolFrameVersion,
+ MAC2STR(sm->addr));
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
/* dot1xAuthDiagTable */
- ret = snprintf(buf + len, buflen - len,
- "dot1xAuthEntersConnecting=%u\n"
- "dot1xAuthEapLogoffsWhileConnecting=%u\n"
- "dot1xAuthEntersAuthenticating=%u\n"
- "dot1xAuthAuthSuccessesWhileAuthenticating=%u\n"
- "dot1xAuthAuthTimeoutsWhileAuthenticating=%u\n"
- "dot1xAuthAuthFailWhileAuthenticating=%u\n"
- "dot1xAuthAuthEapStartsWhileAuthenticating=%u\n"
- "dot1xAuthAuthEapLogoffWhileAuthenticating=%u\n"
- "dot1xAuthAuthReauthsWhileAuthenticated=%u\n"
- "dot1xAuthAuthEapStartsWhileAuthenticated=%u\n"
- "dot1xAuthAuthEapLogoffWhileAuthenticated=%u\n"
- "dot1xAuthBackendResponses=%u\n"
- "dot1xAuthBackendAccessChallenges=%u\n"
- "dot1xAuthBackendOtherRequestsToSupplicant=%u\n"
- "dot1xAuthBackendAuthSuccesses=%u\n"
- "dot1xAuthBackendAuthFails=%u\n",
- sm->authEntersConnecting,
- sm->authEapLogoffsWhileConnecting,
- sm->authEntersAuthenticating,
- sm->authAuthSuccessesWhileAuthenticating,
- sm->authAuthTimeoutsWhileAuthenticating,
- sm->authAuthFailWhileAuthenticating,
- sm->authAuthEapStartsWhileAuthenticating,
- sm->authAuthEapLogoffWhileAuthenticating,
- sm->authAuthReauthsWhileAuthenticated,
- sm->authAuthEapStartsWhileAuthenticated,
- sm->authAuthEapLogoffWhileAuthenticated,
- sm->backendResponses,
- sm->backendAccessChallenges,
- sm->backendOtherRequestsToSupplicant,
- sm->backendAuthSuccesses,
- sm->backendAuthFails);
+ ret = os_snprintf(buf + len, buflen - len,
+ "dot1xAuthEntersConnecting=%u\n"
+ "dot1xAuthEapLogoffsWhileConnecting=%u\n"
+ "dot1xAuthEntersAuthenticating=%u\n"
+ "dot1xAuthAuthSuccessesWhileAuthenticating=%u\n"
+ "dot1xAuthAuthTimeoutsWhileAuthenticating=%u\n"
+ "dot1xAuthAuthFailWhileAuthenticating=%u\n"
+ "dot1xAuthAuthEapStartsWhileAuthenticating=%u\n"
+ "dot1xAuthAuthEapLogoffWhileAuthenticating=%u\n"
+ "dot1xAuthAuthReauthsWhileAuthenticated=%u\n"
+ "dot1xAuthAuthEapStartsWhileAuthenticated=%u\n"
+ "dot1xAuthAuthEapLogoffWhileAuthenticated=%u\n"
+ "dot1xAuthBackendResponses=%u\n"
+ "dot1xAuthBackendAccessChallenges=%u\n"
+ "dot1xAuthBackendOtherRequestsToSupplicant=%u\n"
+ "dot1xAuthBackendAuthSuccesses=%u\n"
+ "dot1xAuthBackendAuthFails=%u\n",
+ sm->authEntersConnecting,
+ sm->authEapLogoffsWhileConnecting,
+ sm->authEntersAuthenticating,
+ sm->authAuthSuccessesWhileAuthenticating,
+ sm->authAuthTimeoutsWhileAuthenticating,
+ sm->authAuthFailWhileAuthenticating,
+ sm->authAuthEapStartsWhileAuthenticating,
+ sm->authAuthEapLogoffWhileAuthenticating,
+ sm->authAuthReauthsWhileAuthenticated,
+ sm->authAuthEapStartsWhileAuthenticated,
+ sm->authAuthEapLogoffWhileAuthenticated,
+ sm->backendResponses,
+ sm->backendAccessChallenges,
+ sm->backendOtherRequestsToSupplicant,
+ sm->backendAuthSuccesses,
+ sm->backendAuthFails);
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
/* dot1xAuthSessionStatsTable */
- ret = snprintf(buf + len, buflen - len,
- /* TODO: dot1xAuthSessionOctetsRx */
- /* TODO: dot1xAuthSessionOctetsTx */
- /* TODO: dot1xAuthSessionFramesRx */
- /* TODO: dot1xAuthSessionFramesTx */
- "dot1xAuthSessionId=%08X-%08X\n"
- "dot1xAuthSessionAuthenticMethod=%d\n"
- "dot1xAuthSessionTime=%u\n"
- "dot1xAuthSessionTerminateCause=999\n"
- "dot1xAuthSessionUserName=%s\n",
- sta->acct_session_id_hi, sta->acct_session_id_lo,
- (wpa_auth_sta_key_mgmt(sta->wpa_sm) ==
- WPA_KEY_MGMT_IEEE8021X ||
- wpa_auth_sta_key_mgmt(sta->wpa_sm) ==
- WPA_KEY_MGMT_FT_IEEE8021X) ? 1 : 2,
- (unsigned int) (time(NULL) - sta->acct_session_start),
- sm->identity);
+ ret = os_snprintf(buf + len, buflen - len,
+ /* TODO: dot1xAuthSessionOctetsRx */
+ /* TODO: dot1xAuthSessionOctetsTx */
+ /* TODO: dot1xAuthSessionFramesRx */
+ /* TODO: dot1xAuthSessionFramesTx */
+ "dot1xAuthSessionId=%08X-%08X\n"
+ "dot1xAuthSessionAuthenticMethod=%d\n"
+ "dot1xAuthSessionTime=%u\n"
+ "dot1xAuthSessionTerminateCause=999\n"
+ "dot1xAuthSessionUserName=%s\n",
+ sta->acct_session_id_hi, sta->acct_session_id_lo,
+ (wpa_auth_sta_key_mgmt(sta->wpa_sm) ==
+ WPA_KEY_MGMT_IEEE8021X ||
+ wpa_auth_sta_key_mgmt(sta->wpa_sm) ==
+ WPA_KEY_MGMT_FT_IEEE8021X) ? 1 : 2,
+ (unsigned int) (time(NULL) -
+ sta->acct_session_start),
+ sm->identity);
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
diff --git a/hostapd/peerkey.c b/hostapd/peerkey.c
index f5b9c6e..26097b7 100644
--- a/hostapd/peerkey.c
+++ b/hostapd/peerkey.c
@@ -44,7 +44,7 @@ struct wpa_stsl_search {
static int wpa_stsl_select_sta(struct wpa_state_machine *sm, void *ctx)
{
struct wpa_stsl_search *search = ctx;
- if (memcmp(search->addr, sm->addr, ETH_ALEN) == 0) {
+ if (os_memcmp(search->addr, sm->addr, ETH_ALEN) == 0) {
search->sm = sm;
return 1;
}
@@ -120,11 +120,11 @@ void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
}
buf_len = kde.rsn_ie_len + 2 + RSN_SELECTOR_LEN + ETH_ALEN;
- buf = malloc(buf_len);
+ buf = os_malloc(buf_len);
if (buf == NULL)
return;
/* Initiator RSN IE */
- memcpy(buf, kde.rsn_ie, kde.rsn_ie_len);
+ os_memcpy(buf, kde.rsn_ie, kde.rsn_ie_len);
pos = buf + kde.rsn_ie_len;
/* Initiator MAC Address */
pos = wpa_add_kde(pos, RSN_KEY_DATA_MAC_ADDR, sm->addr, ETH_ALEN,
@@ -143,7 +143,7 @@ void wpa_smk_m1(struct wpa_authenticator *wpa_auth,
WPA_KEY_INFO_ACK | WPA_KEY_INFO_SMK_MESSAGE,
NULL, key->key_nonce, buf, pos - buf, 0, 0, 0);
- free(buf);
+ os_free(buf);
}
@@ -167,7 +167,7 @@ static void wpa_send_smk_m4(struct wpa_authenticator *wpa_auth,
2 + RSN_SELECTOR_LEN + WPA_NONCE_LEN +
2 + RSN_SELECTOR_LEN + PMK_LEN + WPA_NONCE_LEN +
2 + RSN_SELECTOR_LEN + sizeof(lifetime);
- pos = buf = malloc(buf_len);
+ pos = buf = os_malloc(buf_len);
if (buf == NULL)
return;
@@ -196,7 +196,7 @@ static void wpa_send_smk_m4(struct wpa_authenticator *wpa_auth,
WPA_KEY_INFO_INSTALL | WPA_KEY_INFO_SMK_MESSAGE,
NULL, key->key_nonce, buf, pos - buf, 0, 1, 0);
- free(buf);
+ os_free(buf);
}
@@ -221,12 +221,12 @@ static void wpa_send_smk_m5(struct wpa_authenticator *wpa_auth,
2 + RSN_SELECTOR_LEN + WPA_NONCE_LEN +
2 + RSN_SELECTOR_LEN + PMK_LEN + WPA_NONCE_LEN +
2 + RSN_SELECTOR_LEN + sizeof(lifetime);
- pos = buf = malloc(buf_len);
+ pos = buf = os_malloc(buf_len);
if (buf == NULL)
return;
/* Peer RSN IE */
- memcpy(buf, kde->rsn_ie, kde->rsn_ie_len);
+ os_memcpy(buf, kde->rsn_ie, kde->rsn_ie_len);
pos = buf + kde->rsn_ie_len;
/* Peer MAC Address */
@@ -253,7 +253,7 @@ static void wpa_send_smk_m5(struct wpa_authenticator *wpa_auth,
WPA_KEY_INFO_SMK_MESSAGE,
NULL, kde->nonce, buf, pos - buf, 0, 1, 0);
- free(buf);
+ os_free(buf);
}
@@ -302,13 +302,13 @@ void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
/* SMK = PRF-256(Random number, "SMK Derivation",
* AA || Time || INonce || PNonce)
*/
- memcpy(buf, wpa_auth->addr, ETH_ALEN);
+ os_memcpy(buf, wpa_auth->addr, ETH_ALEN);
pos = buf + ETH_ALEN;
wpa_get_ntp_timestamp(pos);
pos += 8;
- memcpy(pos, kde.nonce, WPA_NONCE_LEN);
+ os_memcpy(pos, kde.nonce, WPA_NONCE_LEN);
pos += WPA_NONCE_LEN;
- memcpy(pos, key->key_nonce, WPA_NONCE_LEN);
+ os_memcpy(pos, key->key_nonce, WPA_NONCE_LEN);
sha1_prf(smk, PMK_LEN, "SMK Derivation", buf, sizeof(buf),
smk, PMK_LEN);
@@ -319,7 +319,7 @@ void wpa_smk_m3(struct wpa_authenticator *wpa_auth,
/* Authenticator does not need SMK anymore and it is required to forget
* it. */
- memset(smk, 0, sizeof(*smk));
+ os_memset(smk, 0, sizeof(*smk));
}
@@ -354,7 +354,7 @@ void wpa_smk_error(struct wpa_authenticator *wpa_auth,
return;
}
- memcpy(&error, kde.error, sizeof(error));
+ os_memcpy(&error, kde.error, sizeof(error));
mui = be_to_host16(error.mui);
error_type = be_to_host16(error.error_type);
wpa_auth_vlogger(wpa_auth, sm->addr, LOGGER_INFO,
@@ -383,7 +383,7 @@ int wpa_stsl_remove(struct wpa_authenticator *wpa_auth,
wpa_auth->stsl_negotiations = pos->next;
eloop_cancel_timeout(wpa_stsl_step, wpa_auth, pos);
- free(pos);
+ os_free(pos);
return 0;
}
prev = pos;
diff --git a/hostapd/pmksa_cache.c b/hostapd/pmksa_cache.c
index a13410f..e1f8d9b 100644
--- a/hostapd/pmksa_cache.c
+++ b/hostapd/pmksa_cache.c
@@ -63,7 +63,7 @@ void rsn_pmkid(const u8 *pmk, size_t pmk_len, const u8 *aa, const u8 *spa,
addr[2] = spa;
hmac_sha1_vector(pmk, pmk_len, 3, addr, len, hash);
- memcpy(pmkid, hash, PMKID_LEN);
+ os_memcpy(pmkid, hash, PMKID_LEN);
}
@@ -74,9 +74,9 @@ static void _pmksa_cache_free_entry(struct rsn_pmksa_cache_entry *entry)
{
if (entry == NULL)
return;
- free(entry->identity);
+ os_free(entry->identity);
ieee802_1x_free_radius_class(&entry->radius_class);
- free(entry);
+ os_free(entry);
}
@@ -161,11 +161,11 @@ static void pmksa_cache_from_eapol_data(struct rsn_pmksa_cache_entry *entry,
return;
if (eapol->identity) {
- entry->identity = malloc(eapol->identity_len);
+ entry->identity = os_malloc(eapol->identity_len);
if (entry->identity) {
entry->identity_len = eapol->identity_len;
- memcpy(entry->identity, eapol->identity,
- eapol->identity_len);
+ os_memcpy(entry->identity, eapol->identity,
+ eapol->identity_len);
}
}
@@ -184,12 +184,12 @@ void pmksa_cache_to_eapol_data(struct rsn_pmksa_cache_entry *entry,
return;
if (entry->identity) {
- free(eapol->identity);
- eapol->identity = malloc(entry->identity_len);
+ os_free(eapol->identity);
+ eapol->identity = os_malloc(entry->identity_len);
if (eapol->identity) {
eapol->identity_len = entry->identity_len;
- memcpy(eapol->identity, entry->identity,
- entry->identity_len);
+ os_memcpy(eapol->identity, entry->identity,
+ entry->identity_len);
}
wpa_hexdump_ascii(MSG_DEBUG, "STA identity from PMKSA",
eapol->identity, eapol->identity_len);
@@ -238,7 +238,7 @@ pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
entry = os_zalloc(sizeof(*entry));
if (entry == NULL)
return NULL;
- memcpy(entry->pmk, pmk, pmk_len);
+ os_memcpy(entry->pmk, pmk, pmk_len);
entry->pmk_len = pmk_len;
rsn_pmkid(pmk, pmk_len, aa, spa, entry->pmkid);
os_get_time(&now);
@@ -248,7 +248,7 @@ pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
else
entry->expiration += dot11RSNAConfigPMKLifetime;
entry->akmp = WPA_KEY_MGMT_IEEE8021X;
- memcpy(entry->spa, spa, ETH_ALEN);
+ os_memcpy(entry->spa, spa, ETH_ALEN);
pmksa_cache_from_eapol_data(entry, eapol);
/* Replace an old entry for the same STA (if found) with the new entry
@@ -314,7 +314,7 @@ void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa)
eloop_cancel_timeout(pmksa_cache_expire, pmksa, NULL);
for (i = 0; i < PMKID_HASH_SIZE; i++)
pmksa->pmkid[i] = NULL;
- free(pmksa);
+ os_free(pmksa);
}
@@ -335,9 +335,10 @@ struct rsn_pmksa_cache_entry * pmksa_cache_get(struct rsn_pmksa_cache *pmksa,
else
entry = pmksa->pmksa;
while (entry) {
- if ((spa == NULL || memcmp(entry->spa, spa, ETH_ALEN) == 0) &&
+ if ((spa == NULL ||
+ os_memcmp(entry->spa, spa, ETH_ALEN) == 0) &&
(pmkid == NULL ||
- memcmp(entry->pmkid, pmkid, PMKID_LEN) == 0))
+ os_memcmp(entry->pmkid, pmkid, PMKID_LEN) == 0))
return entry;
entry = pmkid ? entry->hnext : entry->next;
}
diff --git a/hostapd/preauth.c b/hostapd/preauth.c
index 245c36f..a826c5c 100644
--- a/hostapd/preauth.c
+++ b/hostapd/preauth.c
@@ -61,7 +61,7 @@ static void rsn_preauth_receive(void *ctx, const u8 *src_addr,
ethhdr = (struct l2_ethhdr *) buf;
hdr = (struct ieee802_1x_hdr *) (ethhdr + 1);
- if (memcmp(ethhdr->h_dest, hapd->own_addr, ETH_ALEN) != 0) {
+ if (os_memcmp(ethhdr->h_dest, hapd->own_addr, ETH_ALEN) != 0) {
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "RSN: pre-auth for "
"foreign address " MACSTR "\n",
MAC2STR(ethhdr->h_dest));
@@ -111,7 +111,7 @@ static int rsn_preauth_iface_add(struct hostapd_data *hapd, const char *ifname)
return -1;
piface->hapd = hapd;
- piface->ifname = strdup(ifname);
+ piface->ifname = os_strdup(ifname);
if (piface->ifname == NULL) {
goto fail1;
}
@@ -129,9 +129,9 @@ static int rsn_preauth_iface_add(struct hostapd_data *hapd, const char *ifname)
return 0;
fail2:
- free(piface->ifname);
+ os_free(piface->ifname);
fail1:
- free(piface);
+ os_free(piface);
return -1;
}
@@ -146,8 +146,8 @@ void rsn_preauth_iface_deinit(struct hostapd_data *hapd)
prev = piface;
piface = piface->next;
l2_packet_deinit(prev->l2);
- free(prev->ifname);
- free(prev);
+ os_free(prev->ifname);
+ os_free(prev);
}
}
@@ -159,7 +159,7 @@ int rsn_preauth_iface_init(struct hostapd_data *hapd)
if (hapd->conf->rsn_preauth_interfaces == NULL)
return 0;
- tmp = strdup(hapd->conf->rsn_preauth_interfaces);
+ tmp = os_strdup(hapd->conf->rsn_preauth_interfaces);
if (tmp == NULL)
return -1;
start = tmp;
@@ -168,7 +168,7 @@ int rsn_preauth_iface_init(struct hostapd_data *hapd)
start++;
if (*start == '\0')
break;
- end = strchr(start, ' ');
+ end = os_strchr(start, ' ');
if (end)
*end = '\0';
@@ -182,7 +182,7 @@ int rsn_preauth_iface_init(struct hostapd_data *hapd)
else
break;
}
- free(tmp);
+ os_free(tmp);
return 0;
}
@@ -253,20 +253,20 @@ void rsn_preauth_send(struct hostapd_data *hapd, struct sta_info *sta,
return;
}
- ethhdr = malloc(sizeof(*ethhdr) + len);
+ ethhdr = os_malloc(sizeof(*ethhdr) + len);
if (ethhdr == NULL)
return;
- memcpy(ethhdr->h_dest, sta->addr, ETH_ALEN);
- memcpy(ethhdr->h_source, hapd->own_addr, ETH_ALEN);
+ os_memcpy(ethhdr->h_dest, sta->addr, ETH_ALEN);
+ os_memcpy(ethhdr->h_source, hapd->own_addr, ETH_ALEN);
ethhdr->h_proto = htons(ETH_P_PREAUTH);
- memcpy(ethhdr + 1, buf, len);
+ os_memcpy(ethhdr + 1, buf, len);
if (l2_packet_send(piface->l2, sta->addr, ETH_P_PREAUTH, (u8 *) ethhdr,
sizeof(*ethhdr) + len) < 0) {
printf("Failed to send preauth packet using l2_packet_send\n");
}
- free(ethhdr);
+ os_free(ethhdr);
}
diff --git a/hostapd/reconfig.c b/hostapd/reconfig.c
index 08ca281..5f6d213 100644
--- a/hostapd/reconfig.c
+++ b/hostapd/reconfig.c
@@ -69,8 +69,8 @@ static int hostapd_config_reload_sta(struct hostapd_data *hapd,
sta->ssid = &newbss->ssid;
if (newbss->ssid.ssid_len != oldbss->ssid.ssid_len ||
- memcmp(newbss->ssid.ssid, oldbss->ssid.ssid,
- newbss->ssid.ssid_len) != 0) {
+ os_memcmp(newbss->ssid.ssid, oldbss->ssid.ssid,
+ newbss->ssid.ssid_len) != 0) {
/* main SSID was changed - kick STA out */
deauth++;
}
@@ -211,12 +211,13 @@ static int hostapd_acl_diff(struct hostapd_bss_config *a,
return 1;
for (i = 0; i < a->num_accept_mac; i++) {
- if (memcmp(a->accept_mac[i], b->accept_mac[i], ETH_ALEN) != 0)
+ if (os_memcmp(a->accept_mac[i], b->accept_mac[i], ETH_ALEN) !=
+ 0)
return 1;
}
for (i = 0; i < a->num_deny_mac; i++) {
- if (memcmp(a->deny_mac[i], b->deny_mac[i], ETH_ALEN) != 0)
+ if (os_memcmp(a->deny_mac[i], b->deny_mac[i], ETH_ALEN) != 0)
return 1;
}
@@ -407,8 +408,8 @@ static void hostapd_reconfig_bss(struct hostapd_data *hapd,
printf("Could not set DTIM period for kernel driver\n");
if (newbss->ssid.ssid_len != oldbss->ssid.ssid_len ||
- memcmp(newbss->ssid.ssid, oldbss->ssid.ssid,
- newbss->ssid.ssid_len) != 0) {
+ os_memcmp(newbss->ssid.ssid, oldbss->ssid.ssid,
+ newbss->ssid.ssid_len) != 0) {
if (hostapd_set_ssid(hapd, (u8 *) newbss->ssid.ssid,
newbss->ssid.ssid_len))
printf("Could not set SSID for kernel driver\n");
@@ -477,7 +478,7 @@ static void config_reload2(struct hostapd_iface *hapd_iface, int status)
u8 *prev_addr;
hostapd_iface_cb cb;
- free(change);
+ os_free(change);
hapd_iface->change = NULL;
if (status) {
@@ -492,7 +493,7 @@ static void config_reload2(struct hostapd_iface *hapd_iface, int status)
hapd_iface->conf = hapd->iconf = oldconf;
hapd->conf = &oldconf->bss[0];
hostapd_config_free(newconf);
- free(new_hapd);
+ os_free(new_hapd);
cb(hapd_iface, -2);
@@ -509,9 +510,9 @@ static void config_reload2(struct hostapd_iface *hapd_iface, int status)
max_bss = newconf->num_bss;
for (i = 0; i < max_bss; i++) {
- if (strcmp(oldconf->bss[i].iface, newconf->bss[i].iface) != 0
- || hostapd_mac_comp(oldconf->bss[i].bssid,
- newconf->bss[i].bssid) != 0)
+ if (os_strcmp(oldconf->bss[i].iface, newconf->bss[i].iface) !=
+ 0 || hostapd_mac_comp(oldconf->bss[i].bssid,
+ newconf->bss[i].bssid) != 0)
break;
}
same_bssid = i;
@@ -520,8 +521,8 @@ static void config_reload2(struct hostapd_iface *hapd_iface, int status)
oldbss = &oldconf->bss[i];
newbss = NULL;
for (j = 0; j < newconf->num_bss; j++) {
- if (strcmp(oldbss->iface, newconf->bss[j].iface) == 0)
- {
+ if (os_strcmp(oldbss->iface, newconf->bss[j].iface) ==
+ 0) {
newbss = &newconf->bss[j];
break;
}
@@ -549,7 +550,7 @@ static void config_reload2(struct hostapd_iface *hapd_iface, int status)
hostapd_cleanup(hapd);
#endif
- free(hapd);
+ os_free(hapd);
}
}
@@ -583,7 +584,7 @@ static void config_reload2(struct hostapd_iface *hapd_iface, int status)
hapd->iconf = newconf;
hapd->conf = newbss;
- memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
+ os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN);
if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0)
prev_addr = hapd->own_addr;
@@ -597,7 +598,7 @@ static void config_reload2(struct hostapd_iface *hapd_iface, int status)
}
- free(old_hapd);
+ os_free(old_hapd);
hostapd_config_free(oldconf);
cb = hapd_iface->config_reload_cb;
@@ -644,7 +645,7 @@ int hostapd_config_reload_start(struct hostapd_iface *hapd_iface,
return -1;
}
- if (strcmp(newconf->bss[0].iface, hapd_iface->conf->bss[0].iface) !=
+ if (os_strcmp(newconf->bss[0].iface, hapd_iface->conf->bss[0].iface) !=
0) {
printf("Interface name changing is not allowed in "
"configuration reloading (%s -> %s).\n",
@@ -697,7 +698,7 @@ int hostapd_config_reload_start(struct hostapd_iface *hapd_iface,
printf("Failed to start setup of new interface config\n");
hapd_iface->config_reload_cb = NULL;
- free(change);
+ os_free(change);
hapd_iface->change = NULL;
/* Invalid configuration - cleanup and terminate hostapd */
@@ -706,7 +707,7 @@ int hostapd_config_reload_start(struct hostapd_iface *hapd_iface,
hapd_iface->conf = hapd->iconf = oldconf;
hapd->conf = &oldconf->bss[0];
hostapd_config_free(newconf);
- free(new_hapd);
+ os_free(new_hapd);
return -2;
}
diff --git a/hostapd/sta_info.c b/hostapd/sta_info.c
index acd2d66..cab7750 100644
--- a/hostapd/sta_info.c
+++ b/hostapd/sta_info.c
@@ -55,7 +55,7 @@ struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta)
struct sta_info *s;
s = hapd->sta_hash[STA_HASH(sta)];
- while (s != NULL && memcmp(s->addr, sta, 6) != 0)
+ while (s != NULL && os_memcmp(s->addr, sta, 6) != 0)
s = s->hnext;
return s;
}
@@ -74,8 +74,8 @@ static void ap_sta_list_del(struct hostapd_data *hapd, struct sta_info *sta)
while (tmp != NULL && tmp->next != sta)
tmp = tmp->next;
if (tmp == NULL) {
- printf("Could not remove STA " MACSTR " from list.\n",
- MAC2STR(sta->addr));
+ wpa_printf(MSG_DEBUG, "Could not remove STA " MACSTR " from "
+ "list.", MAC2STR(sta->addr));
} else
tmp->next = sta->next;
}
@@ -94,18 +94,19 @@ static void ap_sta_hash_del(struct hostapd_data *hapd, struct sta_info *sta)
s = hapd->sta_hash[STA_HASH(sta->addr)];
if (s == NULL) return;
- if (memcmp(s->addr, sta->addr, 6) == 0) {
+ if (os_memcmp(s->addr, sta->addr, 6) == 0) {
hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext;
return;
}
- while (s->hnext != NULL && memcmp(s->hnext->addr, sta->addr, 6) != 0)
+ while (s->hnext != NULL &&
+ os_memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
s = s->hnext;
if (s->hnext != NULL)
s->hnext = s->hnext->hnext;
else
- printf("AP: could not remove STA " MACSTR " from hash table\n",
- MAC2STR(sta->addr));
+ wpa_printf(MSG_DEBUG, "AP: could not remove STA " MACSTR
+ " from hash table", MAC2STR(sta->addr));
}
@@ -160,12 +161,9 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
rsn_preauth_free_station(hapd, sta);
radius_client_flush_auth(hapd->radius, sta->addr);
- if (sta->last_assoc_req)
- free(sta->last_assoc_req);
-
- free(sta->challenge);
-
- free(sta);
+ os_free(sta->last_assoc_req);
+ os_free(sta->challenge);
+ os_free(sta);
}
@@ -182,7 +180,8 @@ void hostapd_free_stas(struct hostapd_data *hapd)
hapd, sta, WLAN_REASON_UNSPECIFIED);
}
sta = sta->next;
- printf("Removing station " MACSTR "\n", MAC2STR(prev->addr));
+ wpa_printf(MSG_DEBUG, "Removing station " MACSTR,
+ MAC2STR(prev->addr));
ap_free_sta(hapd, prev);
}
}
@@ -211,9 +210,9 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
MAC2STR(sta->addr));
inactive_sec = hostapd_get_inact_sec(hapd, sta->addr);
if (inactive_sec == -1) {
- printf(" Could not get station info from kernel "
- "driver for " MACSTR ".\n",
- MAC2STR(sta->addr));
+ wpa_printf(MSG_DEBUG, "Could not get station info "
+ "from kernel driver for " MACSTR ".",
+ MAC2STR(sta->addr));
} else if (inactive_sec < hapd->conf->ap_max_inactivity &&
sta->flags & WLAN_STA_ASSOC) {
/* station activity detected; reset timeout state */
@@ -256,14 +255,15 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
/* FIX: WLAN_FC_STYPE_NULLFUNC would be more appropriate, but
* it is apparently not retried so TX Exc events are not
* received for it */
- memset(&hdr, 0, sizeof(hdr));
+ os_memset(&hdr, 0, sizeof(hdr));
hdr.frame_control =
IEEE80211_FC(WLAN_FC_TYPE_DATA, WLAN_FC_STYPE_DATA);
hdr.frame_control |= host_to_le16(BIT(1));
hdr.frame_control |= host_to_le16(WLAN_FC_FROMDS);
- memcpy(hdr.IEEE80211_DA_FROMDS, sta->addr, ETH_ALEN);
- memcpy(hdr.IEEE80211_BSSID_FROMDS, hapd->own_addr, ETH_ALEN);
- memcpy(hdr.IEEE80211_SA_FROMDS, hapd->own_addr, ETH_ALEN);
+ os_memcpy(hdr.IEEE80211_DA_FROMDS, sta->addr, ETH_ALEN);
+ os_memcpy(hdr.IEEE80211_BSSID_FROMDS, hapd->own_addr,
+ ETH_ALEN);
+ os_memcpy(hdr.IEEE80211_SA_FROMDS, hapd->own_addr, ETH_ALEN);
if (hostapd_send_mgmt_frame(hapd, &hdr, sizeof(hdr), 0) < 0)
perror("ap_handle_timer: send");
@@ -271,9 +271,9 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
} else if (sta->timeout_next != STA_REMOVE) {
int deauth = sta->timeout_next == STA_DEAUTH;
- printf(" Sending %s info to STA " MACSTR "\n",
- deauth ? "deauthentication" : "disassociation",
- MAC2STR(sta->addr));
+ wpa_printf(MSG_DEBUG, "Sending %s info to STA " MACSTR,
+ deauth ? "deauthentication" : "disassociation",
+ MAC2STR(sta->addr));
if (deauth) {
hostapd_sta_deauth(hapd, sta->addr,
@@ -341,7 +341,7 @@ static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx)
"session timeout");
sta->acct_terminate_cause =
RADIUS_ACCT_TERMINATE_CAUSE_SESSION_TIMEOUT;
- memcpy(addr, sta->addr, ETH_ALEN);
+ os_memcpy(addr, sta->addr, ETH_ALEN);
ap_free_sta(hapd, sta);
hostapd_sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
}
@@ -376,14 +376,14 @@ struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr)
HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, " New STA\n");
if (hapd->num_sta >= hapd->conf->max_num_sta) {
/* FIX: might try to remove some old STAs first? */
- printf(" no more room for new STAs (%d/%d)\n",
- hapd->num_sta, hapd->conf->max_num_sta);
+ wpa_printf(MSG_DEBUG, "no more room for new STAs (%d/%d)",
+ hapd->num_sta, hapd->conf->max_num_sta);
return NULL;
}
sta = os_zalloc(sizeof(struct sta_info));
if (sta == NULL) {
- printf(" malloc failed\n");
+ wpa_printf(MSG_ERROR, "malloc failed");
return NULL;
}
sta->acct_interim_interval = hapd->conf->radius->acct_interim_interval;
@@ -391,7 +391,7 @@ struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr)
/* initialize STA info data */
eloop_register_timeout(hapd->conf->ap_max_inactivity, 0,
ap_handle_timer, hapd, sta);
- memcpy(sta->addr, addr, ETH_ALEN);
+ os_memcpy(sta->addr, addr, ETH_ALEN);
sta->next = hapd->sta_list;
hapd->sta_list = sta;
hapd->num_sta++;
@@ -410,8 +410,8 @@ static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta)
" from kernel driver\n", MAC2STR(sta->addr));
if (hostapd_sta_remove(hapd, sta->addr) &&
sta->flags & WLAN_STA_ASSOC) {
- printf("Could not remove station " MACSTR " from kernel "
- "driver.\n", MAC2STR(sta->addr));
+ wpa_printf(MSG_DEBUG, "Could not remove station " MACSTR
+ " from kernel driver.", MAC2STR(sta->addr));
return -1;
}
return 0;
diff --git a/hostapd/vlan_init.c b/hostapd/vlan_init.c
index 5b7950f..44f0dc6 100644
--- a/hostapd/vlan_init.c
+++ b/hostapd/vlan_init.c
@@ -53,7 +53,7 @@ static int ifconfig_helper(const char *if_name, int up)
return -1;
}
- memset(&ifr, 0, sizeof(ifr));
+ os_memset(&ifr, 0, sizeof(ifr));
os_strlcpy(ifr.ifr_name, if_name, IFNAMSIZ);
if (ioctl(fd, SIOCGIFFLAGS, &ifr) != 0) {
@@ -274,7 +274,7 @@ static int br_getnumports(const char *br_name)
arg[2] = MAX_BR_PORTS;
arg[3] = 0;
- memset(ifindices, 0, sizeof(ifindices));
+ os_memset(ifindices, 0, sizeof(ifindices));
os_strlcpy(ifr.ifr_name, br_name, sizeof(ifr.ifr_name));
ifr.ifr_data = (__caddr_t) arg;
@@ -300,7 +300,7 @@ static int vlan_rem(const char *if_name)
int fd;
struct vlan_ioctl_args if_request;
- if ((strlen(if_name) + 1) > sizeof(if_request.device1)) {
+ if ((os_strlen(if_name) + 1) > sizeof(if_request.device1)) {
fprintf(stderr, "Interface name to long.\n");
return -1;
}
@@ -310,9 +310,9 @@ static int vlan_rem(const char *if_name)
return -1;
}
- memset(&if_request, 0, sizeof(if_request));
+ os_memset(&if_request, 0, sizeof(if_request));
- strcpy(if_request.device1, if_name);
+ os_strlcpy(if_request.device1, if_name, sizeof(if_request.device1));
if_request.cmd = DEL_VLAN_CMD;
if (ioctl(fd, SIOCSIFVLAN, &if_request) < 0) {
@@ -341,7 +341,7 @@ static int vlan_add(const char *if_name, int vid)
ifconfig_up(if_name);
- if ((strlen(if_name) + 1) > sizeof(if_request.device1)) {
+ if ((os_strlen(if_name) + 1) > sizeof(if_request.device1)) {
fprintf(stderr, "Interface name to long.\n");
return -1;
}
@@ -351,12 +351,12 @@ static int vlan_add(const char *if_name, int vid)
return -1;
}
- memset(&if_request, 0, sizeof(if_request));
+ os_memset(&if_request, 0, sizeof(if_request));
/* Determine if a suitable vlan device already exists. */
- snprintf(if_request.device1, sizeof(if_request.device1), "vlan%d",
- vid);
+ os_snprintf(if_request.device1, sizeof(if_request.device1), "vlan%d",
+ vid);
if_request.cmd = _GET_VLAN_VID_CMD;
@@ -365,8 +365,8 @@ static int vlan_add(const char *if_name, int vid)
if (if_request.u.VID == vid) {
if_request.cmd = _GET_VLAN_REALDEV_NAME_CMD;
- if (ioctl(fd, SIOCSIFVLAN, &if_request) == 0
- && strncmp(if_request.u.device2, if_name,
+ if (ioctl(fd, SIOCSIFVLAN, &if_request) == 0 &&
+ os_strncmp(if_request.u.device2, if_name,
sizeof(if_request.u.device2)) == 0) {
close(fd);
return 1;
@@ -376,8 +376,8 @@ static int vlan_add(const char *if_name, int vid)
/* A suitable vlan device does not already exist, add one. */
- memset(&if_request, 0, sizeof(if_request));
- strcpy(if_request.device1, if_name);
+ os_memset(&if_request, 0, sizeof(if_request));
+ os_strlcpy(if_request.device1, if_name, sizeof(if_request.device1));
if_request.u.VID = vid;
if_request.cmd = ADD_VLAN_CMD;
@@ -402,7 +402,7 @@ static int vlan_set_name_type(unsigned int name_type)
return -1;
}
- memset(&if_request, 0, sizeof(if_request));
+ os_memset(&if_request, 0, sizeof(if_request));
if_request.u.name_type = name_type;
if_request.cmd = SET_VLAN_NAME_TYPE_CMD;
@@ -425,10 +425,10 @@ static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
char *tagged_interface = hapd->conf->ssid.vlan_tagged_interface;
while (vlan) {
- if (strcmp(ifname, vlan->ifname) == 0) {
+ if (os_strcmp(ifname, vlan->ifname) == 0) {
- snprintf(br_name, sizeof(br_name), "brvlan%d",
- vlan->vlan_id);
+ os_snprintf(br_name, sizeof(br_name), "brvlan%d",
+ vlan->vlan_id);
if (!br_addbr(br_name))
vlan->clean |= DVLAN_CLEAN_BR;
@@ -440,8 +440,8 @@ static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
if (!vlan_add(tagged_interface, vlan->vlan_id))
vlan->clean |= DVLAN_CLEAN_VLAN;
- snprintf(vlan_ifname, sizeof(vlan_ifname),
- "vlan%d", vlan->vlan_id);
+ os_snprintf(vlan_ifname, sizeof(vlan_ifname),
+ "vlan%d", vlan->vlan_id);
if (!br_addif(br_name, vlan_ifname))
vlan->clean |= DVLAN_CLEAN_VLAN_PORT;
@@ -472,13 +472,13 @@ static void vlan_dellink(char *ifname, struct hostapd_data *hapd)
first = prev = vlan;
while (vlan) {
- if (strcmp(ifname, vlan->ifname) == 0) {
- snprintf(br_name, sizeof(br_name), "brvlan%d",
- vlan->vlan_id);
+ if (os_strcmp(ifname, vlan->ifname) == 0) {
+ os_snprintf(br_name, sizeof(br_name), "brvlan%d",
+ vlan->vlan_id);
if (tagged_interface) {
- snprintf(vlan_ifname, sizeof(vlan_ifname),
- "vlan%d", vlan->vlan_id);
+ os_snprintf(vlan_ifname, sizeof(vlan_ifname),
+ "vlan%d", vlan->vlan_id);
numports = br_getnumports(br_name);
if (numports == 1) {
@@ -496,7 +496,7 @@ static void vlan_dellink(char *ifname, struct hostapd_data *hapd)
} else {
prev->next = vlan->next;
}
- free(vlan);
+ os_free(vlan);
break;
}
@@ -536,11 +536,11 @@ vlan_read_ifnames(struct nlmsghdr *h, size_t len, int del,
if (n < 0)
break;
- memset(ifname, 0, sizeof(ifname));
+ os_memset(ifname, 0, sizeof(ifname));
if ((size_t) n > sizeof(ifname))
n = sizeof(ifname);
- memcpy(ifname, ((char *) attr) + rta_len, n);
+ os_memcpy(ifname, ((char *) attr) + rta_len, n);
if (del)
vlan_dellink(ifname, hapd);
@@ -610,36 +610,33 @@ full_dynamic_vlan_init(struct hostapd_data *hapd)
struct sockaddr_nl local;
struct full_dynamic_vlan *priv;
- priv = malloc(sizeof(*priv));
-
+ priv = os_zalloc(sizeof(*priv));
if (priv == NULL)
return NULL;
- memset(priv, 0, sizeof(*priv));
-
vlan_set_name_type(VLAN_NAME_TYPE_PLUS_VID_NO_PAD);
priv->s = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (priv->s < 0) {
perror("socket(PF_NETLINK,SOCK_RAW,NETLINK_ROUTE)");
- free(priv);
+ os_free(priv);
return NULL;
}
- memset(&local, 0, sizeof(local));
+ os_memset(&local, 0, sizeof(local));
local.nl_family = AF_NETLINK;
local.nl_groups = RTMGRP_LINK;
if (bind(priv->s, (struct sockaddr *) &local, sizeof(local)) < 0) {
perror("bind(netlink)");
close(priv->s);
- free(priv);
+ os_free(priv);
return NULL;
}
if (eloop_register_read_sock(priv->s, vlan_event_receive, hapd, NULL))
{
close(priv->s);
- free(priv);
+ os_free(priv);
return NULL;
}
@@ -653,7 +650,7 @@ static void full_dynamic_vlan_deinit(struct full_dynamic_vlan *priv)
return;
eloop_unregister_read_sock(priv->s);
close(priv->s);
- free(priv);
+ os_free(priv);
}
#endif /* CONFIG_FULL_DYNAMIC_VLAN */
@@ -774,31 +771,31 @@ struct hostapd_vlan * vlan_add_dynamic(struct hostapd_data *hapd,
vlan->vlan_id != VLAN_ID_WILDCARD)
return NULL;
- ifname = strdup(vlan->ifname);
+ ifname = os_strdup(vlan->ifname);
if (ifname == NULL)
return NULL;
- pos = strchr(ifname, '#');
+ pos = os_strchr(ifname, '#');
if (pos == NULL) {
- free(ifname);
+ os_free(ifname);
return NULL;
}
*pos++ = '\0';
- n = malloc(sizeof(*n));
+ n = os_zalloc(sizeof(*n));
if (n == NULL) {
- free(ifname);
+ os_free(ifname);
return NULL;
}
- memset(n, 0, sizeof(*n));
n->vlan_id = vlan_id;
n->dynamic_vlan = 1;
- snprintf(n->ifname, sizeof(n->ifname), "%s%d%s", ifname, vlan_id, pos);
- free(ifname);
+ os_snprintf(n->ifname, sizeof(n->ifname), "%s%d%s", ifname, vlan_id,
+ pos);
+ os_free(ifname);
if (hostapd_if_add(hapd, HOSTAPD_IF_VLAN, n->ifname, NULL)) {
- free(n);
+ os_free(n);
return NULL;
}
diff --git a/hostapd/wme.c b/hostapd/wme.c
index 9817280..89688d2 100644
--- a/hostapd/wme.c
+++ b/hostapd/wme.c
@@ -91,7 +91,7 @@ int hostapd_eid_wme_valid(struct hostapd_data *hapd, u8 *eid, size_t len)
"version %d\n",
wme->oui[0], wme->oui[1], wme->oui[2], wme->oui_type,
wme->oui_subtype, wme->version);
- if (memcmp(wme->oui, wme_oui, sizeof(wme_oui)) != 0 ||
+ if (os_memcmp(wme->oui, wme_oui, sizeof(wme_oui)) != 0 ||
wme->oui_type != WME_OUI_TYPE ||
wme->oui_subtype != WME_OUI_SUBTYPE_INFORMATION_ELEMENT ||
wme->version != WME_VERSION) {
@@ -134,17 +134,17 @@ static void wme_send_action(struct hostapd_data *hapd, const u8 *addr,
hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG,
"action response - reason %d", status_code);
- memset(buf, 0, sizeof(buf));
+ os_memset(buf, 0, sizeof(buf));
m->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
WLAN_FC_STYPE_ACTION);
- memcpy(m->da, addr, ETH_ALEN);
- memcpy(m->sa, hapd->own_addr, ETH_ALEN);
- memcpy(m->bssid, hapd->own_addr, ETH_ALEN);
+ os_memcpy(m->da, addr, ETH_ALEN);
+ os_memcpy(m->sa, hapd->own_addr, ETH_ALEN);
+ os_memcpy(m->bssid, hapd->own_addr, ETH_ALEN);
m->u.action.category = WME_ACTION_CATEGORY;
m->u.action.u.wme_action.action_code = action_code;
m->u.action.u.wme_action.dialog_token = dialogue_token;
m->u.action.u.wme_action.status_code = status_code;
- memcpy(t, tspec, sizeof(struct wme_tspec_info_element));
+ os_memcpy(t, tspec, sizeof(struct wme_tspec_info_element));
len = ((u8 *) (t + 1)) - buf;
if (hostapd_send_mgmt_frame(hapd, m, len, 0) < 0)
diff --git a/hostapd/wpa.c b/hostapd/wpa.c
index 5fcf69c..ca74b72 100644
--- a/hostapd/wpa.c
+++ b/hostapd/wpa.c
@@ -170,8 +170,8 @@ void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
if (wpa_auth->cb.logger == NULL)
return;
- maxlen = strlen(fmt) + 100;
- format = malloc(maxlen);
+ maxlen = os_strlen(fmt) + 100;
+ format = os_malloc(maxlen);
if (!format)
return;
@@ -181,7 +181,7 @@ void wpa_auth_vlogger(struct wpa_authenticator *wpa_auth, const u8 *addr,
wpa_auth_logger(wpa_auth, addr, level, format);
- free(format);
+ os_free(format);
}
@@ -293,14 +293,14 @@ static struct wpa_group * wpa_group_init(struct wpa_authenticator *wpa_auth,
/* Counter = PRF-256(Random number, "Init Counter",
* Local MAC Address || Time)
*/
- memcpy(buf, wpa_auth->addr, ETH_ALEN);
+ os_memcpy(buf, wpa_auth->addr, ETH_ALEN);
wpa_get_ntp_timestamp(buf + ETH_ALEN);
- memcpy(buf + ETH_ALEN + 8, &group, sizeof(group));
+ os_memcpy(buf + ETH_ALEN + 8, &group, sizeof(group));
if (os_get_random(rkey, sizeof(rkey)) ||
os_get_random(group->GMK, WPA_GMK_LEN)) {
wpa_printf(MSG_ERROR, "Failed to get random data for WPA "
"initialization.");
- free(group);
+ os_free(group);
return NULL;
}
@@ -331,28 +331,28 @@ struct wpa_authenticator * wpa_init(const u8 *addr,
wpa_auth = os_zalloc(sizeof(struct wpa_authenticator));
if (wpa_auth == NULL)
return NULL;
- memcpy(wpa_auth->addr, addr, ETH_ALEN);
- memcpy(&wpa_auth->conf, conf, sizeof(*conf));
- memcpy(&wpa_auth->cb, cb, sizeof(*cb));
+ os_memcpy(wpa_auth->addr, addr, ETH_ALEN);
+ os_memcpy(&wpa_auth->conf, conf, sizeof(*conf));
+ os_memcpy(&wpa_auth->cb, cb, sizeof(*cb));
if (wpa_auth_gen_wpa_ie(wpa_auth)) {
wpa_printf(MSG_ERROR, "Could not generate WPA IE.");
- free(wpa_auth);
+ os_free(wpa_auth);
return NULL;
}
wpa_auth->group = wpa_group_init(wpa_auth, 0);
if (wpa_auth->group == NULL) {
- free(wpa_auth->wpa_ie);
- free(wpa_auth);
+ os_free(wpa_auth->wpa_ie);
+ os_free(wpa_auth);
return NULL;
}
wpa_auth->pmksa = pmksa_cache_init(wpa_auth_pmksa_free_cb, wpa_auth);
if (wpa_auth->pmksa == NULL) {
wpa_printf(MSG_ERROR, "PMKSA cache initialization failed.");
- free(wpa_auth->wpa_ie);
- free(wpa_auth);
+ os_free(wpa_auth->wpa_ie);
+ os_free(wpa_auth);
return NULL;
}
@@ -360,9 +360,9 @@ struct wpa_authenticator * wpa_init(const u8 *addr,
wpa_auth->ft_pmk_cache = wpa_ft_pmk_cache_init();
if (wpa_auth->ft_pmk_cache == NULL) {
wpa_printf(MSG_ERROR, "FT PMK cache initialization failed.");
- free(wpa_auth->wpa_ie);
+ os_free(wpa_auth->wpa_ie);
pmksa_cache_deinit(wpa_auth->pmksa);
- free(wpa_auth);
+ os_free(wpa_auth);
return NULL;
}
#endif /* CONFIG_IEEE80211R */
@@ -404,16 +404,16 @@ void wpa_deinit(struct wpa_authenticator *wpa_auth)
wpa_auth->ft_pmk_cache = NULL;
#endif /* CONFIG_IEEE80211R */
- free(wpa_auth->wpa_ie);
+ os_free(wpa_auth->wpa_ie);
group = wpa_auth->group;
while (group) {
prev = group;
group = group->next;
- free(prev);
+ os_free(prev);
}
- free(wpa_auth);
+ os_free(wpa_auth);
}
@@ -428,7 +428,7 @@ int wpa_reconfig(struct wpa_authenticator *wpa_auth,
if (wpa_auth == NULL)
return 0;
- memcpy(&wpa_auth->conf, conf, sizeof(*conf));
+ os_memcpy(&wpa_auth->conf, conf, sizeof(*conf));
/*
* TODO:
* Disassociate stations if configuration changed
@@ -446,7 +446,7 @@ wpa_auth_sta_init(struct wpa_authenticator *wpa_auth, const u8 *addr)
sm = os_zalloc(sizeof(struct wpa_state_machine));
if (sm == NULL)
return NULL;
- memcpy(sm->addr, addr, ETH_ALEN);
+ os_memcpy(sm->addr, addr, ETH_ALEN);
sm->wpa_auth = wpa_auth;
sm->group = wpa_auth->group;
@@ -471,7 +471,7 @@ void wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth,
#endif /* CONFIG_IEEE80211R */
if (sm->started) {
- memset(sm->key_replay_counter, 0, WPA_REPLAY_COUNTER_LEN);
+ os_memset(sm->key_replay_counter, 0, WPA_REPLAY_COUNTER_LEN);
sm->ReAuthenticationRequest = TRUE;
wpa_sm_step(sm);
return;
@@ -491,9 +491,9 @@ void wpa_auth_sta_associated(struct wpa_authenticator *wpa_auth,
static void wpa_free_sta_sm(struct wpa_state_machine *sm)
{
- free(sm->last_rx_eapol_key);
- free(sm->wpa_ie);
- free(sm);
+ os_free(sm->last_rx_eapol_key);
+ os_free(sm->wpa_ie);
+ os_free(sm);
}
@@ -622,8 +622,8 @@ void wpa_receive(struct wpa_authenticator *wpa_auth,
if (key_info & WPA_KEY_INFO_REQUEST) {
if (sm->req_replay_counter_used &&
- memcmp(key->replay_counter, sm->req_replay_counter,
- WPA_REPLAY_COUNTER_LEN) <= 0) {
+ os_memcmp(key->replay_counter, sm->req_replay_counter,
+ WPA_REPLAY_COUNTER_LEN) <= 0) {
wpa_auth_logger(wpa_auth, sm->addr, LOGGER_WARNING,
"received EAPOL-Key request with "
"replayed counter");
@@ -633,8 +633,8 @@ void wpa_receive(struct wpa_authenticator *wpa_auth,
if (!(key_info & WPA_KEY_INFO_REQUEST) &&
(!sm->key_replay_counter_valid ||
- memcmp(key->replay_counter, sm->key_replay_counter,
- WPA_REPLAY_COUNTER_LEN) != 0)) {
+ os_memcmp(key->replay_counter, sm->key_replay_counter,
+ WPA_REPLAY_COUNTER_LEN) != 0)) {
wpa_auth_vlogger(wpa_auth, sm->addr, LOGGER_INFO,
"received EAPOL-Key %s with unexpected "
"replay counter", msgtxt);
@@ -657,7 +657,7 @@ void wpa_receive(struct wpa_authenticator *wpa_auth,
}
if (sm->wpa_ie == NULL ||
sm->wpa_ie_len != key_data_length ||
- memcmp(sm->wpa_ie, key + 1, key_data_length) != 0) {
+ os_memcmp(sm->wpa_ie, key + 1, key_data_length) != 0) {
wpa_auth_logger(wpa_auth, sm->addr, LOGGER_INFO,
"WPA IE from (Re)AssocReq did not "
"match with msg 2/4");
@@ -747,8 +747,8 @@ void wpa_receive(struct wpa_authenticator *wpa_auth,
if (key_info & WPA_KEY_INFO_REQUEST) {
if (sm->MICVerified) {
sm->req_replay_counter_used = 1;
- memcpy(sm->req_replay_counter, key->replay_counter,
- WPA_REPLAY_COUNTER_LEN);
+ os_memcpy(sm->req_replay_counter, key->replay_counter,
+ WPA_REPLAY_COUNTER_LEN);
} else {
wpa_auth_logger(wpa_auth, sm->addr, LOGGER_INFO,
"received EAPOL-Key request with "
@@ -813,17 +813,17 @@ void wpa_receive(struct wpa_authenticator *wpa_auth,
}
#endif /* CONFIG_PEERKEY */
- free(sm->last_rx_eapol_key);
- sm->last_rx_eapol_key = malloc(data_len);
+ os_free(sm->last_rx_eapol_key);
+ sm->last_rx_eapol_key = os_malloc(data_len);
if (sm->last_rx_eapol_key == NULL)
return;
- memcpy(sm->last_rx_eapol_key, data, data_len);
+ os_memcpy(sm->last_rx_eapol_key, data, data_len);
sm->last_rx_eapol_key_len = data_len;
sm->EAPOLKeyReceived = TRUE;
sm->EAPOLKeyPairwise = !!(key_info & WPA_KEY_INFO_KEY_TYPE);
sm->EAPOLKeyRequest = !!(key_info & WPA_KEY_INFO_REQUEST);
- memcpy(sm->SNonce, key->key_nonce, WPA_NONCE_LEN);
+ os_memcpy(sm->SNonce, key->key_nonce, WPA_NONCE_LEN);
wpa_sm_step(sm);
}
@@ -834,8 +834,8 @@ static void wpa_gmk_to_gtk(const u8 *gmk, const u8 *addr, const u8 *gnonce,
u8 data[ETH_ALEN + WPA_NONCE_LEN];
/* GTK = PRF-X(GMK, "Group key expansion", AA || GNonce) */
- memcpy(data, addr, ETH_ALEN);
- memcpy(data + ETH_ALEN, gnonce, WPA_NONCE_LEN);
+ os_memcpy(data, addr, ETH_ALEN);
+ os_memcpy(data + ETH_ALEN, gnonce, WPA_NONCE_LEN);
sha1_prf(gmk, WPA_GMK_LEN, "Group key expansion",
data, sizeof(data), gtk, gtk_len);
@@ -942,27 +942,27 @@ void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
/* FIX: STSL: what to use as key_replay_counter? */
inc_byte_array(sm->key_replay_counter, WPA_REPLAY_COUNTER_LEN);
- memcpy(key->replay_counter, sm->key_replay_counter,
- WPA_REPLAY_COUNTER_LEN);
+ os_memcpy(key->replay_counter, sm->key_replay_counter,
+ WPA_REPLAY_COUNTER_LEN);
sm->key_replay_counter_valid = TRUE;
if (nonce)
- memcpy(key->key_nonce, nonce, WPA_NONCE_LEN);
+ os_memcpy(key->key_nonce, nonce, WPA_NONCE_LEN);
if (key_rsc)
- memcpy(key->key_rsc, key_rsc, WPA_KEY_RSC_LEN);
+ os_memcpy(key->key_rsc, key_rsc, WPA_KEY_RSC_LEN);
if (kde && !encr) {
- memcpy(key + 1, kde, kde_len);
+ os_memcpy(key + 1, kde, kde_len);
WPA_PUT_BE16(key->key_data_length, kde_len);
} else if (encr && kde) {
buf = os_zalloc(key_data_len);
if (buf == NULL) {
- free(hdr);
+ os_free(hdr);
return;
}
pos = buf;
- memcpy(pos, kde, kde_len);
+ os_memcpy(pos, kde, kde_len);
pos += kde_len;
if (pad_len)
@@ -977,16 +977,16 @@ void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
WPA_PUT_BE16(key->key_data_length, key_data_len);
} else {
u8 ek[32];
- memcpy(key->key_iv,
- sm->group->Counter + WPA_NONCE_LEN - 16, 16);
+ os_memcpy(key->key_iv,
+ sm->group->Counter + WPA_NONCE_LEN - 16, 16);
inc_byte_array(sm->group->Counter, WPA_NONCE_LEN);
- memcpy(ek, key->key_iv, 16);
- memcpy(ek + 16, sm->PTK.kek, 16);
- memcpy(key + 1, buf, key_data_len);
+ os_memcpy(ek, key->key_iv, 16);
+ os_memcpy(ek + 16, sm->PTK.kek, 16);
+ os_memcpy(key + 1, buf, key_data_len);
rc4_skip(ek, 32, 256, (u8 *) (key + 1), key_data_len);
WPA_PUT_BE16(key->key_data_length, key_data_len);
}
- free(buf);
+ os_free(buf);
}
if (key_info & WPA_KEY_INFO_MIC) {
@@ -994,7 +994,7 @@ void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
wpa_auth_logger(wpa_auth, sm->addr, LOGGER_DEBUG,
"PTK not valid when sending EAPOL-Key "
"frame");
- free(hdr);
+ os_free(hdr);
return;
}
wpa_eapol_key_mic(sm->PTK.kck, version, (u8 *) hdr, len,
@@ -1005,7 +1005,7 @@ void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
1);
wpa_auth_send_eapol(wpa_auth, sm->addr, (u8 *) hdr, len,
sm->pairwise_set);
- free(hdr);
+ os_free(hdr);
}
@@ -1045,13 +1045,13 @@ static int wpa_verify_key_mic(struct wpa_ptk *PTK, u8 *data, size_t data_len)
hdr = (struct ieee802_1x_hdr *) data;
key = (struct wpa_eapol_key *) (hdr + 1);
key_info = WPA_GET_BE16(key->key_info);
- memcpy(mic, key->key_mic, 16);
- memset(key->key_mic, 0, 16);
+ os_memcpy(mic, key->key_mic, 16);
+ os_memset(key->key_mic, 0, 16);
if (wpa_eapol_key_mic(PTK->kck, key_info & WPA_KEY_INFO_TYPE_MASK,
data, data_len, key->key_mic) ||
- memcmp(mic, key->key_mic, 16) != 0)
+ os_memcmp(mic, key->key_mic, 16) != 0)
ret = -1;
- memcpy(key->key_mic, mic, 16);
+ os_memcpy(key->key_mic, mic, 16);
return ret;
}
@@ -1059,7 +1059,7 @@ static int wpa_verify_key_mic(struct wpa_ptk *PTK, u8 *data, size_t data_len)
void wpa_remove_ptk(struct wpa_state_machine *sm)
{
sm->PTK_valid = FALSE;
- memset(&sm->PTK, 0, sizeof(sm->PTK));
+ os_memset(&sm->PTK, 0, sizeof(sm->PTK));
wpa_auth_set_key(sm->wpa_auth, 0, "none", sm->addr, 0, (u8 *) "", 0);
sm->pairwise_set = FALSE;
}
@@ -1100,7 +1100,7 @@ void wpa_auth_sm_event(struct wpa_state_machine *sm, wpa_event event)
#endif /* CONFIG_IEEE80211R */
sm->PTK_valid = FALSE;
- memset(&sm->PTK, 0, sizeof(sm->PTK));
+ os_memset(&sm->PTK, 0, sizeof(sm->PTK));
if (event != WPA_REAUTH_EAPOL)
wpa_remove_ptk(sm);
@@ -1190,7 +1190,7 @@ SM_STATE(WPA_PTK, AUTHENTICATION)
"increase GNoStations (STA " MACSTR ")",
MAC2STR(sm->addr));
}
- memset(&sm->PTK, 0, sizeof(sm->PTK));
+ os_memset(&sm->PTK, 0, sizeof(sm->PTK));
sm->PTK_valid = FALSE;
wpa_auth_set_eapol(sm->wpa_auth, sm->addr, WPA_EAPOL_portControl_Auto,
1);
@@ -1202,7 +1202,7 @@ SM_STATE(WPA_PTK, AUTHENTICATION)
SM_STATE(WPA_PTK, AUTHENTICATION2)
{
SM_ENTRY_MA(WPA_PTK, AUTHENTICATION2, wpa_ptk);
- memcpy(sm->ANonce, sm->group->Counter, WPA_NONCE_LEN);
+ os_memcpy(sm->ANonce, sm->group->Counter, WPA_NONCE_LEN);
inc_byte_array(sm->group->Counter, WPA_NONCE_LEN);
sm->ReAuthenticationRequest = FALSE;
/* IEEE 802.11i does not clear TimeoutCtr here, but this is more
@@ -1224,14 +1224,14 @@ SM_STATE(WPA_PTK, INITPMK)
#endif /* CONFIG_IEEE80211R */
if (sm->pmksa) {
wpa_printf(MSG_DEBUG, "WPA: PMK from PMKSA cache");
- memcpy(sm->PMK, sm->pmksa->pmk, PMK_LEN);
+ os_memcpy(sm->PMK, sm->pmksa->pmk, PMK_LEN);
} else if (wpa_auth_get_msk(sm->wpa_auth, sm->addr, msk, &len) == 0) {
wpa_printf(MSG_DEBUG, "WPA: PMK from EAPOL state machine "
"(len=%lu)", (unsigned long) len);
- memcpy(sm->PMK, msk, PMK_LEN);
+ os_memcpy(sm->PMK, msk, PMK_LEN);
#ifdef CONFIG_IEEE80211R
if (len >= 2 * PMK_LEN) {
- memcpy(sm->xxkey, msk + PMK_LEN, PMK_LEN);
+ os_memcpy(sm->xxkey, msk + PMK_LEN, PMK_LEN);
sm->xxkey_len = PMK_LEN;
}
#endif /* CONFIG_IEEE80211R */
@@ -1258,9 +1258,9 @@ SM_STATE(WPA_PTK, INITPSK)
SM_ENTRY_MA(WPA_PTK, INITPSK, wpa_ptk);
psk = wpa_auth_get_psk(sm->wpa_auth, sm->addr, NULL);
if (psk) {
- memcpy(sm->PMK, psk, PMK_LEN);
+ os_memcpy(sm->PMK, psk, PMK_LEN);
#ifdef CONFIG_IEEE80211R
- memcpy(sm->xxkey, psk, PMK_LEN);
+ os_memcpy(sm->xxkey, psk, PMK_LEN);
sm->xxkey_len = PMK_LEN;
#endif /* CONFIG_IEEE80211R */
}
@@ -1290,8 +1290,8 @@ SM_STATE(WPA_PTK, PTKSTART)
pmkid[1] = RSN_SELECTOR_LEN + PMKID_LEN;
RSN_SELECTOR_PUT(&pmkid[2], RSN_KEY_DATA_PMKID);
if (sm->pmksa)
- memcpy(&pmkid[2 + RSN_SELECTOR_LEN], sm->pmksa->pmkid,
- PMKID_LEN);
+ os_memcpy(&pmkid[2 + RSN_SELECTOR_LEN],
+ sm->pmksa->pmkid, PMKID_LEN);
else {
/*
* Calculate PMKID since no PMKSA cache entry was
@@ -1372,12 +1372,12 @@ SM_STATE(WPA_PTK, PTKCALCNEGOTIATING)
/* PSK may have changed from the previous choice, so update
* state machine data based on whatever PSK was selected here.
*/
- memcpy(sm->PMK, pmk, PMK_LEN);
+ os_memcpy(sm->PMK, pmk, PMK_LEN);
}
sm->MICVerified = TRUE;
- memcpy(&sm->PTK, &PTK, sizeof(PTK));
+ os_memcpy(&sm->PTK, &PTK, sizeof(PTK));
sm->PTK_valid = TRUE;
}
@@ -1413,8 +1413,8 @@ static u8 * ieee80211w_kde_add(struct wpa_state_machine *sm, u8 *pos)
igtk.keyid[1] = 0;
if (wpa_auth_get_seqnum_igtk(sm->wpa_auth, NULL, gsm->GN_igtk, igtk.pn)
< 0)
- memset(igtk.pn, 0, sizeof(igtk.pn));
- memcpy(igtk.igtk, gsm->IGTK[gsm->GN_igtk - 4], WPA_IGTK_LEN);
+ os_memset(igtk.pn, 0, sizeof(igtk.pn));
+ os_memcpy(igtk.igtk, gsm->IGTK[gsm->GN_igtk - 4], WPA_IGTK_LEN);
pos = wpa_add_kde(pos, RSN_KEY_DATA_IGTK,
(const u8 *) &igtk, sizeof(igtk), NULL, 0);
@@ -1449,7 +1449,7 @@ SM_STATE(WPA_PTK, PTKINITNEGOTIATING)
sm->TimeoutEvt = FALSE;
/* Send EAPOL(1, 1, 1, Pair, P, RSC, ANonce, MIC(PTK), RSNIE, GTK[GN])
*/
- memset(rsc, 0, WPA_KEY_RSC_LEN);
+ os_memset(rsc, 0, WPA_KEY_RSC_LEN);
wpa_auth_get_seqnum(sm->wpa_auth, NULL, gsm->GN, rsc);
wpa_ie = sm->wpa_auth->wpa_ie;
wpa_ie_len = sm->wpa_auth->wpa_ie_len;
@@ -1482,12 +1482,12 @@ SM_STATE(WPA_PTK, PTKINITNEGOTIATING)
kde_len = wpa_ie_len + ieee80211w_kde_len(sm);
if (gtk)
kde_len += 2 + RSN_SELECTOR_LEN + 2 + gtk_len;
- kde = malloc(kde_len);
+ kde = os_malloc(kde_len);
if (kde == NULL)
return;
pos = kde;
- memcpy(pos, wpa_ie, wpa_ie_len);
+ os_memcpy(pos, wpa_ie, wpa_ie_len);
pos += wpa_ie_len;
if (gtk) {
u8 hdr[2];
@@ -1503,7 +1503,7 @@ SM_STATE(WPA_PTK, PTKINITNEGOTIATING)
WPA_KEY_INFO_ACK | WPA_KEY_INFO_INSTALL |
WPA_KEY_INFO_KEY_TYPE,
_rsc, sm->ANonce, kde, pos - kde, keyidx, encr);
- free(kde);
+ os_free(kde);
sm->TimeoutCtr++;
}
@@ -1686,7 +1686,7 @@ SM_STATE(WPA_PTK_GROUP, REKEYNEGOTIATING)
sm->PInitAKeys = FALSE;
sm->TimeoutEvt = FALSE;
/* Send EAPOL(1, 1, 1, !Pair, G, RSC, GNonce, MIC(PTK), GTK[GN]) */
- memset(rsc, 0, WPA_KEY_RSC_LEN);
+ os_memset(rsc, 0, WPA_KEY_RSC_LEN);
if (gsm->wpa_group_state == WPA_GROUP_SETKEYSDONE)
wpa_auth_get_seqnum(sm->wpa_auth, NULL, gsm->GN, rsc);
wpa_auth_logger(sm->wpa_auth, sm->addr, LOGGER_DEBUG,
@@ -1695,7 +1695,7 @@ SM_STATE(WPA_PTK_GROUP, REKEYNEGOTIATING)
if (sm->wpa == WPA_VERSION_WPA2) {
kde_len = 2 + RSN_SELECTOR_LEN + 2 + gsm->GTK_len +
ieee80211w_kde_len(sm);
- kde = malloc(kde_len);
+ kde = os_malloc(kde_len);
if (kde == NULL)
return;
@@ -1716,7 +1716,7 @@ SM_STATE(WPA_PTK_GROUP, REKEYNEGOTIATING)
(!sm->Pair ? WPA_KEY_INFO_INSTALL : 0),
rsc, gsm->GNonce, kde, pos - kde, gsm->GN, 1);
if (sm->wpa == WPA_VERSION_WPA2)
- free(kde);
+ os_free(kde);
sm->GTimeoutCtr++;
}
@@ -1781,7 +1781,7 @@ static int wpa_gtk_update(struct wpa_authenticator *wpa_auth,
int ret = 0;
/* FIX: is this the correct way of getting GNonce? */
- memcpy(group->GNonce, group->Counter, WPA_NONCE_LEN);
+ os_memcpy(group->GNonce, group->Counter, WPA_NONCE_LEN);
inc_byte_array(group->Counter, WPA_NONCE_LEN);
wpa_gmk_to_gtk(group->GMK, wpa_auth->addr, group->GNonce,
group->GTK[group->GN - 1], group->GTK_len);
@@ -1812,7 +1812,7 @@ static void wpa_group_gtk_init(struct wpa_authenticator *wpa_auth,
group->wpa_group_state = WPA_GROUP_GTK_INIT;
/* GTK[0..N] = 0 */
- memset(group->GTK, 0, sizeof(group->GTK));
+ os_memset(group->GTK, 0, sizeof(group->GTK));
group->GN = 1;
group->GM = 2;
#ifdef CONFIG_IEEE80211W
@@ -2013,17 +2013,17 @@ int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen)
if (wpa_auth == NULL)
return len;
- ret = snprintf(buf + len, buflen - len,
- "dot11RSNAOptionImplemented=TRUE\n"
+ ret = os_snprintf(buf + len, buflen - len,
+ "dot11RSNAOptionImplemented=TRUE\n"
#ifdef CONFIG_RSN_PREAUTH
- "dot11RSNAPreauthenticationImplemented=TRUE\n"
+ "dot11RSNAPreauthenticationImplemented=TRUE\n"
#else /* CONFIG_RSN_PREAUTH */
- "dot11RSNAPreauthenticationImplemented=FALSE\n"
+ "dot11RSNAPreauthenticationImplemented=FALSE\n"
#endif /* CONFIG_RSN_PREAUTH */
- "dot11RSNAEnabled=%s\n"
- "dot11RSNAPreauthenticationEnabled=%s\n",
- wpa_bool_txt(wpa_auth->conf.wpa & WPA_PROTO_RSN),
- wpa_bool_txt(wpa_auth->conf.rsn_preauth));
+ "dot11RSNAEnabled=%s\n"
+ "dot11RSNAPreauthenticationEnabled=%s\n",
+ wpa_bool_txt(wpa_auth->conf.wpa & WPA_PROTO_RSN),
+ wpa_bool_txt(wpa_auth->conf.rsn_preauth));
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
@@ -2031,52 +2031,49 @@ int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen)
wpa_snprintf_hex(pmkid_txt, sizeof(pmkid_txt),
wpa_auth->dot11RSNAPMKIDUsed, PMKID_LEN);
- ret = snprintf(buf + len, buflen - len,
- "dot11RSNAConfigVersion=%u\n"
- "dot11RSNAConfigPairwiseKeysSupported=9999\n"
- /* FIX: dot11RSNAConfigGroupCipher */
- /* FIX: dot11RSNAConfigGroupRekeyMethod */
- /* FIX: dot11RSNAConfigGroupRekeyTime */
- /* FIX: dot11RSNAConfigGroupRekeyPackets */
- "dot11RSNAConfigGroupRekeyStrict=%u\n"
- "dot11RSNAConfigGroupUpdateCount=%u\n"
- "dot11RSNAConfigPairwiseUpdateCount=%u\n"
- "dot11RSNAConfigGroupCipherSize=%u\n"
- "dot11RSNAConfigPMKLifetime=%u\n"
- "dot11RSNAConfigPMKReauthThreshold=%u\n"
- "dot11RSNAConfigNumberOfPTKSAReplayCounters=0\n"
- "dot11RSNAConfigSATimeout=%u\n"
- "dot11RSNAAuthenticationSuiteSelected=" RSN_SUITE "\n"
- "dot11RSNAPairwiseCipherSelected=" RSN_SUITE "\n"
- "dot11RSNAGroupCipherSelected=" RSN_SUITE "\n"
- "dot11RSNAPMKIDUsed=%s\n"
- "dot11RSNAAuthenticationSuiteRequested=" RSN_SUITE "\n"
- "dot11RSNAPairwiseCipherRequested=" RSN_SUITE "\n"
- "dot11RSNAGroupCipherRequested=" RSN_SUITE "\n"
- "dot11RSNATKIPCounterMeasuresInvoked=%u\n"
- "dot11RSNA4WayHandshakeFailures=%u\n"
- "dot11RSNAConfigNumberOfGTKSAReplayCounters=0\n",
- RSN_VERSION,
- !!wpa_auth->conf.wpa_strict_rekey,
- dot11RSNAConfigGroupUpdateCount,
- dot11RSNAConfigPairwiseUpdateCount,
- wpa_cipher_bits(wpa_auth->conf.wpa_group),
- dot11RSNAConfigPMKLifetime,
- dot11RSNAConfigPMKReauthThreshold,
- dot11RSNAConfigSATimeout,
- RSN_SUITE_ARG(wpa_auth->
- dot11RSNAAuthenticationSuiteSelected),
- RSN_SUITE_ARG(wpa_auth->
- dot11RSNAPairwiseCipherSelected),
- RSN_SUITE_ARG(wpa_auth->dot11RSNAGroupCipherSelected),
- pmkid_txt,
- RSN_SUITE_ARG(wpa_auth->
- dot11RSNAAuthenticationSuiteRequested),
- RSN_SUITE_ARG(wpa_auth->
- dot11RSNAPairwiseCipherRequested),
- RSN_SUITE_ARG(wpa_auth->dot11RSNAGroupCipherRequested),
- wpa_auth->dot11RSNATKIPCounterMeasuresInvoked,
- wpa_auth->dot11RSNA4WayHandshakeFailures);
+ ret = os_snprintf(
+ buf + len, buflen - len,
+ "dot11RSNAConfigVersion=%u\n"
+ "dot11RSNAConfigPairwiseKeysSupported=9999\n"
+ /* FIX: dot11RSNAConfigGroupCipher */
+ /* FIX: dot11RSNAConfigGroupRekeyMethod */
+ /* FIX: dot11RSNAConfigGroupRekeyTime */
+ /* FIX: dot11RSNAConfigGroupRekeyPackets */
+ "dot11RSNAConfigGroupRekeyStrict=%u\n"
+ "dot11RSNAConfigGroupUpdateCount=%u\n"
+ "dot11RSNAConfigPairwiseUpdateCount=%u\n"
+ "dot11RSNAConfigGroupCipherSize=%u\n"
+ "dot11RSNAConfigPMKLifetime=%u\n"
+ "dot11RSNAConfigPMKReauthThreshold=%u\n"
+ "dot11RSNAConfigNumberOfPTKSAReplayCounters=0\n"
+ "dot11RSNAConfigSATimeout=%u\n"
+ "dot11RSNAAuthenticationSuiteSelected=" RSN_SUITE "\n"
+ "dot11RSNAPairwiseCipherSelected=" RSN_SUITE "\n"
+ "dot11RSNAGroupCipherSelected=" RSN_SUITE "\n"
+ "dot11RSNAPMKIDUsed=%s\n"
+ "dot11RSNAAuthenticationSuiteRequested=" RSN_SUITE "\n"
+ "dot11RSNAPairwiseCipherRequested=" RSN_SUITE "\n"
+ "dot11RSNAGroupCipherRequested=" RSN_SUITE "\n"
+ "dot11RSNATKIPCounterMeasuresInvoked=%u\n"
+ "dot11RSNA4WayHandshakeFailures=%u\n"
+ "dot11RSNAConfigNumberOfGTKSAReplayCounters=0\n",
+ RSN_VERSION,
+ !!wpa_auth->conf.wpa_strict_rekey,
+ dot11RSNAConfigGroupUpdateCount,
+ dot11RSNAConfigPairwiseUpdateCount,
+ wpa_cipher_bits(wpa_auth->conf.wpa_group),
+ dot11RSNAConfigPMKLifetime,
+ dot11RSNAConfigPMKReauthThreshold,
+ dot11RSNAConfigSATimeout,
+ RSN_SUITE_ARG(wpa_auth->dot11RSNAAuthenticationSuiteSelected),
+ RSN_SUITE_ARG(wpa_auth->dot11RSNAPairwiseCipherSelected),
+ RSN_SUITE_ARG(wpa_auth->dot11RSNAGroupCipherSelected),
+ pmkid_txt,
+ RSN_SUITE_ARG(wpa_auth->dot11RSNAAuthenticationSuiteRequested),
+ RSN_SUITE_ARG(wpa_auth->dot11RSNAPairwiseCipherRequested),
+ RSN_SUITE_ARG(wpa_auth->dot11RSNAGroupCipherRequested),
+ wpa_auth->dot11RSNATKIPCounterMeasuresInvoked,
+ wpa_auth->dot11RSNA4WayHandshakeFailures);
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
@@ -2085,8 +2082,8 @@ int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen)
/* TODO: dot11RSNAConfigAuthenticationSuitesTable */
/* Private MIB */
- ret = snprintf(buf + len, buflen - len, "hostapdWPAGroupState=%d\n",
- wpa_auth->group->wpa_group_state);
+ ret = os_snprintf(buf + len, buflen - len, "hostapdWPAGroupState=%d\n",
+ wpa_auth->group->wpa_group_state);
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
@@ -2132,31 +2129,32 @@ int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen)
} else
return 0;
- ret = snprintf(buf + len, buflen - len,
- /* TODO: dot11RSNAStatsIndex */
- "dot11RSNAStatsSTAAddress=" MACSTR "\n"
- "dot11RSNAStatsVersion=1\n"
- "dot11RSNAStatsSelectedPairwiseCipher=" RSN_SUITE "\n"
- /* TODO: dot11RSNAStatsTKIPICVErrors */
- "dot11RSNAStatsTKIPLocalMICFailures=%u\n"
- "dot11RSNAStatsTKIPRemoveMICFailures=%u\n"
- /* TODO: dot11RSNAStatsCCMPReplays */
- /* TODO: dot11RSNAStatsCCMPDecryptErrors */
- /* TODO: dot11RSNAStatsTKIPReplays */,
- MAC2STR(sm->addr),
- RSN_SUITE_ARG(pairwise),
- sm->dot11RSNAStatsTKIPLocalMICFailures,
- sm->dot11RSNAStatsTKIPRemoteMICFailures);
+ ret = os_snprintf(
+ buf + len, buflen - len,
+ /* TODO: dot11RSNAStatsIndex */
+ "dot11RSNAStatsSTAAddress=" MACSTR "\n"
+ "dot11RSNAStatsVersion=1\n"
+ "dot11RSNAStatsSelectedPairwiseCipher=" RSN_SUITE "\n"
+ /* TODO: dot11RSNAStatsTKIPICVErrors */
+ "dot11RSNAStatsTKIPLocalMICFailures=%u\n"
+ "dot11RSNAStatsTKIPRemoveMICFailures=%u\n"
+ /* TODO: dot11RSNAStatsCCMPReplays */
+ /* TODO: dot11RSNAStatsCCMPDecryptErrors */
+ /* TODO: dot11RSNAStatsTKIPReplays */,
+ MAC2STR(sm->addr),
+ RSN_SUITE_ARG(pairwise),
+ sm->dot11RSNAStatsTKIPLocalMICFailures,
+ sm->dot11RSNAStatsTKIPRemoteMICFailures);
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
/* Private MIB */
- ret = snprintf(buf + len, buflen - len,
- "hostapdWPAPTKState=%d\n"
- "hostapdWPAPTKGroupState=%d\n",
- sm->wpa_ptk_state,
- sm->wpa_ptk_group_state);
+ ret = os_snprintf(buf + len, buflen - len,
+ "hostapdWPAPTKState=%d\n"
+ "hostapdWPAPTKGroupState=%d\n",
+ sm->wpa_ptk_state,
+ sm->wpa_ptk_group_state);
if (ret < 0 || (size_t) ret >= buflen - len)
return len;
len += ret;
diff --git a/hostapd/wpa_ft.c b/hostapd/wpa_ft.c
index 7fa4af3..2a467a4 100644
--- a/hostapd/wpa_ft.c
+++ b/hostapd/wpa_ft.c
@@ -554,7 +554,7 @@ static int wpa_ft_parse_ies(const u8 *ies, size_t ies_len,
struct wpa_ie_data data;
int ret;
- memset(parse, 0, sizeof(*parse));
+ os_memset(parse, 0, sizeof(*parse));
if (ies == NULL)
return 0;
@@ -677,7 +677,7 @@ static u16 wpa_ft_process_auth_req(struct wpa_state_machine *sm,
return WLAN_STATUS_INVALID_FTIE;
}
- memcpy(sm->SNonce, ftie->snonce, WPA_NONCE_LEN);
+ os_memcpy(sm->SNonce, ftie->snonce, WPA_NONCE_LEN);
if (parse.r0kh_id == NULL) {
wpa_printf(MSG_DEBUG, "FT: Invalid FTIE - no R0KH-ID");
@@ -686,7 +686,7 @@ static u16 wpa_ft_process_auth_req(struct wpa_state_machine *sm,
wpa_hexdump(MSG_DEBUG, "FT: STA R0KH-ID",
parse.r0kh_id, parse.r0kh_id_len);
- memcpy(sm->r0kh_id, parse.r0kh_id, parse.r0kh_id_len);
+ os_memcpy(sm->r0kh_id, parse.r0kh_id, parse.r0kh_id_len);
sm->r0kh_id_len = parse.r0kh_id_len;
if (parse.rsn_pmkid == NULL) {
diff --git a/src/eap_server/eap.c b/src/eap_server/eap.c
index 04a78a5..567ecec 100644
--- a/src/eap_server/eap.c
+++ b/src/eap_server/eap.c
@@ -127,7 +127,7 @@ SM_STATE(EAP, INITIALIZE)
sm->eap_if.eapSuccess = FALSE;
sm->eap_if.eapFail = FALSE;
sm->eap_if.eapTimeout = FALSE;
- free(sm->eap_if.eapKeyData);
+ os_free(sm->eap_if.eapKeyData);
sm->eap_if.eapKeyData = NULL;
sm->eap_if.eapKeyDataLen = 0;
sm->eap_if.eapKeyAvailable = FALSE;
@@ -276,7 +276,7 @@ SM_STATE(EAP, METHOD_REQUEST)
wpa_printf(MSG_DEBUG, "EAP: building EAP-Request: Identifier %d",
sm->currentId);
sm->lastId = sm->currentId;
- free(sm->eap_if.eapReqData);
+ os_free(sm->eap_if.eapReqData);
sm->eap_if.eapReqData = sm->m->buildReq(sm, sm->eap_method_priv,
sm->currentId,
&sm->eap_if.eapReqDataLen);
@@ -295,7 +295,7 @@ SM_STATE(EAP, METHOD_RESPONSE)
sm->eap_if.eapRespDataLen);
if (sm->m->isDone(sm, sm->eap_method_priv)) {
eap_sm_Policy_update(sm, NULL, 0);
- free(sm->eap_if.eapKeyData);
+ os_free(sm->eap_if.eapKeyData);
if (sm->m->getKey) {
sm->eap_if.eapKeyData = sm->m->getKey(
sm, sm->eap_method_priv,
@@ -396,10 +396,10 @@ SM_STATE(EAP, FAILURE)
{
SM_ENTRY(EAP, FAILURE);
- free(sm->eap_if.eapReqData);
+ os_free(sm->eap_if.eapReqData);
sm->eap_if.eapReqData = eap_sm_buildFailure(sm, sm->currentId,
&sm->eap_if.eapReqDataLen);
- free(sm->lastReqData);
+ os_free(sm->lastReqData);
sm->lastReqData = NULL;
sm->lastReqDataLen = 0;
sm->eap_if.eapFail = TRUE;
@@ -410,10 +410,10 @@ SM_STATE(EAP, SUCCESS)
{
SM_ENTRY(EAP, SUCCESS);
- free(sm->eap_if.eapReqData);
+ os_free(sm->eap_if.eapReqData);
sm->eap_if.eapReqData = eap_sm_buildSuccess(sm, sm->currentId,
&sm->eap_if.eapReqDataLen);
- free(sm->lastReqData);
+ os_free(sm->lastReqData);
sm->lastReqData = NULL;
sm->lastReqDataLen = 0;
if (sm->eap_if.eapKeyData)
@@ -870,7 +870,7 @@ static u8 * eap_sm_buildSuccess(struct eap_sm *sm, int id, size_t *len)
wpa_printf(MSG_DEBUG, "EAP: Building EAP-Success (id=%d)", id);
*len = sizeof(*resp);
- resp = malloc(*len);
+ resp = os_malloc(*len);
if (resp == NULL)
return NULL;
resp->code = EAP_CODE_SUCCESS;
@@ -887,7 +887,7 @@ static u8 * eap_sm_buildFailure(struct eap_sm *sm, int id, size_t *len)
wpa_printf(MSG_DEBUG, "EAP: Building EAP-Failure (id=%d)", id);
*len = sizeof(*resp);
- resp = malloc(*len);
+ resp = os_malloc(*len);
if (resp == NULL)
return NULL;
resp->code = EAP_CODE_FAILURE;
@@ -957,9 +957,9 @@ void eap_sm_process_nak(struct eap_sm *sm, u8 *nak_list, size_t len)
not_found:
/* not found - remove from the list */
- memmove(&sm->user->methods[i], &sm->user->methods[i + 1],
- (EAP_MAX_METHODS - i - 1) *
- sizeof(sm->user->methods[0]));
+ os_memmove(&sm->user->methods[i], &sm->user->methods[i + 1],
+ (EAP_MAX_METHODS - i - 1) *
+ sizeof(sm->user->methods[0]));
sm->user->methods[EAP_MAX_METHODS - 1].vendor =
EAP_VENDOR_IETF;
sm->user->methods[EAP_MAX_METHODS - 1].method = EAP_TYPE_NONE;
@@ -1105,9 +1105,9 @@ static void eap_user_free(struct eap_user *user)
{
if (user == NULL)
return;
- free(user->password);
+ os_free(user->password);
user->password = NULL;
- free(user);
+ os_free(user);
}
@@ -1144,7 +1144,7 @@ struct eap_sm * eap_server_sm_init(void *eapol_ctx,
}
}
if (conf->eap_fast_a_id)
- sm->eap_fast_a_id = strdup(conf->eap_fast_a_id);
+ sm->eap_fast_a_id = os_strdup(conf->eap_fast_a_id);
wpa_printf(MSG_DEBUG, "EAP: Server state machine created");
@@ -1166,18 +1166,18 @@ void eap_server_sm_deinit(struct eap_sm *sm)
wpa_printf(MSG_DEBUG, "EAP: Server state machine removed");
if (sm->m && sm->eap_method_priv)
sm->m->reset(sm, sm->eap_method_priv);
- free(sm->eap_if.eapReqData);
- free(sm->eap_if.eapKeyData);
- free(sm->lastReqData);
- free(sm->eap_if.eapRespData);
- free(sm->identity);
- free(sm->pac_opaque_encr_key);
- free(sm->eap_fast_a_id);
- free(sm->eap_if.aaaEapReqData);
- free(sm->eap_if.aaaEapRespData);
- free(sm->eap_if.aaaEapKeyData);
+ os_free(sm->eap_if.eapReqData);
+ os_free(sm->eap_if.eapKeyData);
+ os_free(sm->lastReqData);
+ os_free(sm->eap_if.eapRespData);
+ os_free(sm->identity);
+ os_free(sm->pac_opaque_encr_key);
+ os_free(sm->eap_fast_a_id);
+ os_free(sm->eap_if.aaaEapReqData);
+ os_free(sm->eap_if.aaaEapRespData);
+ os_free(sm->eap_if.aaaEapKeyData);
eap_user_free(sm->user);
- free(sm);
+ os_free(sm);
}
diff --git a/src/eap_server/eap_aka.c b/src/eap_server/eap_aka.c
index 6a2db0a..4fe4065 100644
--- a/src/eap_server/eap_aka.c
+++ b/src/eap_server/eap_aka.c
@@ -103,9 +103,9 @@ static void * eap_aka_init(struct eap_sm *sm)
static void eap_aka_reset(struct eap_sm *sm, void *priv)
{
struct eap_aka_data *data = priv;
- free(data->next_pseudonym);
- free(data->next_reauth_id);
- free(data);
+ os_free(data->next_pseudonym);
+ os_free(data->next_reauth_id);
+ os_free(data);
}
@@ -131,10 +131,10 @@ static int eap_aka_build_encr(struct eap_sm *sm, struct eap_aka_data *data,
struct eap_sim_msg *msg, u16 counter,
const u8 *nonce_s)
{
- free(data->next_pseudonym);
+ os_free(data->next_pseudonym);
data->next_pseudonym =
eap_sim_db_get_next_pseudonym(sm->eap_sim_db_priv, 1);
- free(data->next_reauth_id);
+ os_free(data->next_reauth_id);
if (data->counter <= EAP_AKA_MAX_FAST_REAUTHS) {
data->next_reauth_id =
eap_sim_db_get_next_reauth_id(sm->eap_sim_db_priv, 1);
@@ -167,18 +167,18 @@ static int eap_aka_build_encr(struct eap_sm *sm, struct eap_aka_data *data,
wpa_printf(MSG_DEBUG, " *AT_NEXT_PSEUDONYM (%s)",
data->next_pseudonym);
eap_sim_msg_add(msg, EAP_SIM_AT_NEXT_PSEUDONYM,
- strlen(data->next_pseudonym),
+ os_strlen(data->next_pseudonym),
(u8 *) data->next_pseudonym,
- strlen(data->next_pseudonym));
+ os_strlen(data->next_pseudonym));
}
if (data->next_reauth_id) {
wpa_printf(MSG_DEBUG, " *AT_NEXT_REAUTH_ID (%s)",
data->next_reauth_id);
eap_sim_msg_add(msg, EAP_SIM_AT_NEXT_REAUTH_ID,
- strlen(data->next_reauth_id),
+ os_strlen(data->next_reauth_id),
(u8 *) data->next_reauth_id,
- strlen(data->next_reauth_id));
+ os_strlen(data->next_reauth_id));
}
if (eap_sim_msg_add_encr_end(msg, data->k_encr, EAP_SIM_AT_PADDING)) {
@@ -385,8 +385,8 @@ static void eap_aka_determine_identity(struct eap_sm *sm,
identity = data->reauth->identity;
identity_len = data->reauth->identity_len;
data->counter = data->reauth->counter;
- memcpy(data->mk, data->reauth->mk,
- EAP_SIM_MK_LEN);
+ os_memcpy(data->mk, data->reauth->mk,
+ EAP_SIM_MK_LEN);
}
}
}
@@ -471,11 +471,11 @@ static void eap_aka_process_identity(struct eap_sm *sm,
}
if (attr->identity) {
- free(sm->identity);
- sm->identity = malloc(attr->identity_len);
+ os_free(sm->identity);
+ sm->identity = os_malloc(attr->identity_len);
if (sm->identity) {
- memcpy(sm->identity, attr->identity,
- attr->identity_len);
+ os_memcpy(sm->identity, attr->identity,
+ attr->identity_len);
sm->identity_len = attr->identity_len;
}
}
@@ -505,7 +505,7 @@ static void eap_aka_process_challenge(struct eap_sm *sm,
}
if (attr->res == NULL || attr->res_len != data->res_len ||
- memcmp(attr->res, data->res, data->res_len) != 0) {
+ os_memcmp(attr->res, data->res, data->res_len) != 0) {
wpa_printf(MSG_WARNING, "EAP-AKA: Challenge message did not "
"include valid AT_RES");
data->notification = EAP_SIM_GENERAL_FAILURE_BEFORE_AUTH;
@@ -615,7 +615,7 @@ static void eap_aka_process_reauth(struct eap_sm *sm,
eattr.counter, data->counter);
goto fail;
}
- free(decrypted);
+ os_free(decrypted);
decrypted = NULL;
wpa_printf(MSG_DEBUG, "EAP-AKA: Re-authentication response includes "
@@ -668,7 +668,7 @@ fail:
eap_aka_state(data, NOTIFICATION);
eap_sim_db_remove_reauth(sm->eap_sim_db_priv, data->reauth);
data->reauth = NULL;
- free(decrypted);
+ os_free(decrypted);
}
@@ -786,10 +786,10 @@ static u8 * eap_aka_getKey(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_SIM_KEYING_DATA_LEN);
+ key = os_malloc(EAP_SIM_KEYING_DATA_LEN);
if (key == NULL)
return NULL;
- memcpy(key, data->msk, EAP_SIM_KEYING_DATA_LEN);
+ os_memcpy(key, data->msk, EAP_SIM_KEYING_DATA_LEN);
*len = EAP_SIM_KEYING_DATA_LEN;
return key;
}
@@ -803,10 +803,10 @@ static u8 * eap_aka_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_EMSK_LEN);
+ key = os_malloc(EAP_EMSK_LEN);
if (key == NULL)
return NULL;
- memcpy(key, data->emsk, EAP_EMSK_LEN);
+ os_memcpy(key, data->emsk, EAP_EMSK_LEN);
*len = EAP_EMSK_LEN;
return key;
}
diff --git a/src/eap_server/eap_fast.c b/src/eap_server/eap_fast.c
index 00436a8..d761777 100644
--- a/src/eap_server/eap_fast.c
+++ b/src/eap_server/eap_fast.c
@@ -513,8 +513,8 @@ static void eap_fast_reset(struct eap_sm *sm, void *priv)
if (data->phase2_priv && data->phase2_method)
data->phase2_method->reset(sm, data->phase2_priv);
eap_server_tls_ssl_deinit(sm, &data->ssl);
- free(data->srv_id);
- free(data);
+ os_free(data->srv_id);
+ os_free(data);
}
@@ -527,7 +527,7 @@ static u8 * eap_fast_build_start(struct eap_sm *sm, struct eap_fast_data *data,
size_t srv_id_len = os_strlen(data->srv_id);
*reqDataLen = sizeof(*req) + 2 + sizeof(*a_id) + srv_id_len;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-FAST: Failed to allocate memory for"
" request");
@@ -614,7 +614,7 @@ static u8 * eap_fast_encrypt(struct eap_sm *sm, struct eap_fast_data *data,
/* TODO: add support for fragmentation, if needed. This will need to
* add TLS Message Length field, if the frame is fragmented. */
- req = malloc(sizeof(struct eap_hdr) + 2 + data->ssl.tls_out_limit);
+ req = os_malloc(sizeof(struct eap_hdr) + 2 + data->ssl.tls_out_limit);
if (req == NULL)
return NULL;
@@ -631,7 +631,7 @@ static u8 * eap_fast_encrypt(struct eap_sm *sm, struct eap_fast_data *data,
if (res < 0) {
wpa_printf(MSG_INFO, "EAP-FAST: Failed to encrypt Phase 2 "
"data");
- free(req);
+ os_free(req);
return NULL;
}
@@ -919,7 +919,7 @@ static u8 * eap_fast_buildReq(struct eap_sm *sm, void *priv, int id,
wpa_hexdump_key(MSG_DEBUG, "EAP-FAST: Encrypting Phase 2 TLVs",
(u8 *) req, req_len);
encr = eap_fast_encrypt(sm, data, id, req, req_len, reqDataLen);
- free(req);
+ os_free(req);
return encr;
}
@@ -1483,9 +1483,9 @@ static void eap_fast_process_phase2(struct eap_sm *sm,
buf_len = in_len;
if (data->ssl.tls_in_total > buf_len)
buf_len = data->ssl.tls_in_total;
- in_decrypted = malloc(buf_len);
+ in_decrypted = os_malloc(buf_len);
if (in_decrypted == NULL) {
- free(data->ssl.tls_in);
+ os_free(data->ssl.tls_in);
data->ssl.tls_in = NULL;
data->ssl.tls_in_len = 0;
wpa_printf(MSG_WARNING, "EAP-FAST: Failed to allocate memory "
@@ -1496,13 +1496,13 @@ static void eap_fast_process_phase2(struct eap_sm *sm,
len_decrypted = tls_connection_decrypt(sm->ssl_ctx, data->ssl.conn,
in_data, in_len,
in_decrypted, buf_len);
- free(data->ssl.tls_in);
+ os_free(data->ssl.tls_in);
data->ssl.tls_in = NULL;
data->ssl.tls_in_len = 0;
if (len_decrypted < 0) {
wpa_printf(MSG_INFO, "EAP-FAST: Failed to decrypt Phase 2 "
"data");
- free(in_decrypted);
+ os_free(in_decrypted);
eap_fast_state(data, FAILURE);
return;
}
@@ -1512,7 +1512,7 @@ static void eap_fast_process_phase2(struct eap_sm *sm,
eap_fast_process_phase2_tlvs(sm, data, in_decrypted, len_decrypted);
- free(in_decrypted);
+ os_free(in_decrypted);
}
@@ -1560,7 +1560,7 @@ static void eap_fast_process(struct eap_sm *sm, void *priv,
if (data->ssl.tls_in_left == 0) {
data->ssl.tls_in_total = tls_msg_len;
data->ssl.tls_in_left = tls_msg_len;
- free(data->ssl.tls_in);
+ os_free(data->ssl.tls_in);
data->ssl.tls_in = NULL;
data->ssl.tls_in_len = 0;
}
diff --git a/src/eap_server/eap_gpsk.c b/src/eap_server/eap_gpsk.c
index 8c8d367..a57d5df 100644
--- a/src/eap_server/eap_gpsk.c
+++ b/src/eap_server/eap_gpsk.c
@@ -77,9 +77,9 @@ static void * eap_gpsk_init(struct eap_sm *sm)
data->state = GPSK_1;
/* TODO: add support for configuring ID_Server */
- data->id_server = (u8 *) strdup("hostapd");
+ data->id_server = (u8 *) os_strdup("hostapd");
if (data->id_server)
- data->id_server_len = strlen((char *) data->id_server);
+ data->id_server_len = os_strlen((char *) data->id_server);
data->csuite_count = 0;
if (eap_gpsk_supported_ciphersuite(EAP_GPSK_VENDOR_IETF,
@@ -106,9 +106,9 @@ static void * eap_gpsk_init(struct eap_sm *sm)
static void eap_gpsk_reset(struct eap_sm *sm, void *priv)
{
struct eap_gpsk_data *data = priv;
- free(data->id_server);
- free(data->id_peer);
- free(data);
+ os_free(data->id_server);
+ os_free(data->id_peer);
+ os_free(data);
}
@@ -146,16 +146,16 @@ static u8 * eap_gpsk_build_gpsk_1(struct eap_sm *sm,
WPA_PUT_BE16(pos, data->id_server_len);
pos += 2;
if (data->id_server)
- memcpy(pos, data->id_server, data->id_server_len);
+ os_memcpy(pos, data->id_server, data->id_server_len);
pos += data->id_server_len;
- memcpy(pos, data->rand_server, EAP_GPSK_RAND_LEN);
+ os_memcpy(pos, data->rand_server, EAP_GPSK_RAND_LEN);
pos += EAP_GPSK_RAND_LEN;
WPA_PUT_BE16(pos, data->csuite_count * sizeof(struct eap_gpsk_csuite));
pos += 2;
- memcpy(pos, data->csuite_list,
- data->csuite_count * sizeof(struct eap_gpsk_csuite));
+ os_memcpy(pos, data->csuite_list,
+ data->csuite_count * sizeof(struct eap_gpsk_csuite));
return (u8 *) req;
}
@@ -187,14 +187,14 @@ static u8 * eap_gpsk_build_gpsk_3(struct eap_sm *sm,
*pos++ = EAP_GPSK_OPCODE_GPSK_3;
start = pos;
- memcpy(pos, data->rand_peer, EAP_GPSK_RAND_LEN);
+ os_memcpy(pos, data->rand_peer, EAP_GPSK_RAND_LEN);
pos += EAP_GPSK_RAND_LEN;
- memcpy(pos, data->rand_server, EAP_GPSK_RAND_LEN);
+ os_memcpy(pos, data->rand_server, EAP_GPSK_RAND_LEN);
pos += EAP_GPSK_RAND_LEN;
WPA_PUT_BE16(pos, data->id_server_len);
pos += 2;
if (data->id_server)
- memcpy(pos, data->id_server, data->id_server_len);
+ os_memcpy(pos, data->id_server, data->id_server_len);
pos += data->id_server_len;
csuite = (struct eap_gpsk_csuite *) pos;
WPA_PUT_BE32(csuite->vendor, data->vendor);
@@ -208,7 +208,7 @@ static u8 * eap_gpsk_build_gpsk_3(struct eap_sm *sm,
if (eap_gpsk_compute_mic(data->sk, data->sk_len, data->vendor,
data->specifier, start, pos - start, pos) < 0)
{
- free(req);
+ os_free(req);
eap_gpsk_state(data, FAILURE);
return NULL;
}
@@ -298,14 +298,14 @@ static void eap_gpsk_process_gpsk_2(struct eap_sm *sm,
eap_gpsk_state(data, FAILURE);
return;
}
- free(data->id_peer);
- data->id_peer = malloc(alen);
+ os_free(data->id_peer);
+ data->id_peer = os_malloc(alen);
if (data->id_peer == NULL) {
wpa_printf(MSG_DEBUG, "EAP-GPSK: Not enough memory to store "
"%d-octet ID_Peer", alen);
return;
}
- memcpy(data->id_peer, pos, alen);
+ os_memcpy(data->id_peer, pos, alen);
data->id_peer_len = alen;
wpa_hexdump_ascii(MSG_DEBUG, "EAP-GPSK: ID_Peer",
data->id_peer, data->id_peer_len);
@@ -326,7 +326,7 @@ static void eap_gpsk_process_gpsk_2(struct eap_sm *sm,
return;
}
if (alen != data->id_server_len ||
- memcmp(pos, data->id_server, alen) != 0) {
+ os_memcmp(pos, data->id_server, alen) != 0) {
wpa_printf(MSG_DEBUG, "EAP-GPSK: ID_Server in GPSK-1 and "
"GPSK-2 did not match");
eap_gpsk_state(data, FAILURE);
@@ -340,7 +340,7 @@ static void eap_gpsk_process_gpsk_2(struct eap_sm *sm,
eap_gpsk_state(data, FAILURE);
return;
}
- memcpy(data->rand_peer, pos, EAP_GPSK_RAND_LEN);
+ os_memcpy(data->rand_peer, pos, EAP_GPSK_RAND_LEN);
wpa_hexdump(MSG_DEBUG, "EAP-GPSK: RAND_Peer",
data->rand_peer, EAP_GPSK_RAND_LEN);
pos += EAP_GPSK_RAND_LEN;
@@ -351,7 +351,7 @@ static void eap_gpsk_process_gpsk_2(struct eap_sm *sm,
eap_gpsk_state(data, FAILURE);
return;
}
- if (memcmp(data->rand_server, pos, EAP_GPSK_RAND_LEN) != 0) {
+ if (os_memcmp(data->rand_server, pos, EAP_GPSK_RAND_LEN) != 0) {
wpa_printf(MSG_DEBUG, "EAP-GPSK: RAND_Server in GPSK-1 and "
"GPSK-2 did not match");
wpa_hexdump(MSG_DEBUG, "EAP-GPSK: RAND_Server in GPSK-1",
@@ -378,7 +378,7 @@ static void eap_gpsk_process_gpsk_2(struct eap_sm *sm,
return;
}
if (alen != data->csuite_count * sizeof(struct eap_gpsk_csuite) ||
- memcmp(pos, data->csuite_list, alen) != 0) {
+ os_memcmp(pos, data->csuite_list, alen) != 0) {
wpa_printf(MSG_DEBUG, "EAP-GPSK: CSuite_List in GPSK-1 and "
"GPSK-2 did not match");
eap_gpsk_state(data, FAILURE);
@@ -394,8 +394,8 @@ static void eap_gpsk_process_gpsk_2(struct eap_sm *sm,
}
csuite = (const struct eap_gpsk_csuite *) pos;
for (i = 0; i < data->csuite_count; i++) {
- if (memcmp(csuite, &data->csuite_list[i], sizeof(*csuite)) ==
- 0)
+ if (os_memcmp(csuite, &data->csuite_list[i], sizeof(*csuite))
+ == 0)
break;
}
if (i == data->csuite_count) {
@@ -463,7 +463,7 @@ static void eap_gpsk_process_gpsk_2(struct eap_sm *sm,
eap_gpsk_state(data, FAILURE);
return;
}
- if (memcmp(mic, pos, miclen) != 0) {
+ if (os_memcmp(mic, pos, miclen) != 0) {
wpa_printf(MSG_INFO, "EAP-GPSK: Incorrect MIC in GPSK-2");
wpa_hexdump(MSG_DEBUG, "EAP-GPSK: Received MIC", pos, miclen);
wpa_hexdump(MSG_DEBUG, "EAP-GPSK: Computed MIC", mic, miclen);
@@ -530,7 +530,7 @@ static void eap_gpsk_process_gpsk_4(struct eap_sm *sm,
eap_gpsk_state(data, FAILURE);
return;
}
- if (memcmp(mic, pos, miclen) != 0) {
+ if (os_memcmp(mic, pos, miclen) != 0) {
wpa_printf(MSG_INFO, "EAP-GPSK: Incorrect MIC in GPSK-4");
wpa_hexdump(MSG_DEBUG, "EAP-GPSK: Received MIC", pos, miclen);
wpa_hexdump(MSG_DEBUG, "EAP-GPSK: Computed MIC", mic, miclen);
@@ -588,10 +588,10 @@ static u8 * eap_gpsk_getKey(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_MSK_LEN);
+ key = os_malloc(EAP_MSK_LEN);
if (key == NULL)
return NULL;
- memcpy(key, data->msk, EAP_MSK_LEN);
+ os_memcpy(key, data->msk, EAP_MSK_LEN);
*len = EAP_MSK_LEN;
return key;
@@ -606,10 +606,10 @@ static u8 * eap_gpsk_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_EMSK_LEN);
+ key = os_malloc(EAP_EMSK_LEN);
if (key == NULL)
return NULL;
- memcpy(key, data->emsk, EAP_EMSK_LEN);
+ os_memcpy(key, data->emsk, EAP_EMSK_LEN);
*len = EAP_EMSK_LEN;
return key;
diff --git a/src/eap_server/eap_gtc.c b/src/eap_server/eap_gtc.c
index 7410a31..c67c708 100644
--- a/src/eap_server/eap_gtc.c
+++ b/src/eap_server/eap_gtc.c
@@ -49,7 +49,7 @@ static void * eap_gtc_init(struct eap_sm *sm)
static void eap_gtc_reset(struct eap_sm *sm, void *priv)
{
struct eap_gtc_data *data = priv;
- free(data);
+ os_free(data);
}
@@ -64,7 +64,7 @@ static u8 * eap_gtc_buildReq(struct eap_sm *sm, void *priv, int id,
msg = data->prefix ? "CHALLENGE=Password" : "Password";
- msg_len = strlen(msg);
+ msg_len = os_strlen(msg);
req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_GTC, reqDataLen,
msg_len, EAP_CODE_REQUEST, id, &pos);
if (req == NULL) {
@@ -74,7 +74,7 @@ static u8 * eap_gtc_buildReq(struct eap_sm *sm, void *priv, int id,
return NULL;
}
- memcpy(pos, msg, msg_len);
+ os_memcpy(pos, msg, msg_len);
data->state = CONTINUE;
@@ -173,7 +173,7 @@ static void eap_gtc_process(struct eap_sm *sm, void *priv,
}
if (rlen != sm->user->password_len ||
- memcmp(pos, sm->user->password, rlen) != 0) {
+ os_memcmp(pos, sm->user->password, rlen) != 0) {
wpa_printf(MSG_DEBUG, "EAP-GTC: Done - Failure");
data->state = FAILURE;
} else {
diff --git a/src/eap_server/eap_identity.c b/src/eap_server/eap_identity.c
index fc6db65..a1ef828 100644
--- a/src/eap_server/eap_identity.c
+++ b/src/eap_server/eap_identity.c
@@ -51,7 +51,7 @@ static void * eap_identity_initPickUp(struct eap_sm *sm)
static void eap_identity_reset(struct eap_sm *sm, void *priv)
{
struct eap_identity_data *data = priv;
- free(data);
+ os_free(data);
}
@@ -81,7 +81,7 @@ static u8 * eap_identity_buildReq(struct eap_sm *sm, void *priv, int id,
}
if (req_data)
- memcpy(pos, req_data, req_data_len);
+ os_memcpy(pos, req_data, req_data_len);
return (u8 *) req;
}
@@ -127,12 +127,12 @@ static void eap_identity_process(struct eap_sm *sm, void *priv,
return; /* Should not happen - frame already validated */
wpa_hexdump_ascii(MSG_DEBUG, "EAP-Identity: Peer identity", pos, len);
- free(sm->identity);
- sm->identity = malloc(len ? len : 1);
+ os_free(sm->identity);
+ sm->identity = os_malloc(len ? len : 1);
if (sm->identity == NULL) {
data->state = FAILURE;
} else {
- memcpy(sm->identity, pos, len);
+ os_memcpy(sm->identity, pos, len);
sm->identity_len = len;
data->state = SUCCESS;
}
diff --git a/src/eap_server/eap_md5.c b/src/eap_server/eap_md5.c
index a3359fa..2239892 100644
--- a/src/eap_server/eap_md5.c
+++ b/src/eap_server/eap_md5.c
@@ -44,7 +44,7 @@ static void * eap_md5_init(struct eap_sm *sm)
static void eap_md5_reset(struct eap_sm *sm, void *priv)
{
struct eap_md5_data *data = priv;
- free(data);
+ os_free(data);
}
@@ -71,7 +71,7 @@ static u8 * eap_md5_buildReq(struct eap_sm *sm, void *priv, int id,
}
*pos++ = CHALLENGE_LEN;
- memcpy(pos, data->challenge, CHALLENGE_LEN);
+ os_memcpy(pos, data->challenge, CHALLENGE_LEN);
wpa_hexdump(MSG_MSGDUMP, "EAP-MD5: Challenge", pos, CHALLENGE_LEN);
data->state = CONTINUE;
@@ -138,7 +138,7 @@ static void eap_md5_process(struct eap_sm *sm, void *priv,
len[2] = CHALLENGE_LEN;
md5_vector(3, addr, len, hash);
- if (memcmp(hash, pos, MD5_MAC_LEN) == 0) {
+ if (os_memcmp(hash, pos, MD5_MAC_LEN) == 0) {
wpa_printf(MSG_DEBUG, "EAP-MD5: Done - Success");
data->state = SUCCESS;
} else {
diff --git a/src/eap_server/eap_methods.c b/src/eap_server/eap_methods.c
index 0c561a6..c690318 100644
--- a/src/eap_server/eap_methods.c
+++ b/src/eap_server/eap_methods.c
@@ -52,7 +52,7 @@ EapType eap_server_get_type(const char *name, int *vendor)
{
struct eap_method *m;
for (m = eap_methods; m; m = m->next) {
- if (strcmp(m->name, name) == 0) {
+ if (os_strcmp(m->name, name) == 0) {
*vendor = m->vendor;
return m->method;
}
@@ -95,7 +95,7 @@ struct eap_method * eap_server_method_alloc(int version, int vendor,
*/
void eap_server_method_free(struct eap_method *method)
{
- free(method);
+ os_free(method);
}
@@ -119,7 +119,7 @@ int eap_server_method_register(struct eap_method *method)
for (m = eap_methods; m; m = m->next) {
if ((m->vendor == method->vendor &&
m->method == method->method) ||
- strcmp(m->name, method->name) == 0)
+ os_strcmp(m->name, method->name) == 0)
return -2;
last = m;
}
diff --git a/src/eap_server/eap_mschapv2.c b/src/eap_server/eap_mschapv2.c
index 503975b..bd4db55 100644
--- a/src/eap_server/eap_mschapv2.c
+++ b/src/eap_server/eap_mschapv2.c
@@ -95,8 +95,8 @@ static void eap_mschapv2_reset(struct eap_sm *sm, void *priv)
if (data == NULL)
return;
- free(data->peer_challenge);
- free(data);
+ os_free(data->peer_challenge);
+ os_free(data);
}
@@ -118,7 +118,7 @@ static u8 * eap_mschapv2_build_challenge(struct eap_sm *sm,
return NULL;
}
- ms_len = sizeof(*ms) + 1 + CHALLENGE_LEN + strlen(name);
+ ms_len = sizeof(*ms) + 1 + CHALLENGE_LEN + os_strlen(name);
req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2, reqDataLen,
ms_len, EAP_CODE_REQUEST, id, &pos);
if (req == NULL) {
@@ -136,11 +136,11 @@ static u8 * eap_mschapv2_build_challenge(struct eap_sm *sm,
pos = (u8 *) (ms + 1);
*pos++ = CHALLENGE_LEN;
if (!data->auth_challenge_from_tls)
- memcpy(pos, data->auth_challenge, CHALLENGE_LEN);
+ os_memcpy(pos, data->auth_challenge, CHALLENGE_LEN);
wpa_hexdump(MSG_MSGDUMP, "EAP-MSCHAPV2: Challenge", pos,
CHALLENGE_LEN);
pos += CHALLENGE_LEN;
- memcpy(pos, name, strlen(name));
+ os_memcpy(pos, name, os_strlen(name));
return (u8 *) req;
}
@@ -157,7 +157,7 @@ static u8 * eap_mschapv2_build_success_req(struct eap_sm *sm,
size_t ms_len;
ms_len = sizeof(*ms) + 2 + 2 * sizeof(data->auth_response) + 1 + 2 +
- strlen(message);
+ os_strlen(message);
req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2, reqDataLen,
ms_len, EAP_CODE_REQUEST, id, &pos);
if (req == NULL) {
@@ -182,7 +182,7 @@ static u8 * eap_mschapv2_build_success_req(struct eap_sm *sm,
*pos++ = ' ';
*pos++ = 'M';
*pos++ = '=';
- memcpy(pos, message, strlen(message));
+ os_memcpy(pos, message, os_strlen(message));
wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-MSCHAPV2: Success Request Message",
msg, ms_len - sizeof(*ms));
@@ -202,7 +202,7 @@ static u8 * eap_mschapv2_build_failure_req(struct eap_sm *sm,
"M=FAILED";
size_t ms_len;
- ms_len = sizeof(*ms) + strlen(message);
+ ms_len = sizeof(*ms) + os_strlen(message);
req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2, reqDataLen,
ms_len, EAP_CODE_REQUEST, id, &pos);
if (req == NULL) {
@@ -217,10 +217,10 @@ static u8 * eap_mschapv2_build_failure_req(struct eap_sm *sm,
ms->mschapv2_id = data->resp_mschapv2_id;
WPA_PUT_BE16(ms->ms_length, ms_len);
- memcpy((u8 *) (ms + 1), message, strlen(message));
+ os_memcpy((u8 *) (ms + 1), message, os_strlen(message));
wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-MSCHAPV2: Failure Request Message",
- (u8 *) message, strlen(message));
+ (u8 *) message, os_strlen(message));
return (u8 *) req;
}
@@ -365,7 +365,7 @@ static void eap_mschapv2_process_response(struct eap_sm *sm,
}
if (username_len != user_len ||
- memcmp(username, user, username_len) != 0) {
+ os_memcmp(username, user, username_len) != 0) {
wpa_printf(MSG_DEBUG, "EAP-MSCHAPV2: Mismatch in user names");
wpa_hexdump_ascii(MSG_DEBUG, "EAP-MSCHAPV2: Expected user "
"name", username, username_len);
@@ -392,7 +392,7 @@ static void eap_mschapv2_process_response(struct eap_sm *sm,
expected);
}
- if (memcmp(nt_response, expected, 24) == 0) {
+ if (os_memcmp(nt_response, expected, 24) == 0) {
const u8 *pw_hash;
u8 pw_hash_buf[16], pw_hash_hash[16];
@@ -537,7 +537,7 @@ static u8 * eap_mschapv2_getKey(struct eap_sm *sm, void *priv, size_t *len)
return NULL;
*len = 2 * MSCHAPV2_KEY_LEN;
- key = malloc(*len);
+ key = os_malloc(*len);
if (key == NULL)
return NULL;
get_asymetric_start_key(data->master_key, key, MSCHAPV2_KEY_LEN, 0, 0);
diff --git a/src/eap_server/eap_pax.c b/src/eap_server/eap_pax.c
index 64f9504..df765ef 100644
--- a/src/eap_server/eap_pax.c
+++ b/src/eap_server/eap_pax.c
@@ -68,8 +68,8 @@ static void * eap_pax_init(struct eap_sm *sm)
static void eap_pax_reset(struct eap_sm *sm, void *priv)
{
struct eap_pax_data *data = priv;
- free(data->cid);
- free(data);
+ os_free(data->cid);
+ os_free(data);
}
@@ -89,7 +89,7 @@ static u8 * eap_pax_build_std_1(struct eap_sm *sm,
}
*reqDataLen = sizeof(*req) + 2 + EAP_PAX_RAND_LEN + EAP_PAX_ICV_LEN;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-PAX: Failed to allocate memory "
"request");
@@ -109,7 +109,7 @@ static u8 * eap_pax_build_std_1(struct eap_sm *sm,
pos = (u8 *) (req + 1);
*pos++ = 0;
*pos++ = EAP_PAX_RAND_LEN;
- memcpy(pos, data->rand.r.x, EAP_PAX_RAND_LEN);
+ os_memcpy(pos, data->rand.r.x, EAP_PAX_RAND_LEN);
wpa_hexdump(MSG_MSGDUMP, "EAP-PAX: A = X (server rand)",
pos, EAP_PAX_RAND_LEN);
pos += EAP_PAX_RAND_LEN;
@@ -134,7 +134,7 @@ static u8 * eap_pax_build_std_3(struct eap_sm *sm,
wpa_printf(MSG_DEBUG, "EAP-PAX: PAX_STD-3 (sending)");
*reqDataLen = sizeof(*req) + 2 + EAP_PAX_MAC_LEN + EAP_PAX_ICV_LEN;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-PAX: Failed to allocate memory "
"request");
@@ -277,7 +277,7 @@ static Boolean eap_pax_check(struct eap_sm *sm, void *priv,
eap_pax_mac(data->mac_id, data->ick, EAP_PAX_ICK_LEN,
respData, len - EAP_PAX_ICV_LEN, NULL, 0, NULL, 0,
icvbuf);
- if (memcmp(icvbuf, icv, EAP_PAX_ICV_LEN) != 0) {
+ if (os_memcmp(icvbuf, icv, EAP_PAX_ICV_LEN) != 0) {
wpa_printf(MSG_INFO, "EAP-PAX: Invalid ICV");
wpa_hexdump(MSG_MSGDUMP, "EAP-PAX: Expected ICV",
icvbuf, EAP_PAX_ICV_LEN);
@@ -315,7 +315,7 @@ static void eap_pax_process_std_2(struct eap_sm *sm,
}
pos += 2;
left -= 2;
- memcpy(data->rand.r.y, pos, EAP_PAX_RAND_LEN);
+ os_memcpy(data->rand.r.y, pos, EAP_PAX_RAND_LEN);
wpa_hexdump(MSG_MSGDUMP, "EAP-PAX: Y (client rand)",
data->rand.r.y, EAP_PAX_RAND_LEN);
pos += EAP_PAX_RAND_LEN;
@@ -326,14 +326,14 @@ static void eap_pax_process_std_2(struct eap_sm *sm,
return;
}
data->cid_len = WPA_GET_BE16(pos);
- free(data->cid);
- data->cid = malloc(data->cid_len);
+ os_free(data->cid);
+ data->cid = os_malloc(data->cid_len);
if (data->cid == NULL) {
wpa_printf(MSG_INFO, "EAP-PAX: Failed to allocate memory for "
"CID");
return;
}
- memcpy(data->cid, pos + 2, data->cid_len);
+ os_memcpy(data->cid, pos + 2, data->cid_len);
pos += 2 + data->cid_len;
left -= 2 + data->cid_len;
wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-PAX: CID",
@@ -384,7 +384,7 @@ static void eap_pax_process_std_2(struct eap_sm *sm,
data->state = FAILURE;
return;
}
- memcpy(data->ak, sm->user->password, EAP_PAX_AK_LEN);
+ os_memcpy(data->ak, sm->user->password, EAP_PAX_AK_LEN);
if (eap_pax_initial_key_derivation(data->mac_id, data->ak,
data->rand.e, data->mk, data->ck,
@@ -400,7 +400,7 @@ static void eap_pax_process_std_2(struct eap_sm *sm,
data->rand.r.x, EAP_PAX_RAND_LEN,
data->rand.r.y, EAP_PAX_RAND_LEN,
(u8 *) data->cid, data->cid_len, mac);
- if (memcmp(mac, pos, EAP_PAX_MAC_LEN) != 0) {
+ if (os_memcmp(mac, pos, EAP_PAX_MAC_LEN) != 0) {
wpa_printf(MSG_INFO, "EAP-PAX: Invalid MAC_CK(A, B, CID) in "
"PAX_STD-2");
wpa_hexdump(MSG_MSGDUMP, "EAP-PAX: Expected MAC_CK(A, B, CID)",
@@ -420,7 +420,7 @@ static void eap_pax_process_std_2(struct eap_sm *sm,
wpa_hexdump(MSG_MSGDUMP, "EAP-PAX: ICV", pos, EAP_PAX_ICV_LEN);
eap_pax_mac(data->mac_id, data->ick, EAP_PAX_ICK_LEN,
respData, len - EAP_PAX_ICV_LEN, NULL, 0, NULL, 0, icvbuf);
- if (memcmp(icvbuf, pos, EAP_PAX_ICV_LEN) != 0) {
+ if (os_memcmp(icvbuf, pos, EAP_PAX_ICV_LEN) != 0) {
wpa_printf(MSG_INFO, "EAP-PAX: Invalid ICV in PAX_STD-2");
wpa_hexdump(MSG_MSGDUMP, "EAP-PAX: Expected ICV",
icvbuf, EAP_PAX_ICV_LEN);
@@ -492,7 +492,7 @@ static u8 * eap_pax_getKey(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_MSK_LEN);
+ key = os_malloc(EAP_MSK_LEN);
if (key == NULL)
return NULL;
@@ -513,7 +513,7 @@ static u8 * eap_pax_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_EMSK_LEN);
+ key = os_malloc(EAP_EMSK_LEN);
if (key == NULL)
return NULL;
diff --git a/src/eap_server/eap_peap.c b/src/eap_server/eap_peap.c
index ba288ff..21dd3d2 100644
--- a/src/eap_server/eap_peap.c
+++ b/src/eap_server/eap_peap.c
@@ -159,7 +159,7 @@ static void eap_peap_reset(struct eap_sm *sm, void *priv)
if (data->phase2_priv && data->phase2_method)
data->phase2_method->reset(sm, data->phase2_priv);
eap_server_tls_ssl_deinit(sm, &data->ssl);
- free(data);
+ os_free(data);
}
@@ -170,7 +170,7 @@ static u8 * eap_peap_build_start(struct eap_sm *sm, struct eap_peap_data *data,
u8 *pos;
*reqDataLen = sizeof(*req) + 2;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-PEAP: Failed to allocate memory for"
" request");
@@ -224,7 +224,7 @@ static u8 * eap_peap_encrypt(struct eap_sm *sm, struct eap_peap_data *data,
/* TODO: add support for fragmentation, if needed. This will need to
* add TLS Message Length field, if the frame is fragmented. */
- req = malloc(sizeof(struct eap_hdr) + 2 + data->ssl.tls_out_limit);
+ req = os_malloc(sizeof(struct eap_hdr) + 2 + data->ssl.tls_out_limit);
if (req == NULL)
return NULL;
@@ -241,7 +241,7 @@ static u8 * eap_peap_encrypt(struct eap_sm *sm, struct eap_peap_data *data,
if (res < 0) {
wpa_printf(MSG_INFO, "EAP-PEAP: Failed to encrypt Phase 2 "
"data");
- free(req);
+ os_free(req);
return NULL;
}
@@ -273,7 +273,7 @@ static u8 * eap_peap_build_phase2_req(struct eap_sm *sm,
}
encr_req = eap_peap_encrypt(sm, data, id, req, req_len, reqDataLen);
- free(buf);
+ os_free(buf);
return encr_req;
}
@@ -301,7 +301,7 @@ static u8 * eap_peap_build_phase2_term(struct eap_sm *sm,
encr_req = eap_peap_encrypt(sm, data, id, (u8 *) hdr, req_len,
reqDataLen);
- free(hdr);
+ os_free(hdr);
return encr_req;
}
@@ -488,9 +488,9 @@ static void eap_peap_process_phase2(struct eap_sm *sm,
buf_len = in_len;
if (data->ssl.tls_in_total > buf_len)
buf_len = data->ssl.tls_in_total;
- in_decrypted = malloc(buf_len);
+ in_decrypted = os_malloc(buf_len);
if (in_decrypted == NULL) {
- free(data->ssl.tls_in);
+ os_free(data->ssl.tls_in);
data->ssl.tls_in = NULL;
data->ssl.tls_in_len = 0;
wpa_printf(MSG_WARNING, "EAP-PEAP: failed to allocate memory "
@@ -501,13 +501,13 @@ static void eap_peap_process_phase2(struct eap_sm *sm,
len_decrypted = tls_connection_decrypt(sm->ssl_ctx, data->ssl.conn,
in_data, in_len,
in_decrypted, buf_len);
- free(data->ssl.tls_in);
+ os_free(data->ssl.tls_in);
data->ssl.tls_in = NULL;
data->ssl.tls_in_len = 0;
if (len_decrypted < 0) {
wpa_printf(MSG_INFO, "EAP-PEAP: Failed to decrypt Phase 2 "
"data");
- free(in_decrypted);
+ os_free(in_decrypted);
eap_peap_state(data, FAILURE);
return;
}
@@ -518,14 +518,14 @@ static void eap_peap_process_phase2(struct eap_sm *sm,
hdr = (struct eap_hdr *) in_decrypted;
if (data->peap_version == 0 && data->state != PHASE2_TLV) {
- struct eap_hdr *nhdr = malloc(sizeof(struct eap_hdr) +
- len_decrypted);
+ struct eap_hdr *nhdr = os_malloc(sizeof(struct eap_hdr) +
+ len_decrypted);
if (nhdr == NULL) {
- free(in_decrypted);
+ os_free(in_decrypted);
return;
}
- memcpy((u8 *) (nhdr + 1), in_decrypted, len_decrypted);
- free(in_decrypted);
+ os_memcpy((u8 *) (nhdr + 1), in_decrypted, len_decrypted);
+ os_free(in_decrypted);
nhdr->code = resp->code;
nhdr->identifier = resp->identifier;
nhdr->length = host_to_be16(sizeof(struct eap_hdr) +
@@ -536,7 +536,7 @@ static void eap_peap_process_phase2(struct eap_sm *sm,
}
hdr = (struct eap_hdr *) in_decrypted;
if (len_decrypted < (int) sizeof(*hdr)) {
- free(in_decrypted);
+ os_free(in_decrypted);
wpa_printf(MSG_INFO, "EAP-PEAP: Too short Phase 2 "
"EAP frame (len=%d)", len_decrypted);
eap_peap_req_failure(sm, data);
@@ -544,7 +544,7 @@ static void eap_peap_process_phase2(struct eap_sm *sm,
}
len = be_to_host16(hdr->length);
if (len > len_decrypted) {
- free(in_decrypted);
+ os_free(in_decrypted);
wpa_printf(MSG_INFO, "EAP-PEAP: Length mismatch in "
"Phase 2 EAP frame (len=%d hdr->length=%d)",
len_decrypted, len);
@@ -573,7 +573,7 @@ static void eap_peap_process_phase2(struct eap_sm *sm,
break;
}
- free(in_decrypted);
+ os_free(in_decrypted);
}
@@ -621,7 +621,7 @@ static void eap_peap_process(struct eap_sm *sm, void *priv,
if (data->ssl.tls_in_left == 0) {
data->ssl.tls_in_total = tls_msg_len;
data->ssl.tls_in_left = tls_msg_len;
- free(data->ssl.tls_in);
+ os_free(data->ssl.tls_in);
data->ssl.tls_in = NULL;
data->ssl.tls_in_len = 0;
}
diff --git a/src/eap_server/eap_psk.c b/src/eap_server/eap_psk.c
index 4183980..f7b0d48 100644
--- a/src/eap_server/eap_psk.c
+++ b/src/eap_server/eap_psk.c
@@ -53,8 +53,8 @@ static void * eap_psk_init(struct eap_sm *sm)
static void eap_psk_reset(struct eap_sm *sm, void *priv)
{
struct eap_psk_data *data = priv;
- free(data->id_p);
- free(data);
+ os_free(data->id_p);
+ os_free(data);
}
@@ -74,7 +74,7 @@ static u8 * eap_psk_build_1(struct eap_sm *sm, struct eap_psk_data *data,
data->rand_s, EAP_PSK_RAND_LEN);
*reqDataLen = sizeof(*req) + data->id_s_len;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-PSK: Failed to allocate memory "
"request");
@@ -87,8 +87,8 @@ static u8 * eap_psk_build_1(struct eap_sm *sm, struct eap_psk_data *data,
req->length = host_to_be16(*reqDataLen);
req->type = EAP_TYPE_PSK;
req->flags = EAP_PSK_FLAGS_SET_T(0); /* T=0 */
- memcpy(req->rand_s, data->rand_s, EAP_PSK_RAND_LEN);
- memcpy((u8 *) (req + 1), data->id_s, data->id_s_len);
+ os_memcpy(req->rand_s, data->rand_s, EAP_PSK_RAND_LEN);
+ os_memcpy((u8 *) (req + 1), data->id_s, data->id_s_len);
return (u8 *) req;
}
@@ -104,7 +104,7 @@ static u8 * eap_psk_build_3(struct eap_sm *sm, struct eap_psk_data *data,
wpa_printf(MSG_DEBUG, "EAP-PSK: PSK-3 (sending)");
*reqDataLen = sizeof(*req) + 4 + 16 + 1;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-PSK: Failed to allocate memory "
"request");
@@ -117,20 +117,20 @@ static u8 * eap_psk_build_3(struct eap_sm *sm, struct eap_psk_data *data,
req->length = host_to_be16(*reqDataLen);
req->type = EAP_TYPE_PSK;
req->flags = EAP_PSK_FLAGS_SET_T(2); /* T=2 */
- memcpy(req->rand_s, data->rand_s, EAP_PSK_RAND_LEN);
+ os_memcpy(req->rand_s, data->rand_s, EAP_PSK_RAND_LEN);
/* MAC_S = OMAC1-AES-128(AK, ID_S||RAND_P) */
buflen = data->id_s_len + EAP_PSK_RAND_LEN;
- buf = malloc(buflen);
+ buf = os_malloc(buflen);
if (buf == NULL) {
- free(req);
+ os_free(req);
data->state = FAILURE;
return NULL;
}
- memcpy(buf, data->id_s, data->id_s_len);
- memcpy(buf + data->id_s_len, data->rand_p, EAP_PSK_RAND_LEN);
+ os_memcpy(buf, data->id_s, data->id_s_len);
+ os_memcpy(buf + data->id_s_len, data->rand_p, EAP_PSK_RAND_LEN);
omac1_aes_128(data->ak, buf, buflen, req->mac_s);
- free(buf);
+ os_free(buf);
eap_psk_derive_keys(data->kdk, data->rand_p, data->tek, data->msk,
data->emsk);
@@ -138,10 +138,10 @@ static u8 * eap_psk_build_3(struct eap_sm *sm, struct eap_psk_data *data,
wpa_hexdump_key(MSG_DEBUG, "EAP-PSK: MSK", data->msk, EAP_MSK_LEN);
wpa_hexdump_key(MSG_DEBUG, "EAP-PSK: EMSK", data->emsk, EAP_EMSK_LEN);
- memset(nonce, 0, sizeof(nonce));
+ os_memset(nonce, 0, sizeof(nonce));
pchannel = (u8 *) (req + 1);
- memcpy(pchannel, nonce + 12, 4);
- memset(pchannel + 4, 0, 16); /* Tag */
+ os_memcpy(pchannel, nonce + 12, 4);
+ os_memset(pchannel + 4, 0, 16); /* Tag */
pchannel[4 + 16] = EAP_PSK_R_FLAG_DONE_SUCCESS << 6;
wpa_hexdump(MSG_DEBUG, "EAP-PSK: PCHANNEL (plaintext)",
pchannel, 4 + 16 + 1);
@@ -233,14 +233,14 @@ static void eap_psk_process_2(struct eap_sm *sm,
pos = (u8 *) (resp + 1);
left = len - sizeof(*resp);
- free(data->id_p);
- data->id_p = malloc(left);
+ os_free(data->id_p);
+ data->id_p = os_malloc(left);
if (data->id_p == NULL) {
wpa_printf(MSG_INFO, "EAP-PSK: Failed to allocate memory for "
"ID_P");
return;
}
- memcpy(data->id_p, pos, left);
+ os_memcpy(data->id_p, pos, left);
data->id_p_len = left;
wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-PSK: ID_P",
data->id_p, data->id_p_len);
@@ -286,26 +286,26 @@ static void eap_psk_process_2(struct eap_sm *sm,
wpa_hexdump(MSG_MSGDUMP, "EAP-PSK: RAND_P (client rand)",
resp->rand_p, EAP_PSK_RAND_LEN);
- memcpy(data->rand_p, resp->rand_p, EAP_PSK_RAND_LEN);
+ os_memcpy(data->rand_p, resp->rand_p, EAP_PSK_RAND_LEN);
/* MAC_P = OMAC1-AES-128(AK, ID_P||ID_S||RAND_S||RAND_P) */
buflen = data->id_p_len + data->id_s_len + 2 * EAP_PSK_RAND_LEN;
- buf = malloc(buflen);
+ buf = os_malloc(buflen);
if (buf == NULL) {
data->state = FAILURE;
return;
}
- memcpy(buf, data->id_p, data->id_p_len);
+ os_memcpy(buf, data->id_p, data->id_p_len);
pos = buf + data->id_p_len;
- memcpy(pos, data->id_s, data->id_s_len);
+ os_memcpy(pos, data->id_s, data->id_s_len);
pos += data->id_s_len;
- memcpy(pos, data->rand_s, EAP_PSK_RAND_LEN);
+ os_memcpy(pos, data->rand_s, EAP_PSK_RAND_LEN);
pos += EAP_PSK_RAND_LEN;
- memcpy(pos, data->rand_p, EAP_PSK_RAND_LEN);
+ os_memcpy(pos, data->rand_p, EAP_PSK_RAND_LEN);
omac1_aes_128(data->ak, buf, buflen, mac);
- free(buf);
+ os_free(buf);
wpa_hexdump(MSG_DEBUG, "EAP-PSK: MAC_P", resp->mac_p, EAP_PSK_MAC_LEN);
- if (memcmp(mac, resp->mac_p, EAP_PSK_MAC_LEN) != 0) {
+ if (os_memcmp(mac, resp->mac_p, EAP_PSK_MAC_LEN) != 0) {
wpa_printf(MSG_INFO, "EAP-PSK: Invalid MAC_P");
wpa_hexdump(MSG_MSGDUMP, "EAP-PSK: Expected MAC_P",
mac, EAP_PSK_MAC_LEN);
@@ -348,23 +348,23 @@ static void eap_psk_process_4(struct eap_sm *sm,
return;
}
- memset(nonce, 0, 12);
- memcpy(nonce + 12, pos, 4);
+ os_memset(nonce, 0, 12);
+ os_memcpy(nonce + 12, pos, 4);
pos += 4;
left -= 4;
tag = pos;
pos += 16;
left -= 16;
- decrypted = malloc(left);
+ decrypted = os_malloc(left);
if (decrypted == NULL)
return;
- memcpy(decrypted, pos, left);
+ os_memcpy(decrypted, pos, left);
if (aes_128_eax_decrypt(data->tek, nonce, sizeof(nonce),
respData, 22, decrypted, left, tag)) {
wpa_printf(MSG_WARNING, "EAP-PSK: PCHANNEL decryption failed");
- free(decrypted);
+ os_free(decrypted);
data->state = FAILURE;
return;
}
@@ -386,7 +386,7 @@ static void eap_psk_process_4(struct eap_sm *sm,
data->state = FAILURE;
break;
}
- free(decrypted);
+ os_free(decrypted);
}
@@ -431,10 +431,10 @@ static u8 * eap_psk_getKey(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_MSK_LEN);
+ key = os_malloc(EAP_MSK_LEN);
if (key == NULL)
return NULL;
- memcpy(key, data->msk, EAP_MSK_LEN);
+ os_memcpy(key, data->msk, EAP_MSK_LEN);
*len = EAP_MSK_LEN;
return key;
@@ -449,10 +449,10 @@ static u8 * eap_psk_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_EMSK_LEN);
+ key = os_malloc(EAP_EMSK_LEN);
if (key == NULL)
return NULL;
- memcpy(key, data->emsk, EAP_EMSK_LEN);
+ os_memcpy(key, data->emsk, EAP_EMSK_LEN);
*len = EAP_EMSK_LEN;
return key;
diff --git a/src/eap_server/eap_sake.c b/src/eap_server/eap_sake.c
index c80f7b6..df182ed 100644
--- a/src/eap_server/eap_sake.c
+++ b/src/eap_server/eap_sake.c
@@ -83,9 +83,9 @@ static void * eap_sake_init(struct eap_sm *sm)
data->session_id);
/* TODO: add support for configuring SERVERID */
- data->serverid = (u8 *) strdup("hostapd");
+ data->serverid = (u8 *) os_strdup("hostapd");
if (data->serverid)
- data->serverid_len = strlen((char *) data->serverid);
+ data->serverid_len = os_strlen((char *) data->serverid);
return data;
}
diff --git a/src/eap_server/eap_sim.c b/src/eap_server/eap_sim.c
index 3078717..f08a131 100644
--- a/src/eap_server/eap_sim.c
+++ b/src/eap_server/eap_sim.c
@@ -89,9 +89,9 @@ static void * eap_sim_init(struct eap_sm *sm)
static void eap_sim_reset(struct eap_sm *sm, void *priv)
{
struct eap_sim_data *data = priv;
- free(data->next_pseudonym);
- free(data->next_reauth_id);
- free(data);
+ os_free(data->next_pseudonym);
+ os_free(data->next_reauth_id);
+ os_free(data);
}
@@ -122,10 +122,10 @@ static int eap_sim_build_encr(struct eap_sm *sm, struct eap_sim_data *data,
struct eap_sim_msg *msg, u16 counter,
const u8 *nonce_s)
{
- free(data->next_pseudonym);
+ os_free(data->next_pseudonym);
data->next_pseudonym =
eap_sim_db_get_next_pseudonym(sm->eap_sim_db_priv, 0);
- free(data->next_reauth_id);
+ os_free(data->next_reauth_id);
if (data->counter <= EAP_SIM_MAX_FAST_REAUTHS) {
data->next_reauth_id =
eap_sim_db_get_next_reauth_id(sm->eap_sim_db_priv, 0);
@@ -158,18 +158,18 @@ static int eap_sim_build_encr(struct eap_sm *sm, struct eap_sim_data *data,
wpa_printf(MSG_DEBUG, " *AT_NEXT_PSEUDONYM (%s)",
data->next_pseudonym);
eap_sim_msg_add(msg, EAP_SIM_AT_NEXT_PSEUDONYM,
- strlen(data->next_pseudonym),
+ os_strlen(data->next_pseudonym),
(u8 *) data->next_pseudonym,
- strlen(data->next_pseudonym));
+ os_strlen(data->next_pseudonym));
}
if (data->next_reauth_id) {
wpa_printf(MSG_DEBUG, " *AT_NEXT_REAUTH_ID (%s)",
data->next_reauth_id);
eap_sim_msg_add(msg, EAP_SIM_AT_NEXT_REAUTH_ID,
- strlen(data->next_reauth_id),
+ os_strlen(data->next_reauth_id),
(u8 *) data->next_reauth_id,
- strlen(data->next_reauth_id));
+ os_strlen(data->next_reauth_id));
}
if (eap_sim_msg_add_encr_end(msg, data->k_encr, EAP_SIM_AT_PADDING)) {
@@ -344,11 +344,11 @@ static void eap_sim_process_start(struct eap_sm *sm,
}
if (attr->identity) {
- free(sm->identity);
- sm->identity = malloc(attr->identity_len);
+ os_free(sm->identity);
+ sm->identity = os_malloc(attr->identity_len);
if (sm->identity) {
- memcpy(sm->identity, attr->identity,
- attr->identity_len);
+ os_memcpy(sm->identity, attr->identity,
+ attr->identity_len);
sm->identity_len = attr->identity_len;
}
}
@@ -375,8 +375,8 @@ static void eap_sim_process_start(struct eap_sm *sm,
identity = data->reauth->identity;
identity_len = data->reauth->identity_len;
data->counter = data->reauth->counter;
- memcpy(data->mk, data->reauth->mk,
- EAP_SIM_MK_LEN);
+ os_memcpy(data->mk, data->reauth->mk,
+ EAP_SIM_MK_LEN);
}
}
}
@@ -419,7 +419,7 @@ static void eap_sim_process_start(struct eap_sm *sm,
wpa_hexdump_ascii(MSG_DEBUG, "EAP-SIM: Identity for MK derivation",
sm->identity, sm->identity_len);
- memcpy(data->nonce_mt, attr->nonce_mt, EAP_SIM_NONCE_MT_LEN);
+ os_memcpy(data->nonce_mt, attr->nonce_mt, EAP_SIM_NONCE_MT_LEN);
WPA_PUT_BE16(ver_list, EAP_SIM_VERSION);
eap_sim_derive_mk(sm->identity, sm->identity_len, attr->nonce_mt,
attr->selected_version, ver_list, sizeof(ver_list),
@@ -515,7 +515,7 @@ static void eap_sim_process_reauth(struct eap_sm *sm,
eattr.counter, data->counter);
goto fail;
}
- free(decrypted);
+ os_free(decrypted);
decrypted = NULL;
wpa_printf(MSG_DEBUG, "EAP-SIM: Re-authentication response includes "
@@ -558,7 +558,7 @@ fail:
eap_sim_state(data, FAILURE);
eap_sim_db_remove_reauth(sm->eap_sim_db_priv, data->reauth);
data->reauth = NULL;
- free(decrypted);
+ os_free(decrypted);
}
@@ -632,10 +632,10 @@ static u8 * eap_sim_getKey(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_SIM_KEYING_DATA_LEN);
+ key = os_malloc(EAP_SIM_KEYING_DATA_LEN);
if (key == NULL)
return NULL;
- memcpy(key, data->msk, EAP_SIM_KEYING_DATA_LEN);
+ os_memcpy(key, data->msk, EAP_SIM_KEYING_DATA_LEN);
*len = EAP_SIM_KEYING_DATA_LEN;
return key;
}
@@ -649,10 +649,10 @@ static u8 * eap_sim_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(EAP_EMSK_LEN);
+ key = os_malloc(EAP_EMSK_LEN);
if (key == NULL)
return NULL;
- memcpy(key, data->emsk, EAP_EMSK_LEN);
+ os_memcpy(key, data->emsk, EAP_EMSK_LEN);
*len = EAP_EMSK_LEN;
return key;
}
diff --git a/src/eap_server/eap_sim_db.c b/src/eap_server/eap_sim_db.c
index 3bf4154..bc6e020 100644
--- a/src/eap_server/eap_sim_db.c
+++ b/src/eap_server/eap_sim_db.c
@@ -83,7 +83,7 @@ eap_sim_db_get_pending(struct eap_sim_db_data *data, const u8 *imsi,
entry = data->pending;
while (entry) {
if (entry->aka == aka && entry->imsi_len == imsi_len &&
- memcmp(entry->imsi, imsi, imsi_len) == 0) {
+ os_memcmp(entry->imsi, imsi, imsi_len) == 0) {
if (prev)
prev->next = entry->next;
else
@@ -118,7 +118,7 @@ static void eap_sim_db_sim_resp_auth(struct eap_sim_db_data *data,
* (IMSI = ASCII string, Kc/SRES/RAND = hex string)
*/
- entry = eap_sim_db_get_pending(data, (u8 *) imsi, strlen(imsi), 0);
+ entry = eap_sim_db_get_pending(data, (u8 *) imsi, os_strlen(imsi), 0);
if (entry == NULL) {
wpa_printf(MSG_DEBUG, "EAP-SIM DB: No pending entry for the "
"received message found");
@@ -126,7 +126,7 @@ static void eap_sim_db_sim_resp_auth(struct eap_sim_db_data *data,
}
start = buf;
- if (strncmp(start, "FAILURE", 7) == 0) {
+ if (os_strncmp(start, "FAILURE", 7) == 0) {
wpa_printf(MSG_DEBUG, "EAP-SIM DB: External server reported "
"failure");
entry->state = FAILURE;
@@ -137,11 +137,11 @@ static void eap_sim_db_sim_resp_auth(struct eap_sim_db_data *data,
num_chal = 0;
while (num_chal < EAP_SIM_MAX_CHAL) {
- end = strchr(start, ' ');
+ end = os_strchr(start, ' ');
if (end)
*end = '\0';
- pos = strchr(start, ':');
+ pos = os_strchr(start, ':');
if (pos == NULL)
goto parse_fail;
*pos = '\0';
@@ -150,7 +150,7 @@ static void eap_sim_db_sim_resp_auth(struct eap_sim_db_data *data,
goto parse_fail;
start = pos + 1;
- pos = strchr(start, ':');
+ pos = os_strchr(start, ':');
if (pos == NULL)
goto parse_fail;
*pos = '\0';
@@ -180,7 +180,7 @@ static void eap_sim_db_sim_resp_auth(struct eap_sim_db_data *data,
parse_fail:
wpa_printf(MSG_DEBUG, "EAP-SIM DB: Failed to parse response string");
- free(entry);
+ os_free(entry);
}
@@ -196,7 +196,7 @@ static void eap_sim_db_aka_resp_auth(struct eap_sim_db_data *data,
* (IMSI = ASCII string, RAND/AUTN/IK/CK/RES = hex string)
*/
- entry = eap_sim_db_get_pending(data, (u8 *) imsi, strlen(imsi), 1);
+ entry = eap_sim_db_get_pending(data, (u8 *) imsi, os_strlen(imsi), 1);
if (entry == NULL) {
wpa_printf(MSG_DEBUG, "EAP-SIM DB: No pending entry for the "
"received message found");
@@ -204,7 +204,7 @@ static void eap_sim_db_aka_resp_auth(struct eap_sim_db_data *data,
}
start = buf;
- if (strncmp(start, "FAILURE", 7) == 0) {
+ if (os_strncmp(start, "FAILURE", 7) == 0) {
wpa_printf(MSG_DEBUG, "EAP-SIM DB: External server reported "
"failure");
entry->state = FAILURE;
@@ -213,7 +213,7 @@ static void eap_sim_db_aka_resp_auth(struct eap_sim_db_data *data,
return;
}
- end = strchr(start, ' ');
+ end = os_strchr(start, ' ');
if (end == NULL)
goto parse_fail;
*end = '\0';
@@ -221,7 +221,7 @@ static void eap_sim_db_aka_resp_auth(struct eap_sim_db_data *data,
goto parse_fail;
start = end + 1;
- end = strchr(start, ' ');
+ end = os_strchr(start, ' ');
if (end == NULL)
goto parse_fail;
*end = '\0';
@@ -229,7 +229,7 @@ static void eap_sim_db_aka_resp_auth(struct eap_sim_db_data *data,
goto parse_fail;
start = end + 1;
- end = strchr(start, ' ');
+ end = os_strchr(start, ' ');
if (end == NULL)
goto parse_fail;
*end = '\0';
@@ -237,7 +237,7 @@ static void eap_sim_db_aka_resp_auth(struct eap_sim_db_data *data,
goto parse_fail;
start = end + 1;
- end = strchr(start, ' ');
+ end = os_strchr(start, ' ');
if (end == NULL)
goto parse_fail;
*end = '\0';
@@ -245,7 +245,7 @@ static void eap_sim_db_aka_resp_auth(struct eap_sim_db_data *data,
goto parse_fail;
start = end + 1;
- end = strchr(start, ' ');
+ end = os_strchr(start, ' ');
if (end)
*end = '\0';
else {
@@ -271,7 +271,7 @@ static void eap_sim_db_aka_resp_auth(struct eap_sim_db_data *data,
parse_fail:
wpa_printf(MSG_DEBUG, "EAP-SIM DB: Failed to parse response string");
- free(entry);
+ os_free(entry);
}
@@ -301,21 +301,21 @@ static void eap_sim_db_receive(int sock, void *eloop_ctx, void *sock_ctx)
/* <cmd> <IMSI> ... */
cmd = buf;
- pos = strchr(cmd, ' ');
+ pos = os_strchr(cmd, ' ');
if (pos == NULL)
goto parse_fail;
*pos = '\0';
imsi = pos + 1;
- pos = strchr(imsi, ' ');
+ pos = os_strchr(imsi, ' ');
if (pos == NULL)
goto parse_fail;
*pos = '\0';
wpa_printf(MSG_DEBUG, "EAP-SIM DB: External response=%s for IMSI %s",
cmd, imsi);
- if (strcmp(cmd, "SIM-RESP-AUTH") == 0)
+ if (os_strcmp(cmd, "SIM-RESP-AUTH") == 0)
eap_sim_db_sim_resp_auth(data, imsi, pos + 1);
- else if (strcmp(cmd, "AKA-RESP-AUTH") == 0)
+ else if (os_strcmp(cmd, "AKA-RESP-AUTH") == 0)
eap_sim_db_aka_resp_auth(data, imsi, pos + 1);
else
wpa_printf(MSG_INFO, "EAP-SIM DB: Unknown external response "
@@ -332,7 +332,7 @@ static int eap_sim_db_open_socket(struct eap_sim_db_data *data)
struct sockaddr_un addr;
static int counter = 0;
- if (strncmp(data->fname, "unix:", 5) != 0)
+ if (os_strncmp(data->fname, "unix:", 5) != 0)
return -1;
data->sock = socket(PF_UNIX, SOCK_DGRAM, 0);
@@ -341,11 +341,11 @@ static int eap_sim_db_open_socket(struct eap_sim_db_data *data)
return -1;
}
- memset(&addr, 0, sizeof(addr));
+ os_memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- snprintf(addr.sun_path, sizeof(addr.sun_path),
- "/tmp/eap_sim_db_%d-%d", getpid(), counter++);
- data->local_sock = strdup(addr.sun_path);
+ os_snprintf(addr.sun_path, sizeof(addr.sun_path),
+ "/tmp/eap_sim_db_%d-%d", getpid(), counter++);
+ data->local_sock = os_strdup(addr.sun_path);
if (bind(data->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("bind(eap_sim_db)");
close(data->sock);
@@ -353,13 +353,14 @@ static int eap_sim_db_open_socket(struct eap_sim_db_data *data)
return -1;
}
- memset(&addr, 0, sizeof(addr));
+ os_memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
os_strlcpy(addr.sun_path, data->fname + 5, sizeof(addr.sun_path));
if (connect(data->sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("connect(eap_sim_db)");
wpa_hexdump_ascii(MSG_INFO, "HLR/AuC GW socket",
- (u8 *) addr.sun_path, strlen(addr.sun_path));
+ (u8 *) addr.sun_path,
+ os_strlen(addr.sun_path));
close(data->sock);
data->sock = -1;
return -1;
@@ -380,7 +381,7 @@ static void eap_sim_db_close_socket(struct eap_sim_db_data *data)
}
if (data->local_sock) {
unlink(data->local_sock);
- free(data->local_sock);
+ os_free(data->local_sock);
data->local_sock = NULL;
}
}
@@ -406,11 +407,11 @@ void * eap_sim_db_init(const char *config,
data->sock = -1;
data->get_complete_cb = get_complete_cb;
data->ctx = ctx;
- data->fname = strdup(config);
+ data->fname = os_strdup(config);
if (data->fname == NULL)
goto fail;
- if (strncmp(data->fname, "unix:", 5) == 0) {
+ if (os_strncmp(data->fname, "unix:", 5) == 0) {
if (eap_sim_db_open_socket(data))
goto fail;
}
@@ -419,25 +420,25 @@ void * eap_sim_db_init(const char *config,
fail:
eap_sim_db_close_socket(data);
- free(data->fname);
- free(data);
+ os_free(data->fname);
+ os_free(data);
return NULL;
}
static void eap_sim_db_free_pseudonym(struct eap_sim_pseudonym *p)
{
- free(p->identity);
- free(p->pseudonym);
- free(p);
+ os_free(p->identity);
+ os_free(p->pseudonym);
+ os_free(p);
}
static void eap_sim_db_free_reauth(struct eap_sim_reauth *r)
{
- free(r->identity);
- free(r->reauth_id);
- free(r);
+ os_free(r->identity);
+ os_free(r->reauth_id);
+ os_free(r);
}
@@ -453,7 +454,7 @@ void eap_sim_db_deinit(void *priv)
struct eap_sim_db_pending *pending, *prev_pending;
eap_sim_db_close_socket(data);
- free(data->fname);
+ os_free(data->fname);
p = data->pseudonyms;
while (p) {
@@ -473,10 +474,10 @@ void eap_sim_db_deinit(void *priv)
while (pending) {
prev_pending = pending;
pending = pending->next;
- free(prev_pending);
+ os_free(prev_pending);
}
- free(data);
+ os_free(data);
}
@@ -577,7 +578,7 @@ int eap_sim_db_get_gsm_triplets(void *priv, const u8 *identity,
if (entry->state == FAILURE) {
wpa_printf(MSG_DEBUG, "EAP-SIM DB: Pending entry -> "
"failure");
- free(entry);
+ os_free(entry);
return EAP_SIM_DB_FAILURE;
}
@@ -593,10 +594,11 @@ int eap_sim_db_get_gsm_triplets(void *priv, const u8 *identity,
num_chal = entry->u.sim.num_chal;
if (num_chal > max_chal)
num_chal = max_chal;
- memcpy(_rand, entry->u.sim.rand, num_chal * GSM_RAND_LEN);
- memcpy(sres, entry->u.sim.sres, num_chal * EAP_SIM_SRES_LEN);
- memcpy(kc, entry->u.sim.kc, num_chal * EAP_SIM_KC_LEN);
- free(entry);
+ os_memcpy(_rand, entry->u.sim.rand, num_chal * GSM_RAND_LEN);
+ os_memcpy(sres, entry->u.sim.sres,
+ num_chal * EAP_SIM_SRES_LEN);
+ os_memcpy(kc, entry->u.sim.kc, num_chal * EAP_SIM_KC_LEN);
+ os_free(entry);
return num_chal;
}
@@ -605,12 +607,12 @@ int eap_sim_db_get_gsm_triplets(void *priv, const u8 *identity,
return EAP_SIM_DB_FAILURE;
}
- len = snprintf(msg, sizeof(msg), "SIM-REQ-AUTH ");
+ len = os_snprintf(msg, sizeof(msg), "SIM-REQ-AUTH ");
if (len < 0 || len + identity_len >= sizeof(msg))
return EAP_SIM_DB_FAILURE;
- memcpy(msg + len, identity, identity_len);
+ os_memcpy(msg + len, identity, identity_len);
len += identity_len;
- ret = snprintf(msg + len, sizeof(msg) - len, " %d", max_chal);
+ ret = os_snprintf(msg + len, sizeof(msg) - len, " %d", max_chal);
if (ret < 0 || (size_t) ret >= sizeof(msg) - len)
return EAP_SIM_DB_FAILURE;
len += ret;
@@ -625,7 +627,7 @@ int eap_sim_db_get_gsm_triplets(void *priv, const u8 *identity,
return EAP_SIM_DB_FAILURE;
os_get_time(&entry->timestamp);
- memcpy(entry->imsi, identity, identity_len);
+ os_memcpy(entry->imsi, identity, identity_len);
entry->imsi_len = identity_len;
entry->cb_session_ctx = cb_session_ctx;
entry->state = PENDING;
@@ -657,20 +659,20 @@ eap_sim_db_get_pseudonym(struct eap_sim_db_data *data, const u8 *identity,
len++;
}
- pseudonym = malloc(len + 1);
+ pseudonym = os_malloc(len + 1);
if (pseudonym == NULL)
return NULL;
- memcpy(pseudonym, identity, len);
+ os_memcpy(pseudonym, identity, len);
pseudonym[len] = '\0';
p = data->pseudonyms;
while (p) {
- if (strcmp(p->pseudonym, pseudonym) == 0)
+ if (os_strcmp(p->pseudonym, pseudonym) == 0)
break;
p = p->next;
}
- free(pseudonym);
+ os_free(pseudonym);
return p;
}
@@ -690,7 +692,7 @@ eap_sim_db_get_pseudonym_id(struct eap_sim_db_data *data, const u8 *identity,
p = data->pseudonyms;
while (p) {
if (identity_len == p->identity_len &&
- memcmp(p->identity, identity, identity_len) == 0)
+ os_memcmp(p->identity, identity, identity_len) == 0)
break;
p = p->next;
}
@@ -720,20 +722,20 @@ eap_sim_db_get_reauth(struct eap_sim_db_data *data, const u8 *identity,
len++;
}
- reauth_id = malloc(len + 1);
+ reauth_id = os_malloc(len + 1);
if (reauth_id == NULL)
return NULL;
- memcpy(reauth_id, identity, len);
+ os_memcpy(reauth_id, identity, len);
reauth_id[len] = '\0';
r = data->reauths;
while (r) {
- if (strcmp(r->reauth_id, reauth_id) == 0)
+ if (os_strcmp(r->reauth_id, reauth_id) == 0)
break;
r = r->next;
}
- free(reauth_id);
+ os_free(reauth_id);
return r;
}
@@ -760,7 +762,7 @@ eap_sim_db_get_reauth_id(struct eap_sim_db_data *data, const u8 *identity,
r = data->reauths;
while (r) {
if (identity_len == r->identity_len &&
- memcmp(r->identity, identity, identity_len) == 0)
+ os_memcmp(r->identity, identity, identity_len) == 0)
break;
r = r->next;
}
@@ -826,7 +828,7 @@ static char * eap_sim_db_get_next(struct eap_sim_db_data *data, char prefix)
if (os_get_random(buf, sizeof(buf)))
return NULL;
- id = malloc(sizeof(buf) * 2 + 2);
+ id = os_malloc(sizeof(buf) * 2 + 2);
if (id == NULL)
return NULL;
@@ -908,25 +910,25 @@ int eap_sim_db_add_pseudonym(void *priv, const u8 *identity,
if (p) {
wpa_printf(MSG_DEBUG, "EAP-SIM DB: Replacing previous "
"pseudonym: %s", p->pseudonym);
- free(p->pseudonym);
+ os_free(p->pseudonym);
p->pseudonym = pseudonym;
return 0;
}
p = os_zalloc(sizeof(*p));
if (p == NULL) {
- free(pseudonym);
+ os_free(pseudonym);
return -1;
}
p->next = data->pseudonyms;
- p->identity = malloc(identity_len);
+ p->identity = os_malloc(identity_len);
if (p->identity == NULL) {
- free(p);
- free(pseudonym);
+ os_free(p);
+ os_free(pseudonym);
return -1;
}
- memcpy(p->identity, identity, identity_len);
+ os_memcpy(p->identity, identity, identity_len);
p->identity_len = identity_len;
p->pseudonym = pseudonym;
data->pseudonyms = p;
@@ -968,23 +970,23 @@ int eap_sim_db_add_reauth(void *priv, const u8 *identity,
if (r) {
wpa_printf(MSG_DEBUG, "EAP-SIM DB: Replacing previous "
"reauth_id: %s", r->reauth_id);
- free(r->reauth_id);
+ os_free(r->reauth_id);
r->reauth_id = reauth_id;
} else {
r = os_zalloc(sizeof(*r));
if (r == NULL) {
- free(reauth_id);
+ os_free(reauth_id);
return -1;
}
r->next = data->reauths;
- r->identity = malloc(identity_len);
+ r->identity = os_malloc(identity_len);
if (r->identity == NULL) {
- free(r);
- free(reauth_id);
+ os_free(r);
+ os_free(reauth_id);
return -1;
}
- memcpy(r->identity, identity, identity_len);
+ os_memcpy(r->identity, identity, identity_len);
r->identity_len = identity_len;
r->reauth_id = reauth_id;
data->reauths = r;
@@ -992,7 +994,7 @@ int eap_sim_db_add_reauth(void *priv, const u8 *identity,
}
r->counter = counter;
- memcpy(r->mk, mk, EAP_SIM_MK_LEN);
+ os_memcpy(r->mk, mk, EAP_SIM_MK_LEN);
return 0;
}
@@ -1137,7 +1139,7 @@ int eap_sim_db_get_aka_auth(void *priv, const u8 *identity,
entry = eap_sim_db_get_pending(data, identity, identity_len, 1);
if (entry) {
if (entry->state == FAILURE) {
- free(entry);
+ os_free(entry);
wpa_printf(MSG_DEBUG, "EAP-SIM DB: Failure");
return EAP_SIM_DB_FAILURE;
}
@@ -1150,13 +1152,13 @@ int eap_sim_db_get_aka_auth(void *priv, const u8 *identity,
wpa_printf(MSG_DEBUG, "EAP-SIM DB: Returning successfully "
"received authentication data");
- memcpy(_rand, entry->u.aka.rand, EAP_AKA_RAND_LEN);
- memcpy(autn, entry->u.aka.autn, EAP_AKA_AUTN_LEN);
- memcpy(ik, entry->u.aka.ik, EAP_AKA_IK_LEN);
- memcpy(ck, entry->u.aka.ck, EAP_AKA_CK_LEN);
- memcpy(res, entry->u.aka.res, EAP_AKA_RES_MAX_LEN);
+ os_memcpy(_rand, entry->u.aka.rand, EAP_AKA_RAND_LEN);
+ os_memcpy(autn, entry->u.aka.autn, EAP_AKA_AUTN_LEN);
+ os_memcpy(ik, entry->u.aka.ik, EAP_AKA_IK_LEN);
+ os_memcpy(ck, entry->u.aka.ck, EAP_AKA_CK_LEN);
+ os_memcpy(res, entry->u.aka.res, EAP_AKA_RES_MAX_LEN);
*res_len = entry->u.aka.res_len;
- free(entry);
+ os_free(entry);
return 0;
}
@@ -1165,10 +1167,10 @@ int eap_sim_db_get_aka_auth(void *priv, const u8 *identity,
return EAP_SIM_DB_FAILURE;
}
- len = snprintf(msg, sizeof(msg), "AKA-REQ-AUTH ");
+ len = os_snprintf(msg, sizeof(msg), "AKA-REQ-AUTH ");
if (len < 0 || len + identity_len >= sizeof(msg))
return EAP_SIM_DB_FAILURE;
- memcpy(msg + len, identity, identity_len);
+ os_memcpy(msg + len, identity, identity_len);
len += identity_len;
wpa_hexdump(MSG_DEBUG, "EAP-SIM DB: requesting AKA authentication "
@@ -1182,7 +1184,7 @@ int eap_sim_db_get_aka_auth(void *priv, const u8 *identity,
os_get_time(&entry->timestamp);
entry->aka = 1;
- memcpy(entry->imsi, identity, identity_len);
+ os_memcpy(entry->imsi, identity, identity_len);
entry->imsi_len = identity_len;
entry->cb_session_ctx = cb_session_ctx;
entry->state = PENDING;
@@ -1225,19 +1227,19 @@ int eap_sim_db_resynchronize(void *priv, const u8 *identity,
char msg[100];
int len, ret;
- len = snprintf(msg, sizeof(msg), "AKA-AUTS ");
+ len = os_snprintf(msg, sizeof(msg), "AKA-AUTS ");
if (len < 0 || len + identity_len - 1 >= sizeof(msg))
return -1;
- memcpy(msg + len, identity + 1, identity_len - 1);
+ os_memcpy(msg + len, identity + 1, identity_len - 1);
len += identity_len - 1;
- ret = snprintf(msg + len, sizeof(msg) - len, " ");
+ ret = os_snprintf(msg + len, sizeof(msg) - len, " ");
if (ret < 0 || (size_t) ret >= sizeof(msg) - len)
return -1;
len += ret;
len += wpa_snprintf_hex(msg + len, sizeof(msg) - len,
auts, EAP_AKA_AUTS_LEN);
- ret = snprintf(msg + len, sizeof(msg) - len, " ");
+ ret = os_snprintf(msg + len, sizeof(msg) - len, " ");
if (ret < 0 || (size_t) ret >= sizeof(msg) - len)
return -1;
len += ret;
diff --git a/src/eap_server/eap_tls.c b/src/eap_server/eap_tls.c
index ed973bd..a490928 100644
--- a/src/eap_server/eap_tls.c
+++ b/src/eap_server/eap_tls.c
@@ -54,7 +54,7 @@ static void eap_tls_reset(struct eap_sm *sm, void *priv)
if (data == NULL)
return;
eap_server_tls_ssl_deinit(sm, &data->ssl);
- free(data);
+ os_free(data);
}
@@ -65,7 +65,7 @@ static u8 * eap_tls_build_start(struct eap_sm *sm, struct eap_tls_data *data,
u8 *pos;
*reqDataLen = sizeof(*req) + 2;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-TLS: Failed to allocate memory for "
"request");
@@ -172,7 +172,7 @@ static void eap_tls_process(struct eap_sm *sm, void *priv,
if (data->ssl.tls_in_left == 0) {
data->ssl.tls_in_total = tls_msg_len;
data->ssl.tls_in_left = tls_msg_len;
- free(data->ssl.tls_in);
+ os_free(data->ssl.tls_in);
data->ssl.tls_in = NULL;
data->ssl.tls_in_len = 0;
}
@@ -237,11 +237,11 @@ static u8 * eap_tls_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
"client EAP encryption",
EAP_TLS_KEY_LEN + EAP_EMSK_LEN);
if (eapKeyData) {
- emsk = malloc(EAP_EMSK_LEN);
+ emsk = os_malloc(EAP_EMSK_LEN);
if (emsk)
- memcpy(emsk, eapKeyData + EAP_TLS_KEY_LEN,
- EAP_EMSK_LEN);
- free(eapKeyData);
+ os_memcpy(emsk, eapKeyData + EAP_TLS_KEY_LEN,
+ EAP_EMSK_LEN);
+ os_free(eapKeyData);
} else
emsk = NULL;
diff --git a/src/eap_server/eap_tls_common.c b/src/eap_server/eap_tls_common.c
index ebd6afa..60c9e8e 100644
--- a/src/eap_server/eap_tls_common.c
+++ b/src/eap_server/eap_tls_common.c
@@ -58,8 +58,8 @@ int eap_server_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
void eap_server_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data)
{
tls_connection_deinit(sm->ssl_ctx, data->conn);
- free(data->tls_in);
- free(data->tls_out);
+ os_free(data->tls_in);
+ os_free(data->tls_out);
}
@@ -69,7 +69,7 @@ u8 * eap_server_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
struct tls_keys keys;
u8 *rnd = NULL, *out;
- out = malloc(len);
+ out = os_malloc(len);
if (out == NULL)
return NULL;
@@ -84,24 +84,24 @@ u8 * eap_server_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
keys.master_key == NULL)
goto fail;
- rnd = malloc(keys.client_random_len + keys.server_random_len);
+ rnd = os_malloc(keys.client_random_len + keys.server_random_len);
if (rnd == NULL)
goto fail;
- memcpy(rnd, keys.client_random, keys.client_random_len);
- memcpy(rnd + keys.client_random_len, keys.server_random,
- keys.server_random_len);
+ os_memcpy(rnd, keys.client_random, keys.client_random_len);
+ os_memcpy(rnd + keys.client_random_len, keys.server_random,
+ keys.server_random_len);
if (tls_prf(keys.master_key, keys.master_key_len,
label, rnd, keys.client_random_len +
keys.server_random_len, out, len))
goto fail;
- free(rnd);
+ os_free(rnd);
return out;
fail:
- free(out);
- free(rnd);
+ os_free(out);
+ os_free(rnd);
return NULL;
}
@@ -116,23 +116,23 @@ int eap_server_tls_data_reassemble(struct eap_sm *sm,
if (data->tls_in_len + *in_len > 65536) {
/* Limit length to avoid rogue peers from causing large
* memory allocations. */
- free(data->tls_in);
+ os_free(data->tls_in);
data->tls_in = NULL;
data->tls_in_len = 0;
wpa_printf(MSG_INFO, "SSL: Too long TLS fragment (size"
" over 64 kB)");
return -1;
}
- buf = realloc(data->tls_in, data->tls_in_len + *in_len);
+ buf = os_realloc(data->tls_in, data->tls_in_len + *in_len);
if (buf == NULL) {
- free(data->tls_in);
+ os_free(data->tls_in);
data->tls_in = NULL;
data->tls_in_len = 0;
wpa_printf(MSG_INFO, "SSL: Could not allocate memory "
"for TLS data");
return -1;
}
- memcpy(buf + data->tls_in_len, *in_data, *in_len);
+ os_memcpy(buf + data->tls_in_len, *in_data, *in_len);
data->tls_in = buf;
data->tls_in_len += *in_len;
if (*in_len > data->tls_in_left) {
@@ -178,7 +178,7 @@ int eap_server_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
wpa_printf(MSG_INFO, "SSL: eap_tls_process_helper - "
"pending tls_out data even though "
"tls_out_len = 0");
- free(data->tls_out);
+ os_free(data->tls_out);
WPA_ASSERT(data->tls_out == NULL);
}
data->tls_out = tls_connection_server_handshake(
@@ -187,7 +187,7 @@ int eap_server_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
/* Clear reassembled input data (if the buffer was needed). */
data->tls_in_left = data->tls_in_total = data->tls_in_len = 0;
- free(data->tls_in);
+ os_free(data->tls_in);
data->tls_in = NULL;
}
@@ -201,7 +201,7 @@ int eap_server_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
* needing more that should have been catched above based on
* the TLS Message Length field. */
wpa_printf(MSG_DEBUG, "SSL: No data to be sent out");
- free(data->tls_out);
+ os_free(data->tls_out);
data->tls_out = NULL;
if (tls_connection_get_read_alerts(sm->ssl_ctx, data->conn)) {
@@ -233,7 +233,7 @@ int eap_server_tls_buildReq_helper(struct eap_sm *sm,
*out_len = 0;
- req = malloc(sizeof(struct eap_hdr) + 2 + 4 + data->tls_out_limit);
+ req = os_malloc(sizeof(struct eap_hdr) + 2 + 4 + data->tls_out_limit);
if (req == NULL) {
*out_data = NULL;
return -1;
@@ -258,7 +258,7 @@ int eap_server_tls_buildReq_helper(struct eap_sm *sm,
wpa_printf(MSG_DEBUG, "SSL: sending %lu bytes, more fragments "
"will follow", (unsigned long) len);
}
- memcpy(pos, &data->tls_out[data->tls_out_pos], len);
+ os_memcpy(pos, &data->tls_out[data->tls_out_pos], len);
data->tls_out_pos += len;
*out_len = (pos - (u8 *) req) + len;
req->length = host_to_be16(*out_len);
@@ -267,7 +267,7 @@ int eap_server_tls_buildReq_helper(struct eap_sm *sm,
if (!(*flags & EAP_TLS_FLAGS_MORE_FRAGMENTS)) {
data->tls_out_len = 0;
data->tls_out_pos = 0;
- free(data->tls_out);
+ os_free(data->tls_out);
data->tls_out = NULL;
}
@@ -282,7 +282,7 @@ u8 * eap_server_tls_build_ack(size_t *reqDataLen, u8 id, int eap_type,
u8 *pos;
*reqDataLen = sizeof(struct eap_hdr) + 2;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL)
return NULL;
wpa_printf(MSG_DEBUG, "SSL: Building ACK");
diff --git a/src/eap_server/eap_tlv.c b/src/eap_server/eap_tlv.c
index c13b60e..714796f 100644
--- a/src/eap_server/eap_tlv.c
+++ b/src/eap_server/eap_tlv.c
@@ -40,7 +40,7 @@ static void * eap_tlv_init(struct eap_sm *sm)
static void eap_tlv_reset(struct eap_sm *sm, void *priv)
{
struct eap_tlv_data *data = priv;
- free(data);
+ os_free(data);
}
@@ -58,7 +58,7 @@ static u8 * eap_tlv_buildReq(struct eap_sm *sm, void *priv, int id,
}
*reqDataLen = sizeof(struct eap_hdr) + 1 + 6;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL)
return NULL;
diff --git a/src/eap_server/eap_ttls.c b/src/eap_server/eap_ttls.c
index 13fc14b..aaaf801 100644
--- a/src/eap_server/eap_ttls.c
+++ b/src/eap_server/eap_ttls.c
@@ -121,18 +121,18 @@ static int eap_ttls_avp_encapsulate(u8 **resp, size_t *resp_len, u32 avp_code,
{
u8 *avp, *pos;
- avp = malloc(sizeof(struct ttls_avp) + *resp_len + 4);
+ avp = os_malloc(sizeof(struct ttls_avp) + *resp_len + 4);
if (avp == NULL) {
- free(*resp);
+ os_free(*resp);
*resp_len = 0;
return -1;
}
pos = eap_ttls_avp_hdr(avp, avp_code, 0, mandatory, *resp_len);
- memcpy(pos, *resp, *resp_len);
+ os_memcpy(pos, *resp, *resp_len);
pos += *resp_len;
AVP_PAD(avp, pos);
- free(*resp);
+ os_free(*resp);
*resp = avp;
*resp_len = pos - avp;
return 0;
@@ -170,7 +170,7 @@ static int eap_ttls_avp_parse(u8 *buf, size_t len, struct eap_ttls_avp *parse)
pos = buf;
left = len;
- memset(parse, 0, sizeof(*parse));
+ os_memset(parse, 0, sizeof(*parse));
while (left > 0) {
u32 avp_code, avp_length, vendor_id = 0;
@@ -215,25 +215,25 @@ static int eap_ttls_avp_parse(u8 *buf, size_t len, struct eap_ttls_avp *parse)
if (vendor_id == 0 && avp_code == RADIUS_ATTR_EAP_MESSAGE) {
wpa_printf(MSG_DEBUG, "EAP-TTLS: AVP - EAP Message");
if (parse->eap == NULL) {
- parse->eap = malloc(dlen);
+ parse->eap = os_malloc(dlen);
if (parse->eap == NULL) {
wpa_printf(MSG_WARNING, "EAP-TTLS: "
"failed to allocate memory "
"for Phase 2 EAP data");
goto fail;
}
- memcpy(parse->eap, dpos, dlen);
+ os_memcpy(parse->eap, dpos, dlen);
parse->eap_len = dlen;
} else {
- u8 *neweap = realloc(parse->eap,
- parse->eap_len + dlen);
+ u8 *neweap = os_realloc(parse->eap,
+ parse->eap_len + dlen);
if (neweap == NULL) {
wpa_printf(MSG_WARNING, "EAP-TTLS: "
"failed to allocate memory "
"for Phase 2 EAP data");
goto fail;
}
- memcpy(neweap + parse->eap_len, dpos, dlen);
+ os_memcpy(neweap + parse->eap_len, dpos, dlen);
parse->eap = neweap;
parse->eap_len += dlen;
}
@@ -310,7 +310,7 @@ static int eap_ttls_avp_parse(u8 *buf, size_t len, struct eap_ttls_avp *parse)
return 0;
fail:
- free(parse->eap);
+ os_free(parse->eap);
parse->eap = NULL;
return -1;
}
@@ -327,7 +327,7 @@ static u8 * eap_ttls_implicit_challenge(struct eap_sm *sm,
"ttls challenge", len);
}
- memset(&keys, 0, sizeof(keys));
+ os_memset(&keys, 0, sizeof(keys));
if (tls_connection_get_keys(sm->ssl_ctx, data->ssl.conn, &keys) ||
keys.client_random == NULL || keys.server_random == NULL ||
keys.inner_secret == NULL) {
@@ -337,18 +337,18 @@ static u8 * eap_ttls_implicit_challenge(struct eap_sm *sm,
return NULL;
}
- rnd = malloc(keys.client_random_len + keys.server_random_len);
- challenge = malloc(len);
+ rnd = os_malloc(keys.client_random_len + keys.server_random_len);
+ challenge = os_malloc(len);
if (rnd == NULL || challenge == NULL) {
wpa_printf(MSG_INFO, "EAP-TTLS: No memory for implicit "
"challenge derivation");
- free(rnd);
- free(challenge);
+ os_free(rnd);
+ os_free(challenge);
return NULL;
}
- memcpy(rnd, keys.server_random, keys.server_random_len);
- memcpy(rnd + keys.server_random_len, keys.client_random,
- keys.client_random_len);
+ os_memcpy(rnd, keys.server_random, keys.server_random_len);
+ os_memcpy(rnd + keys.server_random_len, keys.client_random,
+ keys.client_random_len);
if (tls_prf(keys.inner_secret, keys.inner_secret_len,
"inner application challenge", rnd,
@@ -356,12 +356,12 @@ static u8 * eap_ttls_implicit_challenge(struct eap_sm *sm,
challenge, len)) {
wpa_printf(MSG_DEBUG, "EAP-TTLS: Failed to derive implicit "
"challenge");
- free(rnd);
- free(challenge);
+ os_free(rnd);
+ os_free(challenge);
return NULL;
}
- free(rnd);
+ os_free(rnd);
wpa_hexdump_key(MSG_DEBUG, "EAP-TTLS: Derived implicit challenge",
challenge, len);
@@ -417,7 +417,7 @@ static void eap_ttls_reset(struct eap_sm *sm, void *priv)
if (data->phase2_priv && data->phase2_method)
data->phase2_method->reset(sm, data->phase2_priv);
eap_server_tls_ssl_deinit(sm, &data->ssl);
- free(data);
+ os_free(data);
}
@@ -428,7 +428,7 @@ static u8 * eap_ttls_build_start(struct eap_sm *sm, struct eap_ttls_data *data,
u8 *pos;
*reqDataLen = sizeof(*req) + 2;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-TTLS: Failed to allocate memory for"
" request");
@@ -482,7 +482,7 @@ static u8 * eap_ttls_encrypt(struct eap_sm *sm, struct eap_ttls_data *data,
/* TODO: add support for fragmentation, if needed. This will need to
* add TLS Message Length field, if the frame is fragmented. */
- req = malloc(sizeof(struct eap_hdr) + 2 + data->ssl.tls_out_limit);
+ req = os_malloc(sizeof(struct eap_hdr) + 2 + data->ssl.tls_out_limit);
if (req == NULL)
return NULL;
@@ -499,7 +499,7 @@ static u8 * eap_ttls_encrypt(struct eap_sm *sm, struct eap_ttls_data *data,
if (res < 0) {
wpa_printf(MSG_INFO, "EAP-TTLS: Failed to encrypt Phase 2 "
"data");
- free(req);
+ os_free(req);
return NULL;
}
@@ -536,7 +536,7 @@ static u8 * eap_ttls_build_phase2_eap_req(struct eap_sm *sm,
"2 data", req, req_len);
encr_req = eap_ttls_encrypt(sm, data, id, req, req_len, reqDataLen);
- free(req);
+ os_free(req);
return encr_req;
}
@@ -550,7 +550,7 @@ static u8 * eap_ttls_build_phase2_mschapv2(struct eap_sm *sm,
int ret;
size_t req_len;
- pos = req = malloc(100);
+ pos = req = os_malloc(100);
if (req == NULL)
return NULL;
end = req + 100;
@@ -559,7 +559,7 @@ static u8 * eap_ttls_build_phase2_mschapv2(struct eap_sm *sm,
pos = eap_ttls_avp_hdr(pos, RADIUS_ATTR_MS_CHAP2_SUCCESS,
RADIUS_VENDOR_ID_MICROSOFT, 1, 43);
*pos++ = data->mschapv2_ident;
- ret = snprintf((char *) pos, end - pos, "S=");
+ ret = os_snprintf((char *) pos, end - pos, "S=");
if (ret >= 0 && ret < end - pos)
pos += ret;
pos += wpa_snprintf_hex_uppercase(
@@ -568,7 +568,7 @@ static u8 * eap_ttls_build_phase2_mschapv2(struct eap_sm *sm,
} else {
pos = eap_ttls_avp_hdr(pos, RADIUS_ATTR_MS_CHAP_ERROR,
RADIUS_VENDOR_ID_MICROSOFT, 1, 6);
- memcpy(pos, "Failed", 6);
+ os_memcpy(pos, "Failed", 6);
pos += 6;
AVP_PAD(req, pos);
}
@@ -578,7 +578,7 @@ static u8 * eap_ttls_build_phase2_mschapv2(struct eap_sm *sm,
"data", req, req_len);
encr_req = eap_ttls_encrypt(sm, data, id, req, req_len, reqDataLen);
- free(req);
+ os_free(req);
return encr_req;
}
@@ -595,7 +595,7 @@ static u8 * eap_ttls_build_phase_finished(struct eap_sm *sm,
const int max_len = 300;
len = sizeof(struct eap_hdr) + 2 + max_len;
- req = malloc(len);
+ req = os_malloc(len);
if (req == NULL)
return NULL;
@@ -610,7 +610,7 @@ static u8 * eap_ttls_build_phase_finished(struct eap_sm *sm,
data->ssl.conn,
final, pos, max_len);
if (len < 0) {
- free(req);
+ os_free(req);
return NULL;
}
@@ -675,11 +675,11 @@ static int eap_ttls_ia_permute_inner_secret(struct eap_sm *sm,
if (key) {
buf_len = 2 + key_len;
- buf = malloc(buf_len);
+ buf = os_malloc(buf_len);
if (buf == NULL)
return -1;
WPA_PUT_BE16(buf, key_len);
- memcpy(buf + 2, key, key_len);
+ os_memcpy(buf + 2, key, key_len);
} else {
buf = NULL;
buf_len = 0;
@@ -690,7 +690,7 @@ static int eap_ttls_ia_permute_inner_secret(struct eap_sm *sm,
ret = tls_connection_ia_permute_inner_secret(sm->ssl_ctx,
data->ssl.conn,
buf, buf_len);
- free(buf);
+ os_free(buf);
return ret;
}
@@ -711,8 +711,8 @@ static void eap_ttls_process_phase2_pap(struct eap_sm *sm,
}
if (sm->user->password_len != user_password_len ||
- memcmp(sm->user->password, user_password, user_password_len) != 0)
- {
+ os_memcmp(sm->user->password, user_password, user_password_len) !=
+ 0) {
wpa_printf(MSG_DEBUG, "EAP-TTLS/PAP: Invalid user password");
eap_ttls_state(data, FAILURE);
return;
@@ -764,14 +764,14 @@ static void eap_ttls_process_phase2_chap(struct eap_sm *sm,
return;
}
- if (memcmp(challenge, chal, EAP_TTLS_CHAP_CHALLENGE_LEN) != 0 ||
+ if (os_memcmp(challenge, chal, EAP_TTLS_CHAP_CHALLENGE_LEN) != 0 ||
password[0] != chal[EAP_TTLS_CHAP_CHALLENGE_LEN]) {
wpa_printf(MSG_DEBUG, "EAP-TTLS/CHAP: Challenge mismatch");
- free(chal);
+ os_free(chal);
eap_ttls_state(data, FAILURE);
return;
}
- free(chal);
+ os_free(chal);
/* MD5(Ident + Password + Challenge) */
addr[0] = password;
@@ -782,7 +782,7 @@ static void eap_ttls_process_phase2_chap(struct eap_sm *sm,
len[2] = challenge_len;
md5_vector(3, addr, len, hash);
- if (memcmp(hash, password + 1, EAP_TTLS_CHAP_PASSWORD_LEN) == 0) {
+ if (os_memcmp(hash, password + 1, EAP_TTLS_CHAP_PASSWORD_LEN) == 0) {
wpa_printf(MSG_DEBUG, "EAP-TTLS/CHAP: Correct user password");
eap_ttls_state(data, data->ttls_version > 0 ? PHASE_FINISHED :
SUCCESS);
@@ -829,14 +829,14 @@ static void eap_ttls_process_phase2_mschap(struct eap_sm *sm,
return;
}
- if (memcmp(challenge, chal, EAP_TTLS_MSCHAP_CHALLENGE_LEN) != 0 ||
+ if (os_memcmp(challenge, chal, EAP_TTLS_MSCHAP_CHALLENGE_LEN) != 0 ||
response[0] != chal[EAP_TTLS_MSCHAP_CHALLENGE_LEN]) {
wpa_printf(MSG_DEBUG, "EAP-TTLS/MSCHAP: Challenge mismatch");
- free(chal);
+ os_free(chal);
eap_ttls_state(data, FAILURE);
return;
}
- free(chal);
+ os_free(chal);
if (sm->user->password_hash)
challenge_response(challenge, sm->user->password, nt_response);
@@ -844,7 +844,7 @@ static void eap_ttls_process_phase2_mschap(struct eap_sm *sm,
nt_challenge_response(challenge, sm->user->password,
sm->user->password_len, nt_response);
- if (memcmp(nt_response, response + 2 + 24, 24) == 0) {
+ if (os_memcmp(nt_response, response + 2 + 24, 24) == 0) {
wpa_printf(MSG_DEBUG, "EAP-TTLS/MSCHAP: Correct response");
eap_ttls_state(data, data->ttls_version > 0 ? PHASE_FINISHED :
SUCCESS);
@@ -911,14 +911,14 @@ static void eap_ttls_process_phase2_mschapv2(struct eap_sm *sm,
return;
}
- if (memcmp(challenge, chal, EAP_TTLS_MSCHAPV2_CHALLENGE_LEN) != 0 ||
+ if (os_memcmp(challenge, chal, EAP_TTLS_MSCHAPV2_CHALLENGE_LEN) != 0 ||
response[0] != chal[EAP_TTLS_MSCHAPV2_CHALLENGE_LEN]) {
wpa_printf(MSG_DEBUG, "EAP-TTLS/MSCHAPV2: Challenge mismatch");
- free(chal);
+ os_free(chal);
eap_ttls_state(data, FAILURE);
return;
}
- free(chal);
+ os_free(chal);
auth_challenge = challenge;
peer_challenge = response + 2;
@@ -944,7 +944,7 @@ static void eap_ttls_process_phase2_mschapv2(struct eap_sm *sm,
}
rx_resp = response + 2 + EAP_TTLS_MSCHAPV2_CHALLENGE_LEN + 8;
- if (memcmp(nt_response, rx_resp, 24) == 0) {
+ if (os_memcmp(nt_response, rx_resp, 24) == 0) {
wpa_printf(MSG_DEBUG, "EAP-TTLS/MSCHAPV2: Correct "
"NT-Response");
data->mschapv2_resp_ok = 1;
@@ -1187,9 +1187,9 @@ static void eap_ttls_process_phase2(struct eap_sm *sm,
buf_len = in_len;
if (data->ssl.tls_in_total > buf_len)
buf_len = data->ssl.tls_in_total;
- in_decrypted = malloc(buf_len);
+ in_decrypted = os_malloc(buf_len);
if (in_decrypted == NULL) {
- free(data->ssl.tls_in);
+ os_free(data->ssl.tls_in);
data->ssl.tls_in = NULL;
data->ssl.tls_in_len = 0;
wpa_printf(MSG_WARNING, "EAP-TTLS: failed to allocate memory "
@@ -1200,13 +1200,13 @@ static void eap_ttls_process_phase2(struct eap_sm *sm,
len_decrypted = tls_connection_decrypt(sm->ssl_ctx, data->ssl.conn,
in_data, in_len,
in_decrypted, buf_len);
- free(data->ssl.tls_in);
+ os_free(data->ssl.tls_in);
data->ssl.tls_in = NULL;
data->ssl.tls_in_len = 0;
if (len_decrypted < 0) {
wpa_printf(MSG_INFO, "EAP-TTLS: Failed to decrypt Phase 2 "
"data");
- free(in_decrypted);
+ os_free(in_decrypted);
eap_ttls_state(data, FAILURE);
return;
}
@@ -1224,7 +1224,7 @@ static void eap_ttls_process_phase2(struct eap_sm *sm,
eap_ttls_state(data, FAILURE);
}
- free(in_decrypted);
+ os_free(in_decrypted);
return;
}
@@ -1233,17 +1233,17 @@ static void eap_ttls_process_phase2(struct eap_sm *sm,
if (eap_ttls_avp_parse(in_decrypted, len_decrypted, &parse) < 0) {
wpa_printf(MSG_DEBUG, "EAP-TTLS: Failed to parse AVPs");
- free(in_decrypted);
+ os_free(in_decrypted);
eap_ttls_state(data, FAILURE);
return;
}
if (parse.user_name) {
- free(sm->identity);
- sm->identity = malloc(parse.user_name_len);
+ os_free(sm->identity);
+ sm->identity = os_malloc(parse.user_name_len);
if (sm->identity) {
- memcpy(sm->identity, parse.user_name,
- parse.user_name_len);
+ os_memcpy(sm->identity, parse.user_name,
+ parse.user_name_len);
sm->identity_len = parse.user_name_len;
}
if (eap_user_get(sm, parse.user_name, parse.user_name_len, 1)
@@ -1282,8 +1282,8 @@ static void eap_ttls_process_phase2(struct eap_sm *sm,
}
done:
- free(in_decrypted);
- free(parse.eap);
+ os_free(in_decrypted);
+ os_free(parse.eap);
}
@@ -1335,7 +1335,7 @@ static void eap_ttls_process(struct eap_sm *sm, void *priv,
if (data->ssl.tls_in_left == 0) {
data->ssl.tls_in_total = tls_msg_len;
data->ssl.tls_in_left = tls_msg_len;
- free(data->ssl.tls_in);
+ os_free(data->ssl.tls_in);
data->ssl.tls_in = NULL;
data->ssl.tls_in_len = 0;
}
@@ -1401,7 +1401,7 @@ static u8 * eap_ttls_v1_derive_key(struct eap_sm *sm,
struct tls_keys keys;
u8 *rnd, *key;
- memset(&keys, 0, sizeof(keys));
+ os_memset(&keys, 0, sizeof(keys));
if (tls_connection_get_keys(sm->ssl_ctx, data->ssl.conn, &keys) ||
keys.client_random == NULL || keys.server_random == NULL ||
keys.inner_secret == NULL) {
@@ -1411,24 +1411,24 @@ static u8 * eap_ttls_v1_derive_key(struct eap_sm *sm,
return NULL;
}
- rnd = malloc(keys.client_random_len + keys.server_random_len);
- key = malloc(EAP_TLS_KEY_LEN);
+ rnd = os_malloc(keys.client_random_len + keys.server_random_len);
+ key = os_malloc(EAP_TLS_KEY_LEN);
if (rnd == NULL || key == NULL) {
wpa_printf(MSG_INFO, "EAP-TTLS: No memory for key derivation");
- free(rnd);
- free(key);
+ os_free(rnd);
+ os_free(key);
return NULL;
}
- memcpy(rnd, keys.client_random, keys.client_random_len);
- memcpy(rnd + keys.client_random_len, keys.server_random,
- keys.server_random_len);
+ os_memcpy(rnd, keys.client_random, keys.client_random_len);
+ os_memcpy(rnd + keys.client_random_len, keys.server_random,
+ keys.server_random_len);
if (tls_prf(keys.inner_secret, keys.inner_secret_len,
"ttls v1 keying material", rnd, keys.client_random_len +
keys.server_random_len, key, EAP_TLS_KEY_LEN)) {
wpa_printf(MSG_DEBUG, "EAP-TTLS: Failed to derive key");
- free(rnd);
- free(key);
+ os_free(rnd);
+ os_free(key);
return NULL;
}
@@ -1437,7 +1437,7 @@ static u8 * eap_ttls_v1_derive_key(struct eap_sm *sm,
wpa_hexdump_key(MSG_DEBUG, "EAP-TTLS: TLS/IA inner secret",
keys.inner_secret, keys.inner_secret_len);
- free(rnd);
+ os_free(rnd);
return key;
}
diff --git a/src/eap_server/eap_vendor_test.c b/src/eap_server/eap_vendor_test.c
index df1ea1e..58d9ae3 100644
--- a/src/eap_server/eap_vendor_test.c
+++ b/src/eap_server/eap_vendor_test.c
@@ -70,7 +70,7 @@ static void * eap_vendor_test_init(struct eap_sm *sm)
static void eap_vendor_test_reset(struct eap_sm *sm, void *priv)
{
struct eap_vendor_test_data *data = priv;
- free(data);
+ os_free(data);
}
@@ -82,7 +82,7 @@ static u8 * eap_vendor_test_buildReq(struct eap_sm *sm, void *priv, int id,
u8 *pos;
*reqDataLen = sizeof(*req) + 8 + 1;
- req = malloc(*reqDataLen);
+ req = os_malloc(*reqDataLen);
if (req == NULL) {
wpa_printf(MSG_ERROR, "EAP-VENDOR-TEST: Failed to allocate "
"memory for request");
@@ -181,12 +181,12 @@ static u8 * eap_vendor_test_getKey(struct eap_sm *sm, void *priv, size_t *len)
if (data->state != SUCCESS)
return NULL;
- key = malloc(key_len);
+ key = os_malloc(key_len);
if (key == NULL)
return NULL;
- memset(key, 0x11, key_len / 2);
- memset(key + key_len / 2, 0x22, key_len / 2);
+ os_memset(key, 0x11, key_len / 2);
+ os_memset(key + key_len / 2, 0x22, key_len / 2);
*len = key_len;
return key;
diff --git a/src/radius/radius_client.c b/src/radius/radius_client.c
index 198c9b8..e76e29e 100644
--- a/src/radius/radius_client.c
+++ b/src/radius/radius_client.c
@@ -1170,8 +1170,8 @@ static int radius_servers_diff(struct hostapd_radius_server *nserv,
if (hostapd_ip_diff(&nserv[i].addr, &oserv[i].addr) ||
nserv[i].port != oserv[i].port ||
nserv[i].shared_secret_len != oserv[i].shared_secret_len ||
- memcmp(nserv[i].shared_secret, oserv[i].shared_secret,
- nserv[i].shared_secret_len) != 0)
+ os_memcmp(nserv[i].shared_secret, oserv[i].shared_secret,
+ nserv[i].shared_secret_len) != 0)
return 1;
}
diff --git a/src/radius/radius_server.c b/src/radius/radius_server.c
index bc9aef2..bb05104 100644
--- a/src/radius/radius_server.c
+++ b/src/radius/radius_server.c
@@ -172,14 +172,14 @@ static void radius_server_session_free(struct radius_server_data *data,
eap_server_sm_deinit(sess->eap);
if (sess->last_msg) {
radius_msg_free(sess->last_msg);
- free(sess->last_msg);
+ os_free(sess->last_msg);
}
- free(sess->last_from_addr);
+ os_free(sess->last_from_addr);
if (sess->last_reply) {
radius_msg_free(sess->last_reply);
- free(sess->last_reply);
+ os_free(sess->last_reply);
}
- free(sess);
+ os_free(sess);
data->num_sess--;
}
@@ -274,21 +274,21 @@ radius_server_get_new_session(struct radius_server_data *data,
RADIUS_DEBUG("Creating a new session");
- user = malloc(256);
+ user = os_malloc(256);
if (user == NULL) {
return NULL;
}
res = radius_msg_get_attr(msg, RADIUS_ATTR_USER_NAME, user, 256);
if (res < 0 || res > 256) {
RADIUS_DEBUG("Could not get User-Name");
- free(user);
+ os_free(user);
return NULL;
}
user_len = res;
RADIUS_DUMP_ASCII("User-Name", user, user_len);
res = data->get_eap_user(data->conf_ctx, user, user_len, 0, NULL);
- free(user);
+ os_free(user);
if (res == 0) {
RADIUS_DEBUG("Matching user entry found");
@@ -302,7 +302,7 @@ radius_server_get_new_session(struct radius_server_data *data,
return NULL;
}
- memset(&eap_conf, 0, sizeof(eap_conf));
+ os_memset(&eap_conf, 0, sizeof(eap_conf));
eap_conf.ssl_ctx = data->ssl_ctx;
eap_conf.eap_sim_db_priv = data->eap_sim_db_priv;
eap_conf.backend_auth = TRUE;
@@ -410,7 +410,7 @@ static int radius_server_reject(struct radius_server_data *data,
return -1;
}
- memset(&eapfail, 0, sizeof(eapfail));
+ os_memset(&eapfail, 0, sizeof(eapfail));
eapfail.code = EAP_CODE_FAILURE;
eapfail.identifier = 0;
eapfail.length = host_to_be16(sizeof(eapfail));
@@ -439,7 +439,7 @@ static int radius_server_reject(struct radius_server_data *data,
}
radius_msg_free(msg);
- free(msg);
+ os_free(msg);
return ret;
}
@@ -556,14 +556,14 @@ static int radius_server_request(struct radius_server_data *data,
} else if (eap_sm_method_pending(sess->eap)) {
if (sess->last_msg) {
radius_msg_free(sess->last_msg);
- free(sess->last_msg);
+ os_free(sess->last_msg);
}
sess->last_msg = msg;
sess->last_from_port = from_port;
- free(sess->last_from_addr);
- sess->last_from_addr = strdup(from_addr);
+ os_free(sess->last_from_addr);
+ sess->last_from_addr = os_strdup(from_addr);
sess->last_fromlen = fromlen;
- memcpy(&sess->last_from, from, fromlen);
+ os_memcpy(&sess->last_from, from, fromlen);
return -2;
} else {
RADIUS_DEBUG("No EAP data from the state machine - ignore this"
@@ -603,7 +603,7 @@ static int radius_server_request(struct radius_server_data *data,
}
if (sess->last_reply) {
radius_msg_free(sess->last_reply);
- free(sess->last_reply);
+ os_free(sess->last_reply);
}
sess->last_reply = reply;
sess->last_from_port = from_port;
@@ -642,7 +642,7 @@ static void radius_server_receive_auth(int sock, void *eloop_ctx,
char abuf[50];
int from_port = 0;
- buf = malloc(RADIUS_MAX_MSG_LEN);
+ buf = os_malloc(RADIUS_MAX_MSG_LEN);
if (buf == NULL) {
goto fail;
}
@@ -697,7 +697,7 @@ static void radius_server_receive_auth(int sock, void *eloop_ctx,
goto fail;
}
- free(buf);
+ os_free(buf);
buf = NULL;
if (wpa_debug_level <= MSG_MSGDUMP) {
@@ -730,9 +730,9 @@ static void radius_server_receive_auth(int sock, void *eloop_ctx,
fail:
if (msg) {
radius_msg_free(msg);
- free(msg);
+ os_free(msg);
}
- free(buf);
+ os_free(buf);
}
@@ -747,7 +747,7 @@ static int radius_server_open_socket(int port)
return -1;
}
- memset(&addr, 0, sizeof(addr));
+ os_memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
@@ -772,9 +772,9 @@ static int radius_server_open_socket6(int port)
return -1;
}
- memset(&addr, 0, sizeof(addr));
+ os_memset(&addr, 0, sizeof(addr));
addr.sin6_family = AF_INET6;
- memcpy(&addr.sin6_addr, &in6addr_any, sizeof(in6addr_any));
+ os_memcpy(&addr.sin6_addr, &in6addr_any, sizeof(in6addr_any));
addr.sin6_port = htons(port);
if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("bind");
@@ -812,8 +812,8 @@ static void radius_server_free_clients(struct radius_server_data *data,
client = client->next;
radius_server_free_sessions(data, prev->sessions);
- free(prev->shared_secret);
- free(prev);
+ os_free(prev->shared_secret);
+ os_free(prev);
}
}
@@ -838,7 +838,7 @@ radius_server_read_clients(const char *client_file, int ipv6)
return NULL;
}
- buf = malloc(buf_size);
+ buf = os_malloc(buf_size);
if (buf == NULL) {
fclose(f);
return NULL;
@@ -901,10 +901,11 @@ radius_server_read_clients(const char *client_file, int ipv6)
/* Convert IPv4 address to IPv6 */
if (mask <= 32)
mask += (128 - 32);
- memset(addr6.s6_addr, 0, 10);
+ os_memset(addr6.s6_addr, 0, 10);
addr6.s6_addr[10] = 0xff;
addr6.s6_addr[11] = 0xff;
- memcpy(addr6.s6_addr + 12, (char *) &addr.s_addr, 4);
+ os_memcpy(addr6.s6_addr + 12, (char *) &addr.s_addr,
+ 4);
}
#endif /* CONFIG_IPV6 */
@@ -922,13 +923,13 @@ radius_server_read_clients(const char *client_file, int ipv6)
failed = 1;
break;
}
- entry->shared_secret = strdup(pos);
+ entry->shared_secret = os_strdup(pos);
if (entry->shared_secret == NULL) {
failed = 1;
- free(entry);
+ os_free(entry);
break;
}
- entry->shared_secret_len = strlen(entry->shared_secret);
+ entry->shared_secret_len = os_strlen(entry->shared_secret);
entry->addr.s_addr = addr.s_addr;
if (!ipv6) {
val = 0;
@@ -940,8 +941,8 @@ radius_server_read_clients(const char *client_file, int ipv6)
if (ipv6) {
int offset = mask / 8;
- memcpy(entry->addr6.s6_addr, addr6.s6_addr, 16);
- memset(entry->mask6.s6_addr, 0xff, offset);
+ os_memcpy(entry->addr6.s6_addr, addr6.s6_addr, 16);
+ os_memset(entry->mask6.s6_addr, 0xff, offset);
val = 0;
for (i = 0; i < (mask % 8); i++)
val |= 1 << (7 - i);
@@ -964,7 +965,7 @@ radius_server_read_clients(const char *client_file, int ipv6)
clients = NULL;
}
- free(buf);
+ os_free(buf);
fclose(f);
return clients;
@@ -1045,7 +1046,7 @@ void radius_server_deinit(struct radius_server_data *data)
radius_server_free_clients(data, data->clients);
- free(data);
+ os_free(data);
}
@@ -1069,40 +1070,40 @@ int radius_server_get_mib(struct radius_server_data *data, char *buf,
os_get_time(&now);
uptime = (now.sec - data->start_time.sec) * 100 +
((now.usec - data->start_time.usec) / 10000) % 100;
- ret = snprintf(pos, end - pos,
- "RADIUS-AUTH-SERVER-MIB\n"
- "radiusAuthServIdent=hostapd\n"
- "radiusAuthServUpTime=%d\n"
- "radiusAuthServResetTime=0\n"
- "radiusAuthServConfigReset=4\n",
- uptime);
+ ret = os_snprintf(pos, end - pos,
+ "RADIUS-AUTH-SERVER-MIB\n"
+ "radiusAuthServIdent=hostapd\n"
+ "radiusAuthServUpTime=%d\n"
+ "radiusAuthServResetTime=0\n"
+ "radiusAuthServConfigReset=4\n",
+ uptime);
if (ret < 0 || ret >= end - pos) {
*pos = '\0';
return pos - buf;
}
pos += ret;
- ret = snprintf(pos, end - pos,
- "radiusAuthServTotalAccessRequests=%u\n"
- "radiusAuthServTotalInvalidRequests=%u\n"
- "radiusAuthServTotalDupAccessRequests=%u\n"
- "radiusAuthServTotalAccessAccepts=%u\n"
- "radiusAuthServTotalAccessRejects=%u\n"
- "radiusAuthServTotalAccessChallenges=%u\n"
- "radiusAuthServTotalMalformedAccessRequests=%u\n"
- "radiusAuthServTotalBadAuthenticators=%u\n"
- "radiusAuthServTotalPacketsDropped=%u\n"
- "radiusAuthServTotalUnknownTypes=%u\n",
- data->counters.access_requests,
- data->counters.invalid_requests,
- data->counters.dup_access_requests,
- data->counters.access_accepts,
- data->counters.access_rejects,
- data->counters.access_challenges,
- data->counters.malformed_access_requests,
- data->counters.bad_authenticators,
- data->counters.packets_dropped,
- data->counters.unknown_types);
+ ret = os_snprintf(pos, end - pos,
+ "radiusAuthServTotalAccessRequests=%u\n"
+ "radiusAuthServTotalInvalidRequests=%u\n"
+ "radiusAuthServTotalDupAccessRequests=%u\n"
+ "radiusAuthServTotalAccessAccepts=%u\n"
+ "radiusAuthServTotalAccessRejects=%u\n"
+ "radiusAuthServTotalAccessChallenges=%u\n"
+ "radiusAuthServTotalMalformedAccessRequests=%u\n"
+ "radiusAuthServTotalBadAuthenticators=%u\n"
+ "radiusAuthServTotalPacketsDropped=%u\n"
+ "radiusAuthServTotalUnknownTypes=%u\n",
+ data->counters.access_requests,
+ data->counters.invalid_requests,
+ data->counters.dup_access_requests,
+ data->counters.access_accepts,
+ data->counters.access_rejects,
+ data->counters.access_challenges,
+ data->counters.malformed_access_requests,
+ data->counters.bad_authenticators,
+ data->counters.packets_dropped,
+ data->counters.unknown_types);
if (ret < 0 || ret >= end - pos) {
*pos = '\0';
return pos - buf;
@@ -1126,29 +1127,29 @@ int radius_server_get_mib(struct radius_server_data *data, char *buf,
os_strlcpy(mbuf, inet_ntoa(cli->mask), sizeof(mbuf));
}
- ret = snprintf(pos, end - pos,
- "radiusAuthClientIndex=%u\n"
- "radiusAuthClientAddress=%s/%s\n"
- "radiusAuthServAccessRequests=%u\n"
- "radiusAuthServDupAccessRequests=%u\n"
- "radiusAuthServAccessAccepts=%u\n"
- "radiusAuthServAccessRejects=%u\n"
- "radiusAuthServAccessChallenges=%u\n"
- "radiusAuthServMalformedAccessRequests=%u\n"
- "radiusAuthServBadAuthenticators=%u\n"
- "radiusAuthServPacketsDropped=%u\n"
- "radiusAuthServUnknownTypes=%u\n",
- idx,
- abuf, mbuf,
- cli->counters.access_requests,
- cli->counters.dup_access_requests,
- cli->counters.access_accepts,
- cli->counters.access_rejects,
- cli->counters.access_challenges,
- cli->counters.malformed_access_requests,
- cli->counters.bad_authenticators,
- cli->counters.packets_dropped,
- cli->counters.unknown_types);
+ ret = os_snprintf(pos, end - pos,
+ "radiusAuthClientIndex=%u\n"
+ "radiusAuthClientAddress=%s/%s\n"
+ "radiusAuthServAccessRequests=%u\n"
+ "radiusAuthServDupAccessRequests=%u\n"
+ "radiusAuthServAccessAccepts=%u\n"
+ "radiusAuthServAccessRejects=%u\n"
+ "radiusAuthServAccessChallenges=%u\n"
+ "radiusAuthServMalformedAccessRequests=%u\n"
+ "radiusAuthServBadAuthenticators=%u\n"
+ "radiusAuthServPacketsDropped=%u\n"
+ "radiusAuthServUnknownTypes=%u\n",
+ idx,
+ abuf, mbuf,
+ cli->counters.access_requests,
+ cli->counters.dup_access_requests,
+ cli->counters.access_accepts,
+ cli->counters.access_rejects,
+ cli->counters.access_challenges,
+ cli->counters.malformed_access_requests,
+ cli->counters.bad_authenticators,
+ cli->counters.packets_dropped,
+ cli->counters.unknown_types);
if (ret < 0 || ret >= end - pos) {
*pos = '\0';
return pos - buf;
@@ -1216,5 +1217,5 @@ void radius_server_eap_pending_cb(struct radius_server_data *data, void *ctx)
return; /* msg was stored with the session */
radius_msg_free(msg);
- free(msg);
+ os_free(msg);
}