mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
Check os_snprintf() result more consistently - automatic 1
This converts os_snprintf() result validation cases to use os_snprintf_error() where the exact rule used in os_snprintf_error() was used. These changes were done automatically with spatch using the following semantic patch: @@ identifier E1; expression E2,E3,E4,E5,E6; statement S1; @@ ( E1 = os_snprintf(E2, E3, ...); | int E1 = os_snprintf(E2, E3, ...); | if (E5) E1 = os_snprintf(E2, E3, ...); else E1 = os_snprintf(E2, E3, ...); | if (E5) E1 = os_snprintf(E2, E3, ...); else if (E6) E1 = os_snprintf(E2, E3, ...); else E1 = 0; | if (E5) { ... E1 = os_snprintf(E2, E3, ...); } else { ... return -1; } | if (E5) { ... E1 = os_snprintf(E2, E3, ...); } else if (E6) { ... E1 = os_snprintf(E2, E3, ...); } else { ... return -1; } | if (E5) { ... E1 = os_snprintf(E2, E3, ...); } else { ... E1 = os_snprintf(E2, E3, ...); } ) ? os_free(E4); - if (E1 < 0 || \( E1 >= E3 \| (size_t) E1 >= E3 \| (unsigned int) E1 >= E3 \| E1 >= (int) E3 \)) + if (os_snprintf_error(E3, E1)) ( S1 | { ... } ) Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
a80ba67a26
commit
d85e1fc8a5
@ -246,14 +246,14 @@ static int hostapd_ctrl_iface_wps_check_pin(
|
|||||||
if (!wps_pin_valid(pin_val)) {
|
if (!wps_pin_valid(pin_val)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Invalid checksum digit");
|
wpa_printf(MSG_DEBUG, "WPS: Invalid checksum digit");
|
||||||
ret = os_snprintf(buf, buflen, "FAIL-CHECKSUM\n");
|
ret = os_snprintf(buf, buflen, "FAIL-CHECKSUM\n");
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return -1;
|
return -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(buf, buflen, "%s", pin);
|
ret = os_snprintf(buf, buflen, "%s", pin);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -584,7 +584,7 @@ static int hostapd_ctrl_iface_wps_get_status(struct hostapd_data *hapd,
|
|||||||
ret = os_snprintf(pos, end - pos, "PBC Status: %s\n",
|
ret = os_snprintf(pos, end - pos, "PBC Status: %s\n",
|
||||||
pbc_status_str(hapd->wps_stats.pbc_status));
|
pbc_status_str(hapd->wps_stats.pbc_status));
|
||||||
|
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -594,7 +594,7 @@ static int hostapd_ctrl_iface_wps_get_status(struct hostapd_data *hapd,
|
|||||||
(hapd->wps_stats.status == WPS_STATUS_FAILURE ?
|
(hapd->wps_stats.status == WPS_STATUS_FAILURE ?
|
||||||
"Failed" : "None")));
|
"Failed" : "None")));
|
||||||
|
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -605,7 +605,7 @@ static int hostapd_ctrl_iface_wps_get_status(struct hostapd_data *hapd,
|
|||||||
"Failure Reason: %s\n",
|
"Failure Reason: %s\n",
|
||||||
wps_ei_str(hapd->wps_stats.failure_reason));
|
wps_ei_str(hapd->wps_stats.failure_reason));
|
||||||
|
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -614,7 +614,7 @@ static int hostapd_ctrl_iface_wps_get_status(struct hostapd_data *hapd,
|
|||||||
ret = os_snprintf(pos, end - pos, "Peer Address: " MACSTR "\n",
|
ret = os_snprintf(pos, end - pos, "Peer Address: " MACSTR "\n",
|
||||||
MAC2STR(hapd->wps_stats.peer_addr));
|
MAC2STR(hapd->wps_stats.peer_addr));
|
||||||
|
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1067,7 +1067,7 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
|
|||||||
MAC2STR(hapd->own_addr),
|
MAC2STR(hapd->own_addr),
|
||||||
wpa_ssid_txt(hapd->conf->ssid.ssid,
|
wpa_ssid_txt(hapd->conf->ssid.ssid,
|
||||||
hapd->conf->ssid.ssid_len));
|
hapd->conf->ssid.ssid_len));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -1076,7 +1076,7 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
|
|||||||
hapd->conf->wps_state == 0 ? "disabled" :
|
hapd->conf->wps_state == 0 ? "disabled" :
|
||||||
(hapd->conf->wps_state == 1 ? "not configured" :
|
(hapd->conf->wps_state == 1 ? "not configured" :
|
||||||
"configured"));
|
"configured"));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -1084,7 +1084,7 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
|
|||||||
hapd->conf->ssid.wpa_passphrase) {
|
hapd->conf->ssid.wpa_passphrase) {
|
||||||
ret = os_snprintf(pos, end - pos, "passphrase=%s\n",
|
ret = os_snprintf(pos, end - pos, "passphrase=%s\n",
|
||||||
hapd->conf->ssid.wpa_passphrase);
|
hapd->conf->ssid.wpa_passphrase);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1096,7 +1096,7 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
|
|||||||
wpa_snprintf_hex(hex, sizeof(hex),
|
wpa_snprintf_hex(hex, sizeof(hex),
|
||||||
hapd->conf->ssid.wpa_psk->psk, PMK_LEN);
|
hapd->conf->ssid.wpa_psk->psk, PMK_LEN);
|
||||||
ret = os_snprintf(pos, end - pos, "psk=%s\n", hex);
|
ret = os_snprintf(pos, end - pos, "psk=%s\n", hex);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1104,39 +1104,39 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
|
|||||||
|
|
||||||
if (hapd->conf->wpa && hapd->conf->wpa_key_mgmt) {
|
if (hapd->conf->wpa && hapd->conf->wpa_key_mgmt) {
|
||||||
ret = os_snprintf(pos, end - pos, "key_mgmt=");
|
ret = os_snprintf(pos, end - pos, "key_mgmt=");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK) {
|
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK) {
|
||||||
ret = os_snprintf(pos, end - pos, "WPA-PSK ");
|
ret = os_snprintf(pos, end - pos, "WPA-PSK ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
|
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
|
||||||
ret = os_snprintf(pos, end - pos, "WPA-EAP ");
|
ret = os_snprintf(pos, end - pos, "WPA-EAP ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_IEEE80211R
|
#ifdef CONFIG_IEEE80211R
|
||||||
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_PSK) {
|
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_PSK) {
|
||||||
ret = os_snprintf(pos, end - pos, "FT-PSK ");
|
ret = os_snprintf(pos, end - pos, "FT-PSK ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X) {
|
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X) {
|
||||||
ret = os_snprintf(pos, end - pos, "FT-EAP ");
|
ret = os_snprintf(pos, end - pos, "FT-EAP ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_SAE
|
#ifdef CONFIG_SAE
|
||||||
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_SAE) {
|
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_FT_SAE) {
|
||||||
ret = os_snprintf(pos, end - pos, "FT-SAE ");
|
ret = os_snprintf(pos, end - pos, "FT-SAE ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1145,13 +1145,13 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
|
|||||||
#ifdef CONFIG_IEEE80211W
|
#ifdef CONFIG_IEEE80211W
|
||||||
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK_SHA256) {
|
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK_SHA256) {
|
||||||
ret = os_snprintf(pos, end - pos, "WPA-PSK-SHA256 ");
|
ret = os_snprintf(pos, end - pos, "WPA-PSK-SHA256 ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256) {
|
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256) {
|
||||||
ret = os_snprintf(pos, end - pos, "WPA-EAP-SHA256 ");
|
ret = os_snprintf(pos, end - pos, "WPA-EAP-SHA256 ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1159,20 +1159,20 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
|
|||||||
#ifdef CONFIG_SAE
|
#ifdef CONFIG_SAE
|
||||||
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_SAE) {
|
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_SAE) {
|
||||||
ret = os_snprintf(pos, end - pos, "SAE ");
|
ret = os_snprintf(pos, end - pos, "SAE ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SAE */
|
#endif /* CONFIG_SAE */
|
||||||
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X_SUITE_B) {
|
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_IEEE8021X_SUITE_B) {
|
||||||
ret = os_snprintf(pos, end - pos, "WPA-EAP-SUITE-B ");
|
ret = os_snprintf(pos, end - pos, "WPA-EAP-SUITE-B ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1180,14 +1180,14 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
|
|||||||
if (hapd->conf->wpa) {
|
if (hapd->conf->wpa) {
|
||||||
ret = os_snprintf(pos, end - pos, "group_cipher=%s\n",
|
ret = os_snprintf(pos, end - pos, "group_cipher=%s\n",
|
||||||
wpa_cipher_txt(hapd->conf->wpa_group));
|
wpa_cipher_txt(hapd->conf->wpa_group));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hapd->conf->wpa & WPA_PROTO_RSN) && hapd->conf->rsn_pairwise) {
|
if ((hapd->conf->wpa & WPA_PROTO_RSN) && hapd->conf->rsn_pairwise) {
|
||||||
ret = os_snprintf(pos, end - pos, "rsn_pairwise_cipher=");
|
ret = os_snprintf(pos, end - pos, "rsn_pairwise_cipher=");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -1198,14 +1198,14 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
|
|||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hapd->conf->wpa & WPA_PROTO_WPA) && hapd->conf->wpa_pairwise) {
|
if ((hapd->conf->wpa & WPA_PROTO_WPA) && hapd->conf->wpa_pairwise) {
|
||||||
ret = os_snprintf(pos, end - pos, "wpa_pairwise_cipher=");
|
ret = os_snprintf(pos, end - pos, "wpa_pairwise_cipher=");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -1216,7 +1216,7 @@ static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
|
|||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1323,7 +1323,7 @@ static int hostapd_ctrl_iface_get(struct hostapd_data *hapd, char *cmd,
|
|||||||
|
|
||||||
if (os_strcmp(cmd, "version") == 0) {
|
if (os_strcmp(cmd, "version") == 0) {
|
||||||
res = os_snprintf(buf, buflen, "%s", VERSION_STR);
|
res = os_snprintf(buf, buflen, "%s", VERSION_STR);
|
||||||
if (res < 0 || (unsigned int) res >= buflen)
|
if (os_snprintf_error(buflen, res))
|
||||||
return -1;
|
return -1;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -711,7 +711,7 @@ static int gsm_auth_req(char *imsi, char *resp, size_t resp_len)
|
|||||||
rend = resp + resp_len;
|
rend = resp + resp_len;
|
||||||
rpos = resp;
|
rpos = resp;
|
||||||
ret = os_snprintf(rpos, rend - rpos, "GSM-AUTH-RESP %s", imsi);
|
ret = os_snprintf(rpos, rend - rpos, "GSM-AUTH-RESP %s", imsi);
|
||||||
if (ret < 0 || ret >= rend - rpos)
|
if (os_snprintf_error(rend - rpos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
rpos += ret;
|
rpos += ret;
|
||||||
|
|
||||||
@ -737,7 +737,7 @@ static int gsm_auth_req(char *imsi, char *resp, size_t resp_len)
|
|||||||
|
|
||||||
printf("No GSM triplets found for %s\n", imsi);
|
printf("No GSM triplets found for %s\n", imsi);
|
||||||
ret = os_snprintf(rpos, rend - rpos, " FAILURE");
|
ret = os_snprintf(rpos, rend - rpos, " FAILURE");
|
||||||
if (ret < 0 || ret >= rend - rpos)
|
if (os_snprintf_error(rend - rpos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
rpos += ret;
|
rpos += ret;
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ static int hostapd_cli_cmd_disassoc_imminent(struct wpa_ctrl *ctrl, int argc,
|
|||||||
|
|
||||||
res = os_snprintf(buf, sizeof(buf), "DISASSOC_IMMINENT %s %s",
|
res = os_snprintf(buf, sizeof(buf), "DISASSOC_IMMINENT %s %s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (res < 0 || res >= (int) sizeof(buf))
|
if (os_snprintf_error(sizeof(buf), res))
|
||||||
return -1;
|
return -1;
|
||||||
return wpa_ctrl_command(ctrl, buf);
|
return wpa_ctrl_command(ctrl, buf);
|
||||||
}
|
}
|
||||||
@ -616,7 +616,7 @@ static int hostapd_cli_cmd_ess_disassoc(struct wpa_ctrl *ctrl, int argc,
|
|||||||
|
|
||||||
res = os_snprintf(buf, sizeof(buf), "ESS_DISASSOC %s %s %s",
|
res = os_snprintf(buf, sizeof(buf), "ESS_DISASSOC %s %s %s",
|
||||||
argv[0], argv[1], argv[2]);
|
argv[0], argv[1], argv[2]);
|
||||||
if (res < 0 || res >= (int) sizeof(buf))
|
if (os_snprintf_error(sizeof(buf), res))
|
||||||
return -1;
|
return -1;
|
||||||
return wpa_ctrl_command(ctrl, buf);
|
return wpa_ctrl_command(ctrl, buf);
|
||||||
}
|
}
|
||||||
@ -634,7 +634,7 @@ static int hostapd_cli_cmd_bss_tm_req(struct wpa_ctrl *ctrl, int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = os_snprintf(buf, sizeof(buf), "BSS_TM_REQ %s", argv[0]);
|
res = os_snprintf(buf, sizeof(buf), "BSS_TM_REQ %s", argv[0]);
|
||||||
if (res < 0 || res >= (int) sizeof(buf))
|
if (os_snprintf_error(sizeof(buf), res))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
total = res;
|
total = res;
|
||||||
@ -736,7 +736,7 @@ static int hostapd_cli_cmd_set_qos_map_set(struct wpa_ctrl *ctrl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = os_snprintf(buf, sizeof(buf), "SET_QOS_MAP_SET %s", argv[0]);
|
res = os_snprintf(buf, sizeof(buf), "SET_QOS_MAP_SET %s", argv[0]);
|
||||||
if (res < 0 || res >= (int) sizeof(buf))
|
if (os_snprintf_error(sizeof(buf), res))
|
||||||
return -1;
|
return -1;
|
||||||
return wpa_ctrl_command(ctrl, buf);
|
return wpa_ctrl_command(ctrl, buf);
|
||||||
}
|
}
|
||||||
@ -755,7 +755,7 @@ static int hostapd_cli_cmd_send_qos_map_conf(struct wpa_ctrl *ctrl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = os_snprintf(buf, sizeof(buf), "SEND_QOS_MAP_CONF %s", argv[0]);
|
res = os_snprintf(buf, sizeof(buf), "SEND_QOS_MAP_CONF %s", argv[0]);
|
||||||
if (res < 0 || res >= (int) sizeof(buf))
|
if (os_snprintf_error(sizeof(buf), res))
|
||||||
return -1;
|
return -1;
|
||||||
return wpa_ctrl_command(ctrl, buf);
|
return wpa_ctrl_command(ctrl, buf);
|
||||||
}
|
}
|
||||||
@ -775,7 +775,7 @@ static int hostapd_cli_cmd_hs20_wnm_notif(struct wpa_ctrl *ctrl, int argc,
|
|||||||
|
|
||||||
res = os_snprintf(buf, sizeof(buf), "HS20_WNM_NOTIF %s %s",
|
res = os_snprintf(buf, sizeof(buf), "HS20_WNM_NOTIF %s %s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (res < 0 || res >= (int) sizeof(buf))
|
if (os_snprintf_error(sizeof(buf), res))
|
||||||
return -1;
|
return -1;
|
||||||
return wpa_ctrl_command(ctrl, buf);
|
return wpa_ctrl_command(ctrl, buf);
|
||||||
}
|
}
|
||||||
@ -800,7 +800,7 @@ static int hostapd_cli_cmd_hs20_deauth_req(struct wpa_ctrl *ctrl, int argc,
|
|||||||
res = os_snprintf(buf, sizeof(buf),
|
res = os_snprintf(buf, sizeof(buf),
|
||||||
"HS20_DEAUTH_REQ %s %s %s",
|
"HS20_DEAUTH_REQ %s %s %s",
|
||||||
argv[0], argv[1], argv[2]);
|
argv[0], argv[1], argv[2]);
|
||||||
if (res < 0 || res >= (int) sizeof(buf))
|
if (os_snprintf_error(sizeof(buf), res))
|
||||||
return -1;
|
return -1;
|
||||||
return wpa_ctrl_command(ctrl, buf);
|
return wpa_ctrl_command(ctrl, buf);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ static int hostapd_get_sta_tx_rx(struct hostapd_data *hapd,
|
|||||||
"rx_bytes=%lu\ntx_bytes=%lu\n",
|
"rx_bytes=%lu\ntx_bytes=%lu\n",
|
||||||
data.rx_packets, data.tx_packets,
|
data.rx_packets, data.tx_packets,
|
||||||
data.rx_bytes, data.tx_bytes);
|
data.rx_bytes, data.tx_bytes);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return 0;
|
return 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ static int hostapd_get_sta_conn_time(struct sta_info *sta,
|
|||||||
|
|
||||||
ret = os_snprintf(buf, buflen, "connected_time=%u\n",
|
ret = os_snprintf(buf, buflen, "connected_time=%u\n",
|
||||||
(unsigned int) age.sec);
|
(unsigned int) age.sec);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return 0;
|
return 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
|
|||||||
len = 0;
|
len = 0;
|
||||||
ret = os_snprintf(buf + len, buflen - len, MACSTR "\nflags=",
|
ret = os_snprintf(buf + len, buflen - len, MACSTR "\nflags=",
|
||||||
MAC2STR(sta->addr));
|
MAC2STR(sta->addr));
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
|
|||||||
ret = os_snprintf(buf + len, buflen - len, "\naid=%d\ncapability=0x%x\n"
|
ret = os_snprintf(buf + len, buflen - len, "\naid=%d\ncapability=0x%x\n"
|
||||||
"listen_interval=%d\nsupported_rates=",
|
"listen_interval=%d\nsupported_rates=",
|
||||||
sta->aid, sta->capability, sta->listen_interval);
|
sta->aid, sta->capability, sta->listen_interval);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -112,14 +112,14 @@ static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
|
|||||||
ret = os_snprintf(buf + len, buflen - len, "%02x%s",
|
ret = os_snprintf(buf + len, buflen - len, "%02x%s",
|
||||||
sta->supported_rates[i],
|
sta->supported_rates[i],
|
||||||
i + 1 < sta->supported_rates_len ? " " : "");
|
i + 1 < sta->supported_rates_len ? " " : "");
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(buf + len, buflen - len, "\ntimeout_next=%s\n",
|
ret = os_snprintf(buf + len, buflen - len, "\ntimeout_next=%s\n",
|
||||||
timeout_next_str(sta->timeout_next));
|
timeout_next_str(sta->timeout_next));
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ int hostapd_ctrl_iface_sta(struct hostapd_data *hapd, const char *txtaddr,
|
|||||||
|
|
||||||
if (hwaddr_aton(txtaddr, addr)) {
|
if (hwaddr_aton(txtaddr, addr)) {
|
||||||
ret = os_snprintf(buf, buflen, "FAIL\n");
|
ret = os_snprintf(buf, buflen, "FAIL\n");
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return 0;
|
return 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd, const char *txtaddr,
|
|||||||
if (hwaddr_aton(txtaddr, addr) ||
|
if (hwaddr_aton(txtaddr, addr) ||
|
||||||
(sta = ap_get_sta(hapd, addr)) == NULL) {
|
(sta = ap_get_sta(hapd, addr)) == NULL) {
|
||||||
ret = os_snprintf(buf, buflen, "FAIL\n");
|
ret = os_snprintf(buf, buflen, "FAIL\n");
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return 0;
|
return 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -422,7 +422,7 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
|
|||||||
iface->num_sta_ht40_intolerant,
|
iface->num_sta_ht40_intolerant,
|
||||||
iface->olbc_ht,
|
iface->olbc_ht,
|
||||||
iface->ht_op_mode);
|
iface->ht_op_mode);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
|
|||||||
iface->dfs_cac_ms / 1000,
|
iface->dfs_cac_ms / 1000,
|
||||||
left_time);
|
left_time);
|
||||||
}
|
}
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
|
|||||||
iface->conf->vht_oper_chwidth,
|
iface->conf->vht_oper_chwidth,
|
||||||
iface->conf->vht_oper_centr_freq_seg0_idx,
|
iface->conf->vht_oper_centr_freq_seg0_idx,
|
||||||
iface->conf->vht_oper_centr_freq_seg1_idx);
|
iface->conf->vht_oper_centr_freq_seg1_idx);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -480,7 +480,7 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
|
|||||||
wpa_ssid_txt(bss->conf->ssid.ssid,
|
wpa_ssid_txt(bss->conf->ssid.ssid,
|
||||||
bss->conf->ssid.ssid_len),
|
bss->conf->ssid.ssid_len),
|
||||||
(int) i, bss->num_sta);
|
(int) i, bss->num_sta);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
}
|
}
|
||||||
|
@ -2359,7 +2359,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||||||
sta->aid,
|
sta->aid,
|
||||||
EAPOL_VERSION,
|
EAPOL_VERSION,
|
||||||
sm->initialize);
|
sm->initialize);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -2387,7 +2387,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||||||
sm->reAuthPeriod,
|
sm->reAuthPeriod,
|
||||||
bool_txt(sm->reAuthEnabled),
|
bool_txt(sm->reAuthEnabled),
|
||||||
bool_txt(sm->keyTxEnabled));
|
bool_txt(sm->keyTxEnabled));
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -2417,7 +2417,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||||||
sm->dot1xAuthEapLengthErrorFramesRx,
|
sm->dot1xAuthEapLengthErrorFramesRx,
|
||||||
sm->dot1xAuthLastEapolFrameVersion,
|
sm->dot1xAuthLastEapolFrameVersion,
|
||||||
MAC2STR(sm->addr));
|
MAC2STR(sm->addr));
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -2455,7 +2455,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||||||
sm->backendOtherRequestsToSupplicant,
|
sm->backendOtherRequestsToSupplicant,
|
||||||
sm->backendAuthSuccesses,
|
sm->backendAuthSuccesses,
|
||||||
sm->backendAuthFails);
|
sm->backendAuthFails);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -2477,7 +2477,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||||||
1 : 2,
|
1 : 2,
|
||||||
(unsigned int) diff.sec,
|
(unsigned int) diff.sec,
|
||||||
sm->identity);
|
sm->identity);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -2490,7 +2490,7 @@ int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||||||
name1 ? name1 : "",
|
name1 ? name1 : "",
|
||||||
sm->eap_type_supp,
|
sm->eap_type_supp,
|
||||||
name2 ? name2 : "");
|
name2 ? name2 : "");
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
|
@ -2970,7 +2970,7 @@ int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen)
|
|||||||
wpa_bool_txt(preauth),
|
wpa_bool_txt(preauth),
|
||||||
wpa_bool_txt(wpa_auth->conf.wpa & WPA_PROTO_RSN),
|
wpa_bool_txt(wpa_auth->conf.wpa & WPA_PROTO_RSN),
|
||||||
wpa_bool_txt(wpa_auth->conf.rsn_preauth));
|
wpa_bool_txt(wpa_auth->conf.rsn_preauth));
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -3020,7 +3020,7 @@ int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen)
|
|||||||
RSN_SUITE_ARG(wpa_auth->dot11RSNAGroupCipherRequested),
|
RSN_SUITE_ARG(wpa_auth->dot11RSNAGroupCipherRequested),
|
||||||
wpa_auth->dot11RSNATKIPCounterMeasuresInvoked,
|
wpa_auth->dot11RSNATKIPCounterMeasuresInvoked,
|
||||||
wpa_auth->dot11RSNA4WayHandshakeFailures);
|
wpa_auth->dot11RSNA4WayHandshakeFailures);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -3030,7 +3030,7 @@ int wpa_get_mib(struct wpa_authenticator *wpa_auth, char *buf, size_t buflen)
|
|||||||
/* Private MIB */
|
/* Private MIB */
|
||||||
ret = os_snprintf(buf + len, buflen - len, "hostapdWPAGroupState=%d\n",
|
ret = os_snprintf(buf + len, buflen - len, "hostapdWPAGroupState=%d\n",
|
||||||
wpa_auth->group->wpa_group_state);
|
wpa_auth->group->wpa_group_state);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -3072,7 +3072,7 @@ int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen)
|
|||||||
RSN_SUITE_ARG(pairwise),
|
RSN_SUITE_ARG(pairwise),
|
||||||
sm->dot11RSNAStatsTKIPLocalMICFailures,
|
sm->dot11RSNAStatsTKIPLocalMICFailures,
|
||||||
sm->dot11RSNAStatsTKIPRemoteMICFailures);
|
sm->dot11RSNAStatsTKIPRemoteMICFailures);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -3082,7 +3082,7 @@ int wpa_get_mib_sta(struct wpa_state_machine *sm, char *buf, size_t buflen)
|
|||||||
"hostapdWPAPTKGroupState=%d\n",
|
"hostapdWPAPTKGroupState=%d\n",
|
||||||
sm->wpa_ptk_state,
|
sm->wpa_ptk_state,
|
||||||
sm->wpa_ptk_group_state);
|
sm->wpa_ptk_group_state);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
|
@ -1583,7 +1583,7 @@ int hostapd_wps_ap_pin_set(struct hostapd_data *hapd, const char *pin,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = os_snprintf(data.pin_txt, sizeof(data.pin_txt), "%s", pin);
|
ret = os_snprintf(data.pin_txt, sizeof(data.pin_txt), "%s", pin);
|
||||||
if (ret < 0 || ret >= (int) sizeof(data.pin_txt))
|
if (os_snprintf_error(sizeof(data.pin_txt), ret))
|
||||||
return -1;
|
return -1;
|
||||||
data.timeout = timeout;
|
data.timeout = timeout;
|
||||||
return hostapd_wps_for_each(hapd, wps_ap_pin_set, &data);
|
return hostapd_wps_for_each(hapd, wps_ap_pin_set, &data);
|
||||||
|
@ -1468,56 +1468,56 @@ int wpa_write_ciphers(char *start, char *end, int ciphers, const char *delim)
|
|||||||
if (ciphers & WPA_CIPHER_CCMP_256) {
|
if (ciphers & WPA_CIPHER_CCMP_256) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sCCMP-256",
|
ret = os_snprintf(pos, end - pos, "%sCCMP-256",
|
||||||
pos == start ? "" : delim);
|
pos == start ? "" : delim);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (ciphers & WPA_CIPHER_GCMP_256) {
|
if (ciphers & WPA_CIPHER_GCMP_256) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sGCMP-256",
|
ret = os_snprintf(pos, end - pos, "%sGCMP-256",
|
||||||
pos == start ? "" : delim);
|
pos == start ? "" : delim);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (ciphers & WPA_CIPHER_CCMP) {
|
if (ciphers & WPA_CIPHER_CCMP) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sCCMP",
|
ret = os_snprintf(pos, end - pos, "%sCCMP",
|
||||||
pos == start ? "" : delim);
|
pos == start ? "" : delim);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (ciphers & WPA_CIPHER_GCMP) {
|
if (ciphers & WPA_CIPHER_GCMP) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sGCMP",
|
ret = os_snprintf(pos, end - pos, "%sGCMP",
|
||||||
pos == start ? "" : delim);
|
pos == start ? "" : delim);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (ciphers & WPA_CIPHER_TKIP) {
|
if (ciphers & WPA_CIPHER_TKIP) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sTKIP",
|
ret = os_snprintf(pos, end - pos, "%sTKIP",
|
||||||
pos == start ? "" : delim);
|
pos == start ? "" : delim);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (ciphers & WPA_CIPHER_WEP104) {
|
if (ciphers & WPA_CIPHER_WEP104) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWEP104",
|
ret = os_snprintf(pos, end - pos, "%sWEP104",
|
||||||
pos == start ? "" : delim);
|
pos == start ? "" : delim);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (ciphers & WPA_CIPHER_WEP40) {
|
if (ciphers & WPA_CIPHER_WEP40) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWEP40",
|
ret = os_snprintf(pos, end - pos, "%sWEP40",
|
||||||
pos == start ? "" : delim);
|
pos == start ? "" : delim);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (ciphers & WPA_CIPHER_NONE) {
|
if (ciphers & WPA_CIPHER_NONE) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sNONE",
|
ret = os_snprintf(pos, end - pos, "%sNONE",
|
||||||
pos == start ? "" : delim);
|
pos == start ? "" : delim);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ try_again:
|
|||||||
CONFIG_CTRL_IFACE_CLIENT_DIR "/"
|
CONFIG_CTRL_IFACE_CLIENT_DIR "/"
|
||||||
CONFIG_CTRL_IFACE_CLIENT_PREFIX "%d-%d",
|
CONFIG_CTRL_IFACE_CLIENT_PREFIX "%d-%d",
|
||||||
(int) getpid(), counter);
|
(int) getpid(), counter);
|
||||||
if (ret < 0 || (size_t) ret >= sizeof(ctrl->local.sun_path)) {
|
if (os_snprintf_error(sizeof(ctrl->local.sun_path), ret)) {
|
||||||
close(ctrl->s);
|
close(ctrl->s);
|
||||||
os_free(ctrl);
|
os_free(ctrl);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2868,7 +2868,7 @@ int tls_connection_set_cipher_list(void *tls_ctx, struct tls_connection *conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = os_snprintf(pos, end - pos, ":%s", suite);
|
ret = os_snprintf(pos, end - pos, ":%s", suite);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
break;
|
break;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
|
@ -5238,7 +5238,7 @@ static void dump_ifidx(struct wpa_driver_nl80211_data *drv)
|
|||||||
if (!drv->if_indices[i])
|
if (!drv->if_indices[i])
|
||||||
continue;
|
continue;
|
||||||
res = os_snprintf(pos, end - pos, " %d", drv->if_indices[i]);
|
res = os_snprintf(pos, end - pos, " %d", drv->if_indices[i]);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
break;
|
break;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
@ -7120,14 +7120,14 @@ static int wpa_driver_nl80211_status(void *priv, char *buf, size_t buflen)
|
|||||||
bss->added_bridge ? "added_bridge=1\n" : "",
|
bss->added_bridge ? "added_bridge=1\n" : "",
|
||||||
bss->in_deinit ? "in_deinit=1\n" : "",
|
bss->in_deinit ? "in_deinit=1\n" : "",
|
||||||
bss->if_dynamic ? "if_dynamic=1\n" : "");
|
bss->if_dynamic ? "if_dynamic=1\n" : "");
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
|
|
||||||
if (bss->wdev_id_set) {
|
if (bss->wdev_id_set) {
|
||||||
res = os_snprintf(pos, end - pos, "wdev_id=%llu\n",
|
res = os_snprintf(pos, end - pos, "wdev_id=%llu\n",
|
||||||
(unsigned long long) bss->wdev_id);
|
(unsigned long long) bss->wdev_id);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
@ -7186,7 +7186,7 @@ static int wpa_driver_nl80211_status(void *priv, char *buf, size_t buflen)
|
|||||||
"ignore_next_local_disconnect=1\n" : "",
|
"ignore_next_local_disconnect=1\n" : "",
|
||||||
drv->ignore_next_local_deauth ?
|
drv->ignore_next_local_deauth ?
|
||||||
"ignore_next_local_deauth=1\n" : "");
|
"ignore_next_local_deauth=1\n" : "");
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
|
|
||||||
@ -7218,7 +7218,7 @@ static int wpa_driver_nl80211_status(void *priv, char *buf, size_t buflen)
|
|||||||
drv->capa.probe_resp_offloads,
|
drv->capa.probe_resp_offloads,
|
||||||
drv->capa.max_acl_mac_addrs,
|
drv->capa.max_acl_mac_addrs,
|
||||||
drv->capa.num_multichan_concurrent);
|
drv->capa.num_multichan_concurrent);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
|
@ -2373,7 +2373,7 @@ static int wpa_driver_wext_status(void *priv, char *buf, size_t buflen)
|
|||||||
drv->ifindex,
|
drv->ifindex,
|
||||||
drv->ifname,
|
drv->ifname,
|
||||||
MAC2STR(addr));
|
MAC2STR(addr));
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
|
|
||||||
|
@ -2090,7 +2090,7 @@ int eap_sm_get_status(struct eap_sm *sm, char *buf, size_t buflen, int verbose)
|
|||||||
len = os_snprintf(buf, buflen,
|
len = os_snprintf(buf, buflen,
|
||||||
"EAP state=%s\n",
|
"EAP state=%s\n",
|
||||||
eap_sm_state_txt(sm->EAP_state));
|
eap_sm_state_txt(sm->EAP_state));
|
||||||
if (len < 0 || (size_t) len >= buflen)
|
if (os_snprintf_error(buflen, len))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (sm->selectedMethod != EAP_TYPE_NONE) {
|
if (sm->selectedMethod != EAP_TYPE_NONE) {
|
||||||
@ -2109,7 +2109,7 @@ int eap_sm_get_status(struct eap_sm *sm, char *buf, size_t buflen, int verbose)
|
|||||||
ret = os_snprintf(buf + len, buflen - len,
|
ret = os_snprintf(buf + len, buflen - len,
|
||||||
"selectedMethod=%d (EAP-%s)\n",
|
"selectedMethod=%d (EAP-%s)\n",
|
||||||
sm->selectedMethod, name);
|
sm->selectedMethod, name);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -2130,7 +2130,7 @@ int eap_sm_get_status(struct eap_sm *sm, char *buf, size_t buflen, int verbose)
|
|||||||
eap_sm_method_state_txt(sm->methodState),
|
eap_sm_method_state_txt(sm->methodState),
|
||||||
eap_sm_decision_txt(sm->decision),
|
eap_sm_decision_txt(sm->decision),
|
||||||
sm->ClientTimeout);
|
sm->ClientTimeout);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
}
|
}
|
||||||
|
@ -1666,7 +1666,7 @@ static int eap_fast_get_status(struct eap_sm *sm, void *priv, char *buf,
|
|||||||
ret = os_snprintf(buf + len, buflen - len,
|
ret = os_snprintf(buf + len, buflen - len,
|
||||||
"EAP-FAST Phase2 method=%s\n",
|
"EAP-FAST Phase2 method=%s\n",
|
||||||
data->phase2_method->name);
|
data->phase2_method->name);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
}
|
}
|
||||||
|
@ -504,28 +504,28 @@ static void eap_fast_write(char **buf, char **pos, size_t *buf_len,
|
|||||||
end = *buf + *buf_len;
|
end = *buf + *buf_len;
|
||||||
|
|
||||||
ret = os_snprintf(*pos, end - *pos, "%s=", field);
|
ret = os_snprintf(*pos, end - *pos, "%s=", field);
|
||||||
if (ret < 0 || ret >= end - *pos)
|
if (os_snprintf_error(end - *pos, ret))
|
||||||
return;
|
return;
|
||||||
*pos += ret;
|
*pos += ret;
|
||||||
*pos += wpa_snprintf_hex(*pos, end - *pos, data, len);
|
*pos += wpa_snprintf_hex(*pos, end - *pos, data, len);
|
||||||
ret = os_snprintf(*pos, end - *pos, "\n");
|
ret = os_snprintf(*pos, end - *pos, "\n");
|
||||||
if (ret < 0 || ret >= end - *pos)
|
if (os_snprintf_error(end - *pos, ret))
|
||||||
return;
|
return;
|
||||||
*pos += ret;
|
*pos += ret;
|
||||||
|
|
||||||
if (txt) {
|
if (txt) {
|
||||||
ret = os_snprintf(*pos, end - *pos, "%s-txt=", field);
|
ret = os_snprintf(*pos, end - *pos, "%s-txt=", field);
|
||||||
if (ret < 0 || ret >= end - *pos)
|
if (os_snprintf_error(end - *pos, ret))
|
||||||
return;
|
return;
|
||||||
*pos += ret;
|
*pos += ret;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
ret = os_snprintf(*pos, end - *pos, "%c", data[i]);
|
ret = os_snprintf(*pos, end - *pos, "%c", data[i]);
|
||||||
if (ret < 0 || ret >= end - *pos)
|
if (os_snprintf_error(end - *pos, ret))
|
||||||
return;
|
return;
|
||||||
*pos += ret;
|
*pos += ret;
|
||||||
}
|
}
|
||||||
ret = os_snprintf(*pos, end - *pos, "\n");
|
ret = os_snprintf(*pos, end - *pos, "\n");
|
||||||
if (ret < 0 || ret >= end - *pos)
|
if (os_snprintf_error(end - *pos, ret))
|
||||||
return;
|
return;
|
||||||
*pos += ret;
|
*pos += ret;
|
||||||
}
|
}
|
||||||
@ -578,7 +578,7 @@ static int eap_fast_add_pac_data(struct eap_fast_pac *pac, char **buf,
|
|||||||
|
|
||||||
ret = os_snprintf(*pos, *buf + *buf_len - *pos,
|
ret = os_snprintf(*pos, *buf + *buf_len - *pos,
|
||||||
"START\nPAC-Type=%d\n", pac->pac_type);
|
"START\nPAC-Type=%d\n", pac->pac_type);
|
||||||
if (ret < 0 || ret >= *buf + *buf_len - *pos)
|
if (os_snprintf_error(*buf + *buf_len - *pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
*pos += ret;
|
*pos += ret;
|
||||||
@ -600,7 +600,7 @@ static int eap_fast_add_pac_data(struct eap_fast_pac *pac, char **buf,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = os_snprintf(*pos, *buf + *buf_len - *pos, "END\n");
|
ret = os_snprintf(*pos, *buf + *buf_len - *pos, "END\n");
|
||||||
if (ret < 0 || ret >= *buf + *buf_len - *pos)
|
if (os_snprintf_error(*buf + *buf_len - *pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
*pos += ret;
|
*pos += ret;
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ int eap_fast_save_pac(struct eap_sm *sm, struct eap_fast_pac *pac_root,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ret = os_snprintf(pos, buf + buf_len - pos, "%s\n", pac_file_hdr);
|
ret = os_snprintf(pos, buf + buf_len - pos, "%s\n", pac_file_hdr);
|
||||||
if (ret < 0 || ret >= buf + buf_len - pos) {
|
if (os_snprintf_error(buf + buf_len - pos, ret)) {
|
||||||
os_free(buf);
|
os_free(buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ size_t eap_get_names(char *buf, size_t buflen)
|
|||||||
for (m = eap_methods; m; m = m->next) {
|
for (m = eap_methods; m; m = m->next) {
|
||||||
ret = os_snprintf(pos, end - pos, "%s%s",
|
ret = os_snprintf(pos, end - pos, "%s%s",
|
||||||
m == eap_methods ? "" : " ", m->name);
|
m == eap_methods ? "" : " ", m->name);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
break;
|
break;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -1156,7 +1156,7 @@ static int eap_peap_get_status(struct eap_sm *sm, void *priv, char *buf,
|
|||||||
"EAP-PEAPv%d Phase2 method=%s\n",
|
"EAP-PEAPv%d Phase2 method=%s\n",
|
||||||
data->peap_version,
|
data->peap_version,
|
||||||
data->phase2_method->name);
|
data->phase2_method->name);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
}
|
}
|
||||||
|
@ -793,7 +793,7 @@ int eap_peer_tls_status(struct eap_sm *sm, struct eap_ssl_data *data,
|
|||||||
{
|
{
|
||||||
ret = os_snprintf(buf + len, buflen - len,
|
ret = os_snprintf(buf + len, buflen - len,
|
||||||
"EAP TLS cipher=%s\n", name);
|
"EAP TLS cipher=%s\n", name);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
}
|
}
|
||||||
|
@ -1571,7 +1571,7 @@ static int eap_ttls_get_status(struct eap_sm *sm, void *priv, char *buf,
|
|||||||
ret = os_snprintf(buf + len, buflen - len,
|
ret = os_snprintf(buf + len, buflen - len,
|
||||||
"EAP-TTLSv%d Phase2 method=",
|
"EAP-TTLSv%d Phase2 method=",
|
||||||
data->ttls_version);
|
data->ttls_version);
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
switch (data->phase2_type) {
|
switch (data->phase2_type) {
|
||||||
|
@ -927,7 +927,7 @@ int eap_sim_db_get_gsm_triplets(struct eap_sim_db_data *data,
|
|||||||
os_memcpy(msg + len, imsi, imsi_len);
|
os_memcpy(msg + len, imsi, imsi_len);
|
||||||
len += imsi_len;
|
len += imsi_len;
|
||||||
ret = os_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)
|
if (os_snprintf_error(sizeof(msg) - len, ret))
|
||||||
return EAP_SIM_DB_FAILURE;
|
return EAP_SIM_DB_FAILURE;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
@ -1455,13 +1455,13 @@ int eap_sim_db_resynchronize(struct eap_sim_db_data *data,
|
|||||||
len += imsi_len;
|
len += imsi_len;
|
||||||
|
|
||||||
ret = os_snprintf(msg + len, sizeof(msg) - len, " ");
|
ret = os_snprintf(msg + len, sizeof(msg) - len, " ");
|
||||||
if (ret < 0 || (size_t) ret >= sizeof(msg) - len)
|
if (os_snprintf_error(sizeof(msg) - len, ret))
|
||||||
return -1;
|
return -1;
|
||||||
len += ret;
|
len += ret;
|
||||||
len += wpa_snprintf_hex(msg + len, sizeof(msg) - len,
|
len += wpa_snprintf_hex(msg + len, sizeof(msg) - len,
|
||||||
auts, EAP_AKA_AUTS_LEN);
|
auts, EAP_AKA_AUTS_LEN);
|
||||||
ret = os_snprintf(msg + len, sizeof(msg) - len, " ");
|
ret = os_snprintf(msg + len, sizeof(msg) - len, " ");
|
||||||
if (ret < 0 || (size_t) ret >= sizeof(msg) - len)
|
if (os_snprintf_error(sizeof(msg) - len, ret))
|
||||||
return -1;
|
return -1;
|
||||||
len += ret;
|
len += ret;
|
||||||
len += wpa_snprintf_hex(msg + len, sizeof(msg) - len,
|
len += wpa_snprintf_hex(msg + len, sizeof(msg) - len,
|
||||||
|
@ -130,7 +130,7 @@ int eapol_auth_dump_state(struct eapol_state_machine *sm, char *buf,
|
|||||||
ret = os_snprintf(pos, end - pos, "aWhile=%d\nquietWhile=%d\n"
|
ret = os_snprintf(pos, end - pos, "aWhile=%d\nquietWhile=%d\n"
|
||||||
"reAuthWhen=%d\n",
|
"reAuthWhen=%d\n",
|
||||||
sm->aWhile, sm->quietWhile, sm->reAuthWhen);
|
sm->aWhile, sm->quietWhile, sm->reAuthWhen);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ int eapol_auth_dump_state(struct eapol_state_machine *sm, char *buf,
|
|||||||
_SB(sm->eap_if->portEnabled),
|
_SB(sm->eap_if->portEnabled),
|
||||||
_SB(sm->portValid),
|
_SB(sm->portValid),
|
||||||
_SB(sm->reAuthenticate));
|
_SB(sm->reAuthenticate));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ int eapol_auth_dump_state(struct eapol_state_machine *sm, char *buf,
|
|||||||
sm->authAuthReauthsWhileAuthenticated,
|
sm->authAuthReauthsWhileAuthenticated,
|
||||||
sm->authAuthEapStartsWhileAuthenticated,
|
sm->authAuthEapStartsWhileAuthenticated,
|
||||||
sm->authAuthEapLogoffWhileAuthenticated);
|
sm->authAuthEapLogoffWhileAuthenticated);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ int eapol_auth_dump_state(struct eapol_state_machine *sm, char *buf,
|
|||||||
sm->backendOtherRequestsToSupplicant,
|
sm->backendOtherRequestsToSupplicant,
|
||||||
sm->backendAuthSuccesses,
|
sm->backendAuthSuccesses,
|
||||||
sm->backendAuthFails);
|
sm->backendAuthFails);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -251,14 +251,14 @@ int eapol_auth_dump_state(struct eapol_state_machine *sm, char *buf,
|
|||||||
reauth_timer_state_txt(sm->reauth_timer_state),
|
reauth_timer_state_txt(sm->reauth_timer_state),
|
||||||
sm->reAuthPeriod,
|
sm->reAuthPeriod,
|
||||||
_SB(sm->reAuthEnabled));
|
_SB(sm->reAuthEnabled));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"auth_key_tx_state=%s\n",
|
"auth_key_tx_state=%s\n",
|
||||||
auth_key_tx_state_txt(sm->auth_key_tx_state));
|
auth_key_tx_state_txt(sm->auth_key_tx_state));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ int eapol_auth_dump_state(struct eapol_state_machine *sm, char *buf,
|
|||||||
"rxKey=%s\n",
|
"rxKey=%s\n",
|
||||||
key_rx_state_txt(sm->key_rx_state),
|
key_rx_state_txt(sm->key_rx_state),
|
||||||
_SB(sm->rxKey));
|
_SB(sm->rxKey));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ int eapol_auth_dump_state(struct eapol_state_machine *sm, char *buf,
|
|||||||
ctrl_dir_txt(sm->adminControlledDirections),
|
ctrl_dir_txt(sm->adminControlledDirections),
|
||||||
ctrl_dir_txt(sm->operControlledDirections),
|
ctrl_dir_txt(sm->operControlledDirections),
|
||||||
_SB(sm->operEdge));
|
_SB(sm->operEdge));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
#undef _SB
|
#undef _SB
|
||||||
|
@ -1108,7 +1108,7 @@ int eapol_sm_get_status(struct eapol_sm *sm, char *buf, size_t buflen,
|
|||||||
"suppPortStatus=%s\n",
|
"suppPortStatus=%s\n",
|
||||||
eapol_supp_pae_state(sm->SUPP_PAE_state),
|
eapol_supp_pae_state(sm->SUPP_PAE_state),
|
||||||
eapol_port_status(sm->suppPortStatus));
|
eapol_port_status(sm->suppPortStatus));
|
||||||
if (len < 0 || (size_t) len >= buflen)
|
if (os_snprintf_error(buflen, len))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
@ -1125,7 +1125,7 @@ int eapol_sm_get_status(struct eapol_sm *sm, char *buf, size_t buflen,
|
|||||||
sm->maxStart,
|
sm->maxStart,
|
||||||
eapol_port_control(sm->portControl),
|
eapol_port_control(sm->portControl),
|
||||||
eapol_supp_be_state(sm->SUPP_BE_state));
|
eapol_supp_be_state(sm->SUPP_BE_state));
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
}
|
}
|
||||||
@ -1179,7 +1179,7 @@ int eapol_sm_get_mib(struct eapol_sm *sm, char *buf, size_t buflen)
|
|||||||
"Authorized" : "Unauthorized",
|
"Authorized" : "Unauthorized",
|
||||||
sm->SUPP_BE_state);
|
sm->SUPP_BE_state);
|
||||||
|
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return 0;
|
return 0;
|
||||||
len = ret;
|
len = ret;
|
||||||
|
|
||||||
@ -1207,7 +1207,7 @@ int eapol_sm_get_mib(struct eapol_sm *sm, char *buf, size_t buflen)
|
|||||||
sm->dot1xSuppLastEapolFrameVersion,
|
sm->dot1xSuppLastEapolFrameVersion,
|
||||||
MAC2STR(sm->dot1xSuppLastEapolFrameSource));
|
MAC2STR(sm->dot1xSuppLastEapolFrameSource));
|
||||||
|
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
|
@ -3750,7 +3750,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
|
|||||||
"[PD_FOR_JOIN]" : "",
|
"[PD_FOR_JOIN]" : "",
|
||||||
dev->status,
|
dev->status,
|
||||||
dev->invitation_reqs);
|
dev->invitation_reqs);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
|
|
||||||
@ -3760,7 +3760,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
|
|||||||
"ext_listen_interval=%u\n",
|
"ext_listen_interval=%u\n",
|
||||||
dev->ext_listen_period,
|
dev->ext_listen_period,
|
||||||
dev->ext_listen_interval);
|
dev->ext_listen_interval);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
@ -3770,7 +3770,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
|
|||||||
"oper_ssid=%s\n",
|
"oper_ssid=%s\n",
|
||||||
wpa_ssid_txt(dev->oper_ssid,
|
wpa_ssid_txt(dev->oper_ssid,
|
||||||
dev->oper_ssid_len));
|
dev->oper_ssid_len));
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
@ -3778,7 +3778,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
|
|||||||
#ifdef CONFIG_WIFI_DISPLAY
|
#ifdef CONFIG_WIFI_DISPLAY
|
||||||
if (dev->info.wfd_subelems) {
|
if (dev->info.wfd_subelems) {
|
||||||
res = os_snprintf(pos, end - pos, "wfd_subelems=");
|
res = os_snprintf(pos, end - pos, "wfd_subelems=");
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
|
|
||||||
@ -3787,7 +3787,7 @@ int p2p_get_peer_info_txt(const struct p2p_peer_info *info,
|
|||||||
wpabuf_len(dev->info.wfd_subelems));
|
wpabuf_len(dev->info.wfd_subelems));
|
||||||
|
|
||||||
res = os_snprintf(pos, end - pos, "\n");
|
res = os_snprintf(pos, end - pos, "\n");
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,7 @@ static int p2p_group_info_text(const u8 *gi, size_t gi_len, char *buf,
|
|||||||
"dev=" MACSTR " iface=" MACSTR,
|
"dev=" MACSTR " iface=" MACSTR,
|
||||||
MAC2STR(cli->p2p_device_addr),
|
MAC2STR(cli->p2p_device_addr),
|
||||||
MAC2STR(cli->p2p_interface_addr));
|
MAC2STR(cli->p2p_interface_addr));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -618,7 +618,7 @@ static int p2p_group_info_text(const u8 *gi, size_t gi_len, char *buf,
|
|||||||
wps_dev_type_bin2str(cli->pri_dev_type,
|
wps_dev_type_bin2str(cli->pri_dev_type,
|
||||||
devtype,
|
devtype,
|
||||||
sizeof(devtype)));
|
sizeof(devtype)));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -627,7 +627,7 @@ static int p2p_group_info_text(const u8 *gi, size_t gi_len, char *buf,
|
|||||||
wps_dev_type_bin2str(
|
wps_dev_type_bin2str(
|
||||||
&cli->sec_dev_types[s * 8],
|
&cli->sec_dev_types[s * 8],
|
||||||
devtype, sizeof(devtype)));
|
devtype, sizeof(devtype)));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -642,7 +642,7 @@ static int p2p_group_info_text(const u8 *gi, size_t gi_len, char *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, " dev_name='%s'\n", name);
|
ret = os_snprintf(pos, end - pos, " dev_name='%s'\n", name);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -676,7 +676,7 @@ int p2p_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
"p2p_dev_capab=0x%x\n"
|
"p2p_dev_capab=0x%x\n"
|
||||||
"p2p_group_capab=0x%x\n",
|
"p2p_group_capab=0x%x\n",
|
||||||
msg.capability[0], msg.capability[1]);
|
msg.capability[0], msg.capability[1]);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -688,14 +688,14 @@ int p2p_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
wps_dev_type_bin2str(msg.pri_dev_type,
|
wps_dev_type_bin2str(msg.pri_dev_type,
|
||||||
devtype,
|
devtype,
|
||||||
sizeof(devtype)));
|
sizeof(devtype)));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "p2p_device_name=%s\n",
|
ret = os_snprintf(pos, end - pos, "p2p_device_name=%s\n",
|
||||||
msg.device_name);
|
msg.device_name);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -703,14 +703,14 @@ int p2p_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
ret = os_snprintf(pos, end - pos, "p2p_device_addr=" MACSTR
|
ret = os_snprintf(pos, end - pos, "p2p_device_addr=" MACSTR
|
||||||
"\n",
|
"\n",
|
||||||
MAC2STR(msg.p2p_device_addr));
|
MAC2STR(msg.p2p_device_addr));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "p2p_config_methods=0x%x\n",
|
ret = os_snprintf(pos, end - pos, "p2p_config_methods=0x%x\n",
|
||||||
msg.config_methods);
|
msg.config_methods);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ void p2p_channels_dump(struct p2p_data *p2p, const char *title,
|
|||||||
const struct p2p_reg_class *c;
|
const struct p2p_reg_class *c;
|
||||||
c = &chan->reg_class[i];
|
c = &chan->reg_class[i];
|
||||||
ret = os_snprintf(pos, end - pos, " %u:", c->reg_class);
|
ret = os_snprintf(pos, end - pos, " %u:", c->reg_class);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
break;
|
break;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ void p2p_channels_dump(struct p2p_data *p2p, const char *title,
|
|||||||
ret = os_snprintf(pos, end - pos, "%s%u",
|
ret = os_snprintf(pos, end - pos, "%s%u",
|
||||||
j == 0 ? "" : ",",
|
j == 0 ? "" : ",",
|
||||||
c->channel[j]);
|
c->channel[j]);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
break;
|
break;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -1900,7 +1900,7 @@ int radius_server_get_mib(struct radius_server_data *data, char *buf,
|
|||||||
"radiusAuthServResetTime=0\n"
|
"radiusAuthServResetTime=0\n"
|
||||||
"radiusAuthServConfigReset=4\n",
|
"radiusAuthServConfigReset=4\n",
|
||||||
uptime);
|
uptime);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
}
|
}
|
||||||
@ -1939,7 +1939,7 @@ int radius_server_get_mib(struct radius_server_data *data, char *buf,
|
|||||||
data->counters.malformed_acct_requests,
|
data->counters.malformed_acct_requests,
|
||||||
data->counters.acct_bad_authenticators,
|
data->counters.acct_bad_authenticators,
|
||||||
data->counters.unknown_acct_types);
|
data->counters.unknown_acct_types);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
}
|
}
|
||||||
@ -1997,7 +1997,7 @@ int radius_server_get_mib(struct radius_server_data *data, char *buf,
|
|||||||
cli->counters.malformed_acct_requests,
|
cli->counters.malformed_acct_requests,
|
||||||
cli->counters.acct_bad_authenticators,
|
cli->counters.acct_bad_authenticators,
|
||||||
cli->counters.unknown_acct_types);
|
cli->counters.unknown_acct_types);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
}
|
}
|
||||||
|
@ -482,7 +482,7 @@ int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
|
|||||||
ret = os_snprintf(pos, buf + len - pos,
|
ret = os_snprintf(pos, buf + len - pos,
|
||||||
"Index / AA / PMKID / expiration (in seconds) / "
|
"Index / AA / PMKID / expiration (in seconds) / "
|
||||||
"opportunistic\n");
|
"opportunistic\n");
|
||||||
if (ret < 0 || ret >= buf + len - pos)
|
if (os_snprintf_error(buf + len - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -491,7 +491,7 @@ int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
|
|||||||
i++;
|
i++;
|
||||||
ret = os_snprintf(pos, buf + len - pos, "%d " MACSTR " ",
|
ret = os_snprintf(pos, buf + len - pos, "%d " MACSTR " ",
|
||||||
i, MAC2STR(entry->aa));
|
i, MAC2STR(entry->aa));
|
||||||
if (ret < 0 || ret >= buf + len - pos)
|
if (os_snprintf_error(buf + len - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
pos += wpa_snprintf_hex(pos, buf + len - pos, entry->pmkid,
|
pos += wpa_snprintf_hex(pos, buf + len - pos, entry->pmkid,
|
||||||
@ -499,7 +499,7 @@ int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
|
|||||||
ret = os_snprintf(pos, buf + len - pos, " %d %d\n",
|
ret = os_snprintf(pos, buf + len - pos, " %d %d\n",
|
||||||
(int) (entry->expiration - now.sec),
|
(int) (entry->expiration - now.sec),
|
||||||
entry->opportunistic);
|
entry->opportunistic);
|
||||||
if (ret < 0 || ret >= buf + len - pos)
|
if (os_snprintf_error(buf + len - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
entry = entry->next;
|
entry = entry->next;
|
||||||
|
@ -501,7 +501,7 @@ int rsn_preauth_get_status(struct wpa_sm *sm, char *buf, size_t buflen,
|
|||||||
if (sm->preauth_eapol) {
|
if (sm->preauth_eapol) {
|
||||||
ret = os_snprintf(pos, end - pos, "Pre-authentication "
|
ret = os_snprintf(pos, end - pos, "Pre-authentication "
|
||||||
"EAPOL state machines:\n");
|
"EAPOL state machines:\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
res = eapol_sm_get_status(sm->preauth_eapol,
|
res = eapol_sm_get_status(sm->preauth_eapol,
|
||||||
|
@ -2015,7 +2015,7 @@ int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen)
|
|||||||
sm->dot11RSNAConfigPMKLifetime,
|
sm->dot11RSNAConfigPMKLifetime,
|
||||||
sm->dot11RSNAConfigPMKReauthThreshold,
|
sm->dot11RSNAConfigPMKReauthThreshold,
|
||||||
sm->dot11RSNAConfigSATimeout);
|
sm->dot11RSNAConfigSATimeout);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return 0;
|
return 0;
|
||||||
len = ret;
|
len = ret;
|
||||||
|
|
||||||
@ -2484,7 +2484,7 @@ int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen,
|
|||||||
wpa_cipher_txt(sm->pairwise_cipher),
|
wpa_cipher_txt(sm->pairwise_cipher),
|
||||||
wpa_cipher_txt(sm->group_cipher),
|
wpa_cipher_txt(sm->group_cipher),
|
||||||
wpa_key_mgmt_txt(sm->key_mgmt, sm->proto));
|
wpa_key_mgmt_txt(sm->key_mgmt, sm->proto));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -2497,7 +2497,7 @@ int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen,
|
|||||||
ret = os_snprintf(pos, end - pos, "pmf=%d\n",
|
ret = os_snprintf(pos, end - pos, "pmf=%d\n",
|
||||||
(rsn.capabilities &
|
(rsn.capabilities &
|
||||||
WPA_CAPABILITY_MFPR) ? 2 : 1);
|
WPA_CAPABILITY_MFPR) ? 2 : 1);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ void asn1_oid_to_str(const struct asn1_oid *oid, char *buf, size_t len)
|
|||||||
ret = os_snprintf(pos, buf + len - pos,
|
ret = os_snprintf(pos, buf + len - pos,
|
||||||
"%s%lu",
|
"%s%lu",
|
||||||
i == 0 ? "" : ".", oid->oid[i]);
|
i == 0 ? "" : ".", oid->oid[i]);
|
||||||
if (ret < 0 || ret >= buf + len - pos)
|
if (os_snprintf_error(buf + len - pos, ret))
|
||||||
break;
|
break;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ void x509_name_string(struct x509_name *name, char *buf, size_t len)
|
|||||||
ret = os_snprintf(pos, end - pos, "%s=%s, ",
|
ret = os_snprintf(pos, end - pos, "%s=%s, ",
|
||||||
x509_name_attr_str(name->attr[i].type),
|
x509_name_attr_str(name->attr[i].type),
|
||||||
name->attr[i].value);
|
name->attr[i].value);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
goto done;
|
goto done;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -527,7 +527,7 @@ void x509_name_string(struct x509_name *name, char *buf, size_t len)
|
|||||||
if (name->email) {
|
if (name->email) {
|
||||||
ret = os_snprintf(pos, end - pos, "/emailAddress=%s",
|
ret = os_snprintf(pos, end - pos, "/emailAddress=%s",
|
||||||
name->email);
|
name->email);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
goto done;
|
goto done;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ static inline int _wpa_snprintf_hex(char *buf, size_t buf_size, const u8 *data,
|
|||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, uppercase ? "%02X" : "%02x",
|
ret = os_snprintf(pos, end - pos, uppercase ? "%02X" : "%02x",
|
||||||
data[i]);
|
data[i]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ int uuid_bin2str(const u8 *bin, char *str, size_t max_len)
|
|||||||
bin[4], bin[5], bin[6], bin[7],
|
bin[4], bin[5], bin[6], bin[7],
|
||||||
bin[8], bin[9], bin[10], bin[11],
|
bin[8], bin[9], bin[10], bin[11],
|
||||||
bin[12], bin[13], bin[14], bin[15]);
|
bin[12], bin[13], bin[14], bin[15]);
|
||||||
if (len < 0 || (size_t) len >= max_len)
|
if (os_snprintf_error(max_len, len))
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -619,7 +619,7 @@ void wpa_msg(void *ctx, int level, const char *fmt, ...)
|
|||||||
if (ifname) {
|
if (ifname) {
|
||||||
int res = os_snprintf(prefix, sizeof(prefix), "%s: ",
|
int res = os_snprintf(prefix, sizeof(prefix), "%s: ",
|
||||||
ifname);
|
ifname);
|
||||||
if (res < 0 || res >= (int) sizeof(prefix))
|
if (os_snprintf_error(sizeof(prefix), res))
|
||||||
prefix[0] = '\0';
|
prefix[0] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -560,7 +560,7 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
"wps_state=configured\n");
|
"wps_state=configured\n");
|
||||||
else
|
else
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -568,7 +568,7 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
if (attr.ap_setup_locked && *attr.ap_setup_locked) {
|
if (attr.ap_setup_locked && *attr.ap_setup_locked) {
|
||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"wps_ap_setup_locked=1\n");
|
"wps_ap_setup_locked=1\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -576,7 +576,7 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
if (attr.selected_registrar && *attr.selected_registrar) {
|
if (attr.selected_registrar && *attr.selected_registrar) {
|
||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"wps_selected_registrar=1\n");
|
"wps_selected_registrar=1\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -585,7 +585,7 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"wps_device_password_id=%u\n",
|
"wps_device_password_id=%u\n",
|
||||||
WPA_GET_BE16(attr.dev_password_id));
|
WPA_GET_BE16(attr.dev_password_id));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -595,7 +595,7 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
"wps_selected_registrar_config_methods="
|
"wps_selected_registrar_config_methods="
|
||||||
"0x%04x\n",
|
"0x%04x\n",
|
||||||
WPA_GET_BE16(attr.sel_reg_config_methods));
|
WPA_GET_BE16(attr.sel_reg_config_methods));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -607,7 +607,7 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
wps_dev_type_bin2str(attr.primary_dev_type,
|
wps_dev_type_bin2str(attr.primary_dev_type,
|
||||||
devtype,
|
devtype,
|
||||||
sizeof(devtype)));
|
sizeof(devtype)));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -626,7 +626,7 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
str[i] = '\0';
|
str[i] = '\0';
|
||||||
ret = os_snprintf(pos, end - pos, "wps_device_name=%s\n", str);
|
ret = os_snprintf(pos, end - pos, "wps_device_name=%s\n", str);
|
||||||
os_free(str);
|
os_free(str);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -635,7 +635,7 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
|
|||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"wps_config_methods=0x%04x\n",
|
"wps_config_methods=0x%04x\n",
|
||||||
WPA_GET_BE16(attr.config_methods));
|
WPA_GET_BE16(attr.config_methods));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -489,7 +489,7 @@ char * wps_dev_type_bin2str(const u8 dev_type[WPS_DEV_TYPE_LEN], char *buf,
|
|||||||
ret = os_snprintf(buf, buf_len, "%u-%08X-%u",
|
ret = os_snprintf(buf, buf_len, "%u-%08X-%u",
|
||||||
WPA_GET_BE16(dev_type), WPA_GET_BE32(&dev_type[2]),
|
WPA_GET_BE16(dev_type), WPA_GET_BE32(&dev_type[2]),
|
||||||
WPA_GET_BE16(&dev_type[6]));
|
WPA_GET_BE16(&dev_type[6]));
|
||||||
if (ret < 0 || (unsigned int) ret >= buf_len)
|
if (os_snprintf_error(buf_len, ret))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -3495,7 +3495,7 @@ int wps_registrar_get_info(struct wps_registrar *reg, const u8 *addr,
|
|||||||
d->dev.model_name ? d->dev.model_name : "",
|
d->dev.model_name ? d->dev.model_name : "",
|
||||||
d->dev.model_number ? d->dev.model_number : "",
|
d->dev.model_number ? d->dev.model_number : "",
|
||||||
d->dev.serial_number ? d->dev.serial_number : "");
|
d->dev.serial_number ? d->dev.serial_number : "");
|
||||||
if (ret < 0 || (size_t) ret >= buflen - len)
|
if (os_snprintf_error(buflen - len, ret))
|
||||||
return len;
|
return len;
|
||||||
len += ret;
|
len += ret;
|
||||||
|
|
||||||
|
@ -904,7 +904,7 @@ int wpas_wps_ap_pin_set(struct wpa_supplicant *wpa_s, const char *pin,
|
|||||||
return -1;
|
return -1;
|
||||||
hapd = wpa_s->ap_iface->bss[0];
|
hapd = wpa_s->ap_iface->bss[0];
|
||||||
ret = os_snprintf(pin_txt, sizeof(pin_txt), "%s", pin);
|
ret = os_snprintf(pin_txt, sizeof(pin_txt), "%s", pin);
|
||||||
if (ret < 0 || ret >= (int) sizeof(pin_txt))
|
if (os_snprintf_error(sizeof(pin_txt), ret))
|
||||||
return -1;
|
return -1;
|
||||||
os_free(hapd->conf->ap_pin);
|
os_free(hapd->conf->ap_pin);
|
||||||
hapd->conf->ap_pin = os_strdup(pin_txt);
|
hapd->conf->ap_pin = os_strdup(pin_txt);
|
||||||
@ -1058,7 +1058,7 @@ int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf,
|
|||||||
wpa_cipher_txt(conf->wpa_group),
|
wpa_cipher_txt(conf->wpa_group),
|
||||||
wpa_key_mgmt_txt(conf->wpa_key_mgmt,
|
wpa_key_mgmt_txt(conf->wpa_key_mgmt,
|
||||||
conf->wpa));
|
conf->wpa));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
|
@ -294,7 +294,7 @@ static void bgscan_learn_timeout(void *eloop_ctx, void *timeout_ctx)
|
|||||||
int ret;
|
int ret;
|
||||||
ret = os_snprintf(pos, msg + sizeof(msg) - pos, " %d",
|
ret = os_snprintf(pos, msg + sizeof(msg) - pos, " %d",
|
||||||
freqs[i]);
|
freqs[i]);
|
||||||
if (ret < 0 || ret >= msg + sizeof(msg) - pos)
|
if (os_snprintf_error(msg + sizeof(msg) - pos, ret))
|
||||||
break;
|
break;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ static char * wpa_config_write_int(const struct parse_data *data,
|
|||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
res = os_snprintf(value, 20, "%d", *src);
|
res = os_snprintf(value, 20, "%d", *src);
|
||||||
if (res < 0 || res >= 20) {
|
if (os_snprintf_error(20, res)) {
|
||||||
os_free(value);
|
os_free(value);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ static char * wpa_config_write_bssid(const struct parse_data *data,
|
|||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
res = os_snprintf(value, 20, MACSTR, MAC2STR(ssid->bssid));
|
res = os_snprintf(value, 20, MACSTR, MAC2STR(ssid->bssid));
|
||||||
if (res < 0 || res >= 20) {
|
if (os_snprintf_error(20, res)) {
|
||||||
os_free(value);
|
os_free(value);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -446,7 +446,7 @@ static char * wpa_config_write_proto(const struct parse_data *data,
|
|||||||
if (ssid->proto & WPA_PROTO_WPA) {
|
if (ssid->proto & WPA_PROTO_WPA) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWPA",
|
ret = os_snprintf(pos, end - pos, "%sWPA",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return buf;
|
return buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -454,7 +454,7 @@ static char * wpa_config_write_proto(const struct parse_data *data,
|
|||||||
if (ssid->proto & WPA_PROTO_RSN) {
|
if (ssid->proto & WPA_PROTO_RSN) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sRSN",
|
ret = os_snprintf(pos, end - pos, "%sRSN",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return buf;
|
return buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -462,7 +462,7 @@ static char * wpa_config_write_proto(const struct parse_data *data,
|
|||||||
if (ssid->proto & WPA_PROTO_OSEN) {
|
if (ssid->proto & WPA_PROTO_OSEN) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sOSEN",
|
ret = os_snprintf(pos, end - pos, "%sOSEN",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return buf;
|
return buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -576,7 +576,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_PSK) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_PSK) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWPA-PSK",
|
ret = os_snprintf(pos, end - pos, "%sWPA-PSK",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -586,7 +586,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWPA-EAP",
|
ret = os_snprintf(pos, end - pos, "%sWPA-EAP",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -596,7 +596,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sIEEE8021X",
|
ret = os_snprintf(pos, end - pos, "%sIEEE8021X",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -606,7 +606,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_NONE) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_NONE) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sNONE",
|
ret = os_snprintf(pos, end - pos, "%sNONE",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -616,7 +616,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_WPA_NONE) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_WPA_NONE) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWPA-NONE",
|
ret = os_snprintf(pos, end - pos, "%sWPA-NONE",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -627,7 +627,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_FT_PSK) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_FT_PSK) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sFT-PSK",
|
ret = os_snprintf(pos, end - pos, "%sFT-PSK",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -637,7 +637,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sFT-EAP",
|
ret = os_snprintf(pos, end - pos, "%sFT-EAP",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -649,7 +649,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_PSK_SHA256) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_PSK_SHA256) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWPA-PSK-SHA256",
|
ret = os_snprintf(pos, end - pos, "%sWPA-PSK-SHA256",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -659,7 +659,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWPA-EAP-SHA256",
|
ret = os_snprintf(pos, end - pos, "%sWPA-EAP-SHA256",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWPS",
|
ret = os_snprintf(pos, end - pos, "%sWPS",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -683,7 +683,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sSAE",
|
ret = os_snprintf(pos, end - pos, "%sSAE",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -693,7 +693,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_FT_SAE) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_FT_SAE) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sFT-SAE",
|
ret = os_snprintf(pos, end - pos, "%sFT-SAE",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -705,7 +705,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_OSEN) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_OSEN) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sOSEN",
|
ret = os_snprintf(pos, end - pos, "%sOSEN",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -716,7 +716,7 @@ static char * wpa_config_write_key_mgmt(const struct parse_data *data,
|
|||||||
if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_SUITE_B) {
|
if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_SUITE_B) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWPA-EAP-SUITE-B",
|
ret = os_snprintf(pos, end - pos, "%sWPA-EAP-SUITE-B",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -892,7 +892,7 @@ static char * wpa_config_write_auth_alg(const struct parse_data *data,
|
|||||||
if (ssid->auth_alg & WPA_AUTH_ALG_OPEN) {
|
if (ssid->auth_alg & WPA_AUTH_ALG_OPEN) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sOPEN",
|
ret = os_snprintf(pos, end - pos, "%sOPEN",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -902,7 +902,7 @@ static char * wpa_config_write_auth_alg(const struct parse_data *data,
|
|||||||
if (ssid->auth_alg & WPA_AUTH_ALG_SHARED) {
|
if (ssid->auth_alg & WPA_AUTH_ALG_SHARED) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sSHARED",
|
ret = os_snprintf(pos, end - pos, "%sSHARED",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -912,7 +912,7 @@ static char * wpa_config_write_auth_alg(const struct parse_data *data,
|
|||||||
if (ssid->auth_alg & WPA_AUTH_ALG_LEAP) {
|
if (ssid->auth_alg & WPA_AUTH_ALG_LEAP) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sLEAP",
|
ret = os_snprintf(pos, end - pos, "%sLEAP",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -1033,7 +1033,7 @@ static char * wpa_config_write_freqs(const struct parse_data *data,
|
|||||||
for (i = 0; freqs[i]; i++) {
|
for (i = 0; freqs[i]; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, "%s%u",
|
ret = os_snprintf(pos, end - pos, "%s%u",
|
||||||
i == 0 ? "" : " ", freqs[i]);
|
i == 0 ? "" : " ", freqs[i]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
end[-1] = '\0';
|
end[-1] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -1156,7 +1156,7 @@ static char * wpa_config_write_eap(const struct parse_data *data,
|
|||||||
if (name) {
|
if (name) {
|
||||||
ret = os_snprintf(pos, end - pos, "%s%s",
|
ret = os_snprintf(pos, end - pos, "%s%s",
|
||||||
pos == buf ? "" : " ", name);
|
pos == buf ? "" : " ", name);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
break;
|
break;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1433,7 +1433,7 @@ static char * wpa_config_write_go_p2p_dev_addr(const struct parse_data *data,
|
|||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
res = os_snprintf(value, 20, MACSTR, MAC2STR(ssid->go_p2p_dev_addr));
|
res = os_snprintf(value, 20, MACSTR, MAC2STR(ssid->go_p2p_dev_addr));
|
||||||
if (res < 0 || res >= 20) {
|
if (os_snprintf_error(20, res)) {
|
||||||
os_free(value);
|
os_free(value);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1518,7 +1518,7 @@ static char * wpa_config_write_p2p_client_list(const struct parse_data *data,
|
|||||||
res = os_snprintf(pos, end - pos, MACSTR " ",
|
res = os_snprintf(pos, end - pos, MACSTR " ",
|
||||||
MAC2STR(ssid->p2p_client_list +
|
MAC2STR(ssid->p2p_client_list +
|
||||||
(i - 1) * ETH_ALEN));
|
(i - 1) * ETH_ALEN));
|
||||||
if (res < 0 || res >= end - pos) {
|
if (os_snprintf_error(end - pos, res)) {
|
||||||
os_free(value);
|
os_free(value);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -3071,7 +3071,7 @@ char * wpa_config_get_cred_no_key(struct wpa_cred *cred, const char *var)
|
|||||||
ret = os_snprintf(pos, end - pos, "%s%u",
|
ret = os_snprintf(pos, end - pos, "%s%u",
|
||||||
i > 0 ? "\n" : "",
|
i > 0 ? "\n" : "",
|
||||||
cred->req_conn_capab_proto[i]);
|
cred->req_conn_capab_proto[i]);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return buf;
|
return buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -3083,7 +3083,7 @@ char * wpa_config_get_cred_no_key(struct wpa_cred *cred, const char *var)
|
|||||||
"%s%d",
|
"%s%d",
|
||||||
j > 0 ? "," : ":",
|
j > 0 ? "," : ":",
|
||||||
ports[j]);
|
ports[j]);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return buf;
|
return buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3152,7 +3152,7 @@ char * wpa_config_get_cred_no_key(struct wpa_cred *cred, const char *var)
|
|||||||
for (i = 0; i < cred->num_domain; i++) {
|
for (i = 0; i < cred->num_domain; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, "%s%s",
|
ret = os_snprintf(pos, end - pos, "%s%s",
|
||||||
i > 0 ? "\n" : "", cred->domain[i]);
|
i > 0 ? "\n" : "", cred->domain[i]);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return buf;
|
return buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3217,7 +3217,7 @@ char * wpa_config_get_cred_no_key(struct wpa_cred *cred, const char *var)
|
|||||||
ret = os_snprintf(pos, end - pos, "%s%s",
|
ret = os_snprintf(pos, end - pos, "%s%s",
|
||||||
i > 0 ? "\n" : "",
|
i > 0 ? "\n" : "",
|
||||||
wpa_ssid_txt(e->ssid, e->ssid_len));
|
wpa_ssid_txt(e->ssid, e->ssid_len));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return buf;
|
return buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3247,7 +3247,7 @@ char * wpa_config_get_cred_no_key(struct wpa_cred *cred, const char *var)
|
|||||||
i > 0 ? "\n" : "",
|
i > 0 ? "\n" : "",
|
||||||
p->fqdn, p->exact_match, p->priority,
|
p->fqdn, p->exact_match, p->priority,
|
||||||
p->country);
|
p->country);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return buf;
|
return buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -608,7 +608,7 @@ static void write_wep_key(FILE *f, int idx, struct wpa_ssid *ssid)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = os_snprintf(field, sizeof(field), "wep_key%d", idx);
|
res = os_snprintf(field, sizeof(field), "wep_key%d", idx);
|
||||||
if (res < 0 || (size_t) res >= sizeof(field))
|
if (os_snprintf_error(sizeof(field), res))
|
||||||
return;
|
return;
|
||||||
value = wpa_config_get(ssid, field);
|
value = wpa_config_get(ssid, field);
|
||||||
if (value) {
|
if (value) {
|
||||||
|
@ -475,7 +475,7 @@ static int wpa_supplicant_ctrl_iface_get(struct wpa_supplicant *wpa_s,
|
|||||||
else
|
else
|
||||||
enabled = wpa_s->global->wifi_display;
|
enabled = wpa_s->global->wifi_display;
|
||||||
res = os_snprintf(buf, buflen, "%d", enabled);
|
res = os_snprintf(buf, buflen, "%d", enabled);
|
||||||
if (res < 0 || (unsigned int) res >= buflen)
|
if (os_snprintf_error(buflen, res))
|
||||||
return -1;
|
return -1;
|
||||||
return res;
|
return res;
|
||||||
#endif /* CONFIG_WIFI_DISPLAY */
|
#endif /* CONFIG_WIFI_DISPLAY */
|
||||||
@ -813,7 +813,7 @@ static int wpa_supplicant_ctrl_iface_wps_pin(struct wpa_supplicant *wpa_s,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -1;
|
return -1;
|
||||||
ret = os_snprintf(buf, buflen, "%s", pin);
|
ret = os_snprintf(buf, buflen, "%s", pin);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return -1;
|
return -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -825,7 +825,7 @@ static int wpa_supplicant_ctrl_iface_wps_pin(struct wpa_supplicant *wpa_s,
|
|||||||
done:
|
done:
|
||||||
/* Return the generated PIN */
|
/* Return the generated PIN */
|
||||||
ret = os_snprintf(buf, buflen, "%08d", ret);
|
ret = os_snprintf(buf, buflen, "%08d", ret);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return -1;
|
return -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -862,14 +862,14 @@ static int wpa_supplicant_ctrl_iface_wps_check_pin(
|
|||||||
if (!wps_pin_valid(pin_val)) {
|
if (!wps_pin_valid(pin_val)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Invalid checksum digit");
|
wpa_printf(MSG_DEBUG, "WPS: Invalid checksum digit");
|
||||||
ret = os_snprintf(buf, buflen, "FAIL-CHECKSUM\n");
|
ret = os_snprintf(buf, buflen, "FAIL-CHECKSUM\n");
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return -1;
|
return -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(buf, buflen, "%s", pin);
|
ret = os_snprintf(buf, buflen, "%s", pin);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -1603,12 +1603,12 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
struct wpa_ssid *ssid = wpa_s->current_ssid;
|
struct wpa_ssid *ssid = wpa_s->current_ssid;
|
||||||
ret = os_snprintf(pos, end - pos, "bssid=" MACSTR "\n",
|
ret = os_snprintf(pos, end - pos, "bssid=" MACSTR "\n",
|
||||||
MAC2STR(wpa_s->bssid));
|
MAC2STR(wpa_s->bssid));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
ret = os_snprintf(pos, end - pos, "freq=%u\n",
|
ret = os_snprintf(pos, end - pos, "freq=%u\n",
|
||||||
wpa_s->assoc_freq);
|
wpa_s->assoc_freq);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
if (ssid) {
|
if (ssid) {
|
||||||
@ -1626,7 +1626,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
ret = os_snprintf(pos, end - pos, "ssid=%s\nid=%d\n",
|
ret = os_snprintf(pos, end - pos, "ssid=%s\nid=%d\n",
|
||||||
wpa_ssid_txt(_ssid, ssid_len),
|
wpa_ssid_txt(_ssid, ssid_len),
|
||||||
ssid->id);
|
ssid->id);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -1637,7 +1637,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"passphrase=%s\n",
|
"passphrase=%s\n",
|
||||||
ssid->passphrase);
|
ssid->passphrase);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1645,7 +1645,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"id_str=%s\n",
|
"id_str=%s\n",
|
||||||
ssid->id_str);
|
ssid->id_str);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1698,21 +1698,21 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
wpa_s->sme.sae.state == SAE_ACCEPTED) {
|
wpa_s->sme.sae.state == SAE_ACCEPTED) {
|
||||||
ret = os_snprintf(pos, end - pos, "sae_group=%d\n",
|
ret = os_snprintf(pos, end - pos, "sae_group=%d\n",
|
||||||
wpa_s->sme.sae.group);
|
wpa_s->sme.sae.group);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SAE */
|
#endif /* CONFIG_SAE */
|
||||||
ret = os_snprintf(pos, end - pos, "wpa_state=%s\n",
|
ret = os_snprintf(pos, end - pos, "wpa_state=%s\n",
|
||||||
wpa_supplicant_state_txt(wpa_s->wpa_state));
|
wpa_supplicant_state_txt(wpa_s->wpa_state));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
if (wpa_s->l2 &&
|
if (wpa_s->l2 &&
|
||||||
l2_packet_get_ip_addr(wpa_s->l2, tmp, sizeof(tmp)) >= 0) {
|
l2_packet_get_ip_addr(wpa_s->l2, tmp, sizeof(tmp)) >= 0) {
|
||||||
ret = os_snprintf(pos, end - pos, "ip_address=%s\n", tmp);
|
ret = os_snprintf(pos, end - pos, "ip_address=%s\n", tmp);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1721,7 +1721,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
if (wpa_s->global->p2p) {
|
if (wpa_s->global->p2p) {
|
||||||
ret = os_snprintf(pos, end - pos, "p2p_device_address=" MACSTR
|
ret = os_snprintf(pos, end - pos, "p2p_device_address=" MACSTR
|
||||||
"\n", MAC2STR(wpa_s->global->p2p_dev_addr));
|
"\n", MAC2STR(wpa_s->global->p2p_dev_addr));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1729,7 +1729,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "address=" MACSTR "\n",
|
ret = os_snprintf(pos, end - pos, "address=" MACSTR "\n",
|
||||||
MAC2STR(wpa_s->own_addr));
|
MAC2STR(wpa_s->own_addr));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -1745,7 +1745,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
release = rel_num + 1;
|
release = rel_num + 1;
|
||||||
}
|
}
|
||||||
ret = os_snprintf(pos, end - pos, "hs20=%d\n", release);
|
ret = os_snprintf(pos, end - pos, "hs20=%d\n", release);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1764,7 +1764,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"provisioning_sp=%s\n",
|
"provisioning_sp=%s\n",
|
||||||
cred->provisioning_sp);
|
cred->provisioning_sp);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1787,7 +1787,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
}
|
}
|
||||||
ret = os_snprintf(pos, end - pos, "home_sp=%s\n",
|
ret = os_snprintf(pos, end - pos, "home_sp=%s\n",
|
||||||
cred->domain[i]);
|
cred->domain[i]);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -1807,7 +1807,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
type = "unknown";
|
type = "unknown";
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "sp_type=%s\n", type);
|
ret = os_snprintf(pos, end - pos, "sp_type=%s\n", type);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -1833,7 +1833,7 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
|
|||||||
char uuid_str[100];
|
char uuid_str[100];
|
||||||
uuid_bin2str(wpa_s->wps->uuid, uuid_str, sizeof(uuid_str));
|
uuid_bin2str(wpa_s->wps->uuid, uuid_str, sizeof(uuid_str));
|
||||||
ret = os_snprintf(pos, end - pos, "uuid=%s\n", uuid_str);
|
ret = os_snprintf(pos, end - pos, "uuid=%s\n", uuid_str);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -1921,7 +1921,7 @@ static int wpa_supplicant_ctrl_iface_blacklist(struct wpa_supplicant *wpa_s,
|
|||||||
while (e) {
|
while (e) {
|
||||||
ret = os_snprintf(pos, end - pos, MACSTR "\n",
|
ret = os_snprintf(pos, end - pos, MACSTR "\n",
|
||||||
MAC2STR(e->bssid));
|
MAC2STR(e->bssid));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
e = e->next;
|
e = e->next;
|
||||||
@ -2011,7 +2011,7 @@ static int wpa_supplicant_ctrl_iface_log_level(struct wpa_supplicant *wpa_s,
|
|||||||
"Timestamp: %d\n",
|
"Timestamp: %d\n",
|
||||||
debug_level_str(wpa_debug_level),
|
debug_level_str(wpa_debug_level),
|
||||||
wpa_debug_timestamp);
|
wpa_debug_timestamp);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -2054,7 +2054,7 @@ static int wpa_supplicant_ctrl_iface_list_networks(
|
|||||||
end = buf + buflen;
|
end = buf + buflen;
|
||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"network id / ssid / bssid / flags\n");
|
"network id / ssid / bssid / flags\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -2075,7 +2075,7 @@ static int wpa_supplicant_ctrl_iface_list_networks(
|
|||||||
ret = os_snprintf(pos, end - pos, "%d\t%s",
|
ret = os_snprintf(pos, end - pos, "%d\t%s",
|
||||||
ssid->id,
|
ssid->id,
|
||||||
wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
|
wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return prev - buf;
|
return prev - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
if (ssid->bssid_set) {
|
if (ssid->bssid_set) {
|
||||||
@ -2084,7 +2084,7 @@ static int wpa_supplicant_ctrl_iface_list_networks(
|
|||||||
} else {
|
} else {
|
||||||
ret = os_snprintf(pos, end - pos, "\tany");
|
ret = os_snprintf(pos, end - pos, "\tany");
|
||||||
}
|
}
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return prev - buf;
|
return prev - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
ret = os_snprintf(pos, end - pos, "\t%s%s%s%s",
|
ret = os_snprintf(pos, end - pos, "\t%s%s%s%s",
|
||||||
@ -2095,11 +2095,11 @@ static int wpa_supplicant_ctrl_iface_list_networks(
|
|||||||
"[TEMP-DISABLED]" : "",
|
"[TEMP-DISABLED]" : "",
|
||||||
ssid->disabled == 2 ? "[P2P-PERSISTENT]" :
|
ssid->disabled == 2 ? "[P2P-PERSISTENT]" :
|
||||||
"");
|
"");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return prev - buf;
|
return prev - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return prev - buf;
|
return prev - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -2114,7 +2114,7 @@ static char * wpa_supplicant_cipher_txt(char *pos, char *end, int cipher)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = os_snprintf(pos, end - pos, "-");
|
ret = os_snprintf(pos, end - pos, "-");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
ret = wpa_write_ciphers(pos, end, cipher, "+");
|
ret = wpa_write_ciphers(pos, end, cipher, "+");
|
||||||
@ -2133,13 +2133,13 @@ static char * wpa_supplicant_ie_txt(char *pos, char *end, const char *proto,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "[%s-", proto);
|
ret = os_snprintf(pos, end - pos, "[%s-", proto);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
if (wpa_parse_wpa_ie(ie, ie_len, &data) < 0) {
|
if (wpa_parse_wpa_ie(ie, ie_len, &data) < 0) {
|
||||||
ret = os_snprintf(pos, end - pos, "?]");
|
ret = os_snprintf(pos, end - pos, "?]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
return pos;
|
return pos;
|
||||||
@ -2149,28 +2149,28 @@ static char * wpa_supplicant_ie_txt(char *pos, char *end, const char *proto,
|
|||||||
if (data.key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
|
if (data.key_mgmt & WPA_KEY_MGMT_IEEE8021X) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sEAP",
|
ret = os_snprintf(pos, end - pos, "%sEAP",
|
||||||
pos == start ? "" : "+");
|
pos == start ? "" : "+");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (data.key_mgmt & WPA_KEY_MGMT_PSK) {
|
if (data.key_mgmt & WPA_KEY_MGMT_PSK) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sPSK",
|
ret = os_snprintf(pos, end - pos, "%sPSK",
|
||||||
pos == start ? "" : "+");
|
pos == start ? "" : "+");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (data.key_mgmt & WPA_KEY_MGMT_WPA_NONE) {
|
if (data.key_mgmt & WPA_KEY_MGMT_WPA_NONE) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sNone",
|
ret = os_snprintf(pos, end - pos, "%sNone",
|
||||||
pos == start ? "" : "+");
|
pos == start ? "" : "+");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (data.key_mgmt & WPA_KEY_MGMT_SAE) {
|
if (data.key_mgmt & WPA_KEY_MGMT_SAE) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sSAE",
|
ret = os_snprintf(pos, end - pos, "%sSAE",
|
||||||
pos == start ? "" : "+");
|
pos == start ? "" : "+");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -2178,21 +2178,21 @@ static char * wpa_supplicant_ie_txt(char *pos, char *end, const char *proto,
|
|||||||
if (data.key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X) {
|
if (data.key_mgmt & WPA_KEY_MGMT_FT_IEEE8021X) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sFT/EAP",
|
ret = os_snprintf(pos, end - pos, "%sFT/EAP",
|
||||||
pos == start ? "" : "+");
|
pos == start ? "" : "+");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (data.key_mgmt & WPA_KEY_MGMT_FT_PSK) {
|
if (data.key_mgmt & WPA_KEY_MGMT_FT_PSK) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sFT/PSK",
|
ret = os_snprintf(pos, end - pos, "%sFT/PSK",
|
||||||
pos == start ? "" : "+");
|
pos == start ? "" : "+");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (data.key_mgmt & WPA_KEY_MGMT_FT_SAE) {
|
if (data.key_mgmt & WPA_KEY_MGMT_FT_SAE) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sFT/SAE",
|
ret = os_snprintf(pos, end - pos, "%sFT/SAE",
|
||||||
pos == start ? "" : "+");
|
pos == start ? "" : "+");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -2201,14 +2201,14 @@ static char * wpa_supplicant_ie_txt(char *pos, char *end, const char *proto,
|
|||||||
if (data.key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256) {
|
if (data.key_mgmt & WPA_KEY_MGMT_IEEE8021X_SHA256) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sEAP-SHA256",
|
ret = os_snprintf(pos, end - pos, "%sEAP-SHA256",
|
||||||
pos == start ? "" : "+");
|
pos == start ? "" : "+");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (data.key_mgmt & WPA_KEY_MGMT_PSK_SHA256) {
|
if (data.key_mgmt & WPA_KEY_MGMT_PSK_SHA256) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sPSK-SHA256",
|
ret = os_snprintf(pos, end - pos, "%sPSK-SHA256",
|
||||||
pos == start ? "" : "+");
|
pos == start ? "" : "+");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -2217,7 +2217,7 @@ static char * wpa_supplicant_ie_txt(char *pos, char *end, const char *proto,
|
|||||||
if (data.key_mgmt & WPA_KEY_MGMT_IEEE8021X_SUITE_B) {
|
if (data.key_mgmt & WPA_KEY_MGMT_IEEE8021X_SUITE_B) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sEAP-SUITE-B",
|
ret = os_snprintf(pos, end - pos, "%sEAP-SUITE-B",
|
||||||
pos == start ? "" : "+");
|
pos == start ? "" : "+");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -2226,13 +2226,13 @@ static char * wpa_supplicant_ie_txt(char *pos, char *end, const char *proto,
|
|||||||
|
|
||||||
if (data.capabilities & WPA_CAPABILITY_PREAUTH) {
|
if (data.capabilities & WPA_CAPABILITY_PREAUTH) {
|
||||||
ret = os_snprintf(pos, end - pos, "-preauth");
|
ret = os_snprintf(pos, end - pos, "-preauth");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "]");
|
ret = os_snprintf(pos, end - pos, "]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos;
|
return pos;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -2305,7 +2305,7 @@ static int wpa_supplicant_ctrl_iface_scan_result(
|
|||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, MACSTR "\t%d\t%d\t",
|
ret = os_snprintf(pos, end - pos, MACSTR "\t%d\t%d\t",
|
||||||
MAC2STR(bss->bssid), bss->freq, bss->level);
|
MAC2STR(bss->bssid), bss->freq, bss->level);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
|
ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
|
||||||
@ -2319,20 +2319,20 @@ static int wpa_supplicant_ctrl_iface_scan_result(
|
|||||||
pos = wpa_supplicant_wps_ie_txt(wpa_s, pos, end, bss);
|
pos = wpa_supplicant_wps_ie_txt(wpa_s, pos, end, bss);
|
||||||
if (!ie && !ie2 && bss->caps & IEEE80211_CAP_PRIVACY) {
|
if (!ie && !ie2 && bss->caps & IEEE80211_CAP_PRIVACY) {
|
||||||
ret = os_snprintf(pos, end - pos, "[WEP]");
|
ret = os_snprintf(pos, end - pos, "[WEP]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
ret = os_snprintf(pos, end - pos, "[MESH]");
|
ret = os_snprintf(pos, end - pos, "[MESH]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (bss_is_dmg(bss)) {
|
if (bss_is_dmg(bss)) {
|
||||||
const char *s;
|
const char *s;
|
||||||
ret = os_snprintf(pos, end - pos, "[DMG]");
|
ret = os_snprintf(pos, end - pos, "[DMG]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
switch (bss->caps & IEEE80211_CAP_DMG_MASK) {
|
switch (bss->caps & IEEE80211_CAP_DMG_MASK) {
|
||||||
@ -2350,33 +2350,33 @@ static int wpa_supplicant_ctrl_iface_scan_result(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = os_snprintf(pos, end - pos, "%s", s);
|
ret = os_snprintf(pos, end - pos, "%s", s);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
} else {
|
} else {
|
||||||
if (bss->caps & IEEE80211_CAP_IBSS) {
|
if (bss->caps & IEEE80211_CAP_IBSS) {
|
||||||
ret = os_snprintf(pos, end - pos, "[IBSS]");
|
ret = os_snprintf(pos, end - pos, "[IBSS]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (bss->caps & IEEE80211_CAP_ESS) {
|
if (bss->caps & IEEE80211_CAP_ESS) {
|
||||||
ret = os_snprintf(pos, end - pos, "[ESS]");
|
ret = os_snprintf(pos, end - pos, "[ESS]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p2p) {
|
if (p2p) {
|
||||||
ret = os_snprintf(pos, end - pos, "[P2P]");
|
ret = os_snprintf(pos, end - pos, "[P2P]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_HS20
|
#ifdef CONFIG_HS20
|
||||||
if (wpa_bss_get_vendor_ie(bss, HS20_IE_VENDOR_TYPE) && ie2) {
|
if (wpa_bss_get_vendor_ie(bss, HS20_IE_VENDOR_TYPE) && ie2) {
|
||||||
ret = os_snprintf(pos, end - pos, "[HS20]");
|
ret = os_snprintf(pos, end - pos, "[HS20]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -2384,12 +2384,12 @@ static int wpa_supplicant_ctrl_iface_scan_result(
|
|||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\t%s",
|
ret = os_snprintf(pos, end - pos, "\t%s",
|
||||||
wpa_ssid_txt(bss->ssid, bss->ssid_len));
|
wpa_ssid_txt(bss->ssid, bss->ssid_len));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -2408,7 +2408,7 @@ static int wpa_supplicant_ctrl_iface_scan_results(
|
|||||||
end = buf + buflen;
|
end = buf + buflen;
|
||||||
ret = os_snprintf(pos, end - pos, "bssid / frequency / signal level / "
|
ret = os_snprintf(pos, end - pos, "bssid / frequency / signal level / "
|
||||||
"flags / ssid\n");
|
"flags / ssid\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -2627,7 +2627,7 @@ static int wpa_supplicant_ctrl_iface_add_network(
|
|||||||
wpa_config_set_network_defaults(ssid);
|
wpa_config_set_network_defaults(ssid);
|
||||||
|
|
||||||
ret = os_snprintf(buf, buflen, "%d\n", ssid->id);
|
ret = os_snprintf(buf, buflen, "%d\n", ssid->id);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return -1;
|
return -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2909,7 +2909,7 @@ static int wpa_supplicant_ctrl_iface_list_creds(struct wpa_supplicant *wpa_s,
|
|||||||
end = buf + buflen;
|
end = buf + buflen;
|
||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"cred id / realm / username / domain / imsi\n");
|
"cred id / realm / username / domain / imsi\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -2920,7 +2920,7 @@ static int wpa_supplicant_ctrl_iface_list_creds(struct wpa_supplicant *wpa_s,
|
|||||||
cred->username ? cred->username : "",
|
cred->username ? cred->username : "",
|
||||||
cred->domain ? cred->domain[0] : "",
|
cred->domain ? cred->domain[0] : "",
|
||||||
cred->imsi ? cred->imsi : "");
|
cred->imsi ? cred->imsi : "");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -2946,7 +2946,7 @@ static int wpa_supplicant_ctrl_iface_add_cred(struct wpa_supplicant *wpa_s,
|
|||||||
wpa_msg(wpa_s, MSG_INFO, CRED_ADDED "%d", cred->id);
|
wpa_msg(wpa_s, MSG_INFO, CRED_ADDED "%d", cred->id);
|
||||||
|
|
||||||
ret = os_snprintf(buf, buflen, "%d\n", cred->id);
|
ret = os_snprintf(buf, buflen, "%d\n", cred->id);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return -1;
|
return -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3208,7 +3208,7 @@ static int ctrl_iface_get_capability_pairwise(int res, char *strict,
|
|||||||
ret = os_snprintf(pos, end - pos, "%s%s",
|
ret = os_snprintf(pos, end - pos, "%s%s",
|
||||||
pos == buf ? "" : " ",
|
pos == buf ? "" : " ",
|
||||||
ciphers[i].name);
|
ciphers[i].name);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3244,7 +3244,7 @@ static int ctrl_iface_get_capability_group(int res, char *strict,
|
|||||||
ret = os_snprintf(pos, end - pos, "%s%s",
|
ret = os_snprintf(pos, end - pos, "%s%s",
|
||||||
pos == buf ? "" : " ",
|
pos == buf ? "" : " ",
|
||||||
ciphers[i].name);
|
ciphers[i].name);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3276,14 +3276,14 @@ static int ctrl_iface_get_capability_key_mgmt(int res, char *strict,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "NONE IEEE8021X");
|
ret = os_snprintf(pos, end - pos, "NONE IEEE8021X");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
if (capa->key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
if (capa->key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA |
|
||||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2)) {
|
WPA_DRIVER_CAPA_KEY_MGMT_WPA2)) {
|
||||||
ret = os_snprintf(pos, end - pos, " WPA-EAP");
|
ret = os_snprintf(pos, end - pos, " WPA-EAP");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3291,14 +3291,14 @@ static int ctrl_iface_get_capability_key_mgmt(int res, char *strict,
|
|||||||
if (capa->key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK |
|
if (capa->key_mgmt & (WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK |
|
||||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) {
|
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) {
|
||||||
ret = os_snprintf(pos, end - pos, " WPA-PSK");
|
ret = os_snprintf(pos, end - pos, " WPA-PSK");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (capa->key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) {
|
if (capa->key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE) {
|
||||||
ret = os_snprintf(pos, end - pos, " WPA-NONE");
|
ret = os_snprintf(pos, end - pos, " WPA-NONE");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3331,7 +3331,7 @@ static int ctrl_iface_get_capability_proto(int res, char *strict,
|
|||||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) {
|
WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sRSN",
|
ret = os_snprintf(pos, end - pos, "%sRSN",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3340,7 +3340,7 @@ static int ctrl_iface_get_capability_proto(int res, char *strict,
|
|||||||
WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK)) {
|
WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK)) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sWPA",
|
ret = os_snprintf(pos, end - pos, "%sWPA",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3372,7 +3372,7 @@ static int ctrl_iface_get_capability_auth_alg(int res, char *strict,
|
|||||||
if (capa->auth & (WPA_DRIVER_AUTH_OPEN)) {
|
if (capa->auth & (WPA_DRIVER_AUTH_OPEN)) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sOPEN",
|
ret = os_snprintf(pos, end - pos, "%sOPEN",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3380,7 +3380,7 @@ static int ctrl_iface_get_capability_auth_alg(int res, char *strict,
|
|||||||
if (capa->auth & (WPA_DRIVER_AUTH_SHARED)) {
|
if (capa->auth & (WPA_DRIVER_AUTH_SHARED)) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sSHARED",
|
ret = os_snprintf(pos, end - pos, "%sSHARED",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3388,7 +3388,7 @@ static int ctrl_iface_get_capability_auth_alg(int res, char *strict,
|
|||||||
if (capa->auth & (WPA_DRIVER_AUTH_LEAP)) {
|
if (capa->auth & (WPA_DRIVER_AUTH_LEAP)) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sLEAP",
|
ret = os_snprintf(pos, end - pos, "%sLEAP",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3420,7 +3420,7 @@ static int ctrl_iface_get_capability_modes(int res, char *strict,
|
|||||||
if (capa->flags & WPA_DRIVER_FLAGS_IBSS) {
|
if (capa->flags & WPA_DRIVER_FLAGS_IBSS) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sIBSS",
|
ret = os_snprintf(pos, end - pos, "%sIBSS",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3428,7 +3428,7 @@ static int ctrl_iface_get_capability_modes(int res, char *strict,
|
|||||||
if (capa->flags & WPA_DRIVER_FLAGS_AP) {
|
if (capa->flags & WPA_DRIVER_FLAGS_AP) {
|
||||||
ret = os_snprintf(pos, end - pos, "%sAP",
|
ret = os_snprintf(pos, end - pos, "%sAP",
|
||||||
pos == buf ? "" : " ");
|
pos == buf ? "" : " ");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3465,7 +3465,7 @@ static int ctrl_iface_get_capability_channels(struct wpa_supplicant *wpa_s,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ret = os_snprintf(pos, end - pos, "Mode[%s] Channels:", hmode);
|
ret = os_snprintf(pos, end - pos, "Mode[%s] Channels:", hmode);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
chnl = wpa_s->hw.modes[j].channels;
|
chnl = wpa_s->hw.modes[j].channels;
|
||||||
@ -3473,12 +3473,12 @@ static int ctrl_iface_get_capability_channels(struct wpa_supplicant *wpa_s,
|
|||||||
if (chnl[i].flag & HOSTAPD_CHAN_DISABLED)
|
if (chnl[i].flag & HOSTAPD_CHAN_DISABLED)
|
||||||
continue;
|
continue;
|
||||||
ret = os_snprintf(pos, end - pos, " %d", chnl[i].chan);
|
ret = os_snprintf(pos, end - pos, " %d", chnl[i].chan);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3516,7 +3516,7 @@ static int ctrl_iface_get_capability_freq(struct wpa_supplicant *wpa_s,
|
|||||||
}
|
}
|
||||||
ret = os_snprintf(pos, end - pos, "Mode[%s] Channels:\n",
|
ret = os_snprintf(pos, end - pos, "Mode[%s] Channels:\n",
|
||||||
hmode);
|
hmode);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
chnl = wpa_s->hw.modes[j].channels;
|
chnl = wpa_s->hw.modes[j].channels;
|
||||||
@ -3530,12 +3530,12 @@ static int ctrl_iface_get_capability_freq(struct wpa_supplicant *wpa_s,
|
|||||||
chnl[i].flag & HOSTAPD_CHAN_RADAR ?
|
chnl[i].flag & HOSTAPD_CHAN_RADAR ?
|
||||||
" (DFS)" : "");
|
" (DFS)" : "");
|
||||||
|
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3612,7 +3612,7 @@ static int wpa_supplicant_ctrl_iface_get_capability(
|
|||||||
#ifdef CONFIG_ERP
|
#ifdef CONFIG_ERP
|
||||||
if (os_strcmp(field, "erp") == 0) {
|
if (os_strcmp(field, "erp") == 0) {
|
||||||
res = os_snprintf(buf, buflen, "ERP");
|
res = os_snprintf(buf, buflen, "ERP");
|
||||||
if (res < 0 || (unsigned int) res >= buflen)
|
if (os_snprintf_error(buflen, res))
|
||||||
return -1;
|
return -1;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -3638,20 +3638,20 @@ static char * anqp_add_hex(char *pos, char *end, const char *title,
|
|||||||
return start;
|
return start;
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "%s=", title);
|
ret = os_snprintf(pos, end - pos, "%s=", title);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return start;
|
return start;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
d = wpabuf_head_u8(data);
|
d = wpabuf_head_u8(data);
|
||||||
for (i = 0; i < wpabuf_len(data); i++) {
|
for (i = 0; i < wpabuf_len(data); i++) {
|
||||||
ret = os_snprintf(pos, end - pos, "%02x", *d++);
|
ret = os_snprintf(pos, end - pos, "%02x", *d++);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return start;
|
return start;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return start;
|
return start;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -3673,7 +3673,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
|
|
||||||
if (mask & WPA_BSS_MASK_ID) {
|
if (mask & WPA_BSS_MASK_ID) {
|
||||||
ret = os_snprintf(pos, end - pos, "id=%u\n", bss->id);
|
ret = os_snprintf(pos, end - pos, "id=%u\n", bss->id);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3681,14 +3681,14 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
if (mask & WPA_BSS_MASK_BSSID) {
|
if (mask & WPA_BSS_MASK_BSSID) {
|
||||||
ret = os_snprintf(pos, end - pos, "bssid=" MACSTR "\n",
|
ret = os_snprintf(pos, end - pos, "bssid=" MACSTR "\n",
|
||||||
MAC2STR(bss->bssid));
|
MAC2STR(bss->bssid));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & WPA_BSS_MASK_FREQ) {
|
if (mask & WPA_BSS_MASK_FREQ) {
|
||||||
ret = os_snprintf(pos, end - pos, "freq=%d\n", bss->freq);
|
ret = os_snprintf(pos, end - pos, "freq=%d\n", bss->freq);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3696,7 +3696,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
if (mask & WPA_BSS_MASK_BEACON_INT) {
|
if (mask & WPA_BSS_MASK_BEACON_INT) {
|
||||||
ret = os_snprintf(pos, end - pos, "beacon_int=%d\n",
|
ret = os_snprintf(pos, end - pos, "beacon_int=%d\n",
|
||||||
bss->beacon_int);
|
bss->beacon_int);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3704,28 +3704,28 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
if (mask & WPA_BSS_MASK_CAPABILITIES) {
|
if (mask & WPA_BSS_MASK_CAPABILITIES) {
|
||||||
ret = os_snprintf(pos, end - pos, "capabilities=0x%04x\n",
|
ret = os_snprintf(pos, end - pos, "capabilities=0x%04x\n",
|
||||||
bss->caps);
|
bss->caps);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & WPA_BSS_MASK_QUAL) {
|
if (mask & WPA_BSS_MASK_QUAL) {
|
||||||
ret = os_snprintf(pos, end - pos, "qual=%d\n", bss->qual);
|
ret = os_snprintf(pos, end - pos, "qual=%d\n", bss->qual);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & WPA_BSS_MASK_NOISE) {
|
if (mask & WPA_BSS_MASK_NOISE) {
|
||||||
ret = os_snprintf(pos, end - pos, "noise=%d\n", bss->noise);
|
ret = os_snprintf(pos, end - pos, "noise=%d\n", bss->noise);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & WPA_BSS_MASK_LEVEL) {
|
if (mask & WPA_BSS_MASK_LEVEL) {
|
||||||
ret = os_snprintf(pos, end - pos, "level=%d\n", bss->level);
|
ret = os_snprintf(pos, end - pos, "level=%d\n", bss->level);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3733,7 +3733,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
if (mask & WPA_BSS_MASK_TSF) {
|
if (mask & WPA_BSS_MASK_TSF) {
|
||||||
ret = os_snprintf(pos, end - pos, "tsf=%016llu\n",
|
ret = os_snprintf(pos, end - pos, "tsf=%016llu\n",
|
||||||
(unsigned long long) bss->tsf);
|
(unsigned long long) bss->tsf);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3744,34 +3744,34 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
os_get_reltime(&now);
|
os_get_reltime(&now);
|
||||||
ret = os_snprintf(pos, end - pos, "age=%d\n",
|
ret = os_snprintf(pos, end - pos, "age=%d\n",
|
||||||
(int) (now.sec - bss->last_update.sec));
|
(int) (now.sec - bss->last_update.sec));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & WPA_BSS_MASK_IE) {
|
if (mask & WPA_BSS_MASK_IE) {
|
||||||
ret = os_snprintf(pos, end - pos, "ie=");
|
ret = os_snprintf(pos, end - pos, "ie=");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
ie = (const u8 *) (bss + 1);
|
ie = (const u8 *) (bss + 1);
|
||||||
for (i = 0; i < bss->ie_len; i++) {
|
for (i = 0; i < bss->ie_len; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, "%02x", *ie++);
|
ret = os_snprintf(pos, end - pos, "%02x", *ie++);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & WPA_BSS_MASK_FLAGS) {
|
if (mask & WPA_BSS_MASK_FLAGS) {
|
||||||
ret = os_snprintf(pos, end - pos, "flags=");
|
ret = os_snprintf(pos, end - pos, "flags=");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -3786,14 +3786,14 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
pos = wpa_supplicant_wps_ie_txt(wpa_s, pos, end, bss);
|
pos = wpa_supplicant_wps_ie_txt(wpa_s, pos, end, bss);
|
||||||
if (!ie && !ie2 && bss->caps & IEEE80211_CAP_PRIVACY) {
|
if (!ie && !ie2 && bss->caps & IEEE80211_CAP_PRIVACY) {
|
||||||
ret = os_snprintf(pos, end - pos, "[WEP]");
|
ret = os_snprintf(pos, end - pos, "[WEP]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (bss_is_dmg(bss)) {
|
if (bss_is_dmg(bss)) {
|
||||||
const char *s;
|
const char *s;
|
||||||
ret = os_snprintf(pos, end - pos, "[DMG]");
|
ret = os_snprintf(pos, end - pos, "[DMG]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
switch (bss->caps & IEEE80211_CAP_DMG_MASK) {
|
switch (bss->caps & IEEE80211_CAP_DMG_MASK) {
|
||||||
@ -3811,19 +3811,19 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = os_snprintf(pos, end - pos, "%s", s);
|
ret = os_snprintf(pos, end - pos, "%s", s);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
} else {
|
} else {
|
||||||
if (bss->caps & IEEE80211_CAP_IBSS) {
|
if (bss->caps & IEEE80211_CAP_IBSS) {
|
||||||
ret = os_snprintf(pos, end - pos, "[IBSS]");
|
ret = os_snprintf(pos, end - pos, "[IBSS]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
if (bss->caps & IEEE80211_CAP_ESS) {
|
if (bss->caps & IEEE80211_CAP_ESS) {
|
||||||
ret = os_snprintf(pos, end - pos, "[ESS]");
|
ret = os_snprintf(pos, end - pos, "[ESS]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3831,21 +3831,21 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
if (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) ||
|
if (wpa_bss_get_vendor_ie(bss, P2P_IE_VENDOR_TYPE) ||
|
||||||
wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) {
|
wpa_bss_get_vendor_ie_beacon(bss, P2P_IE_VENDOR_TYPE)) {
|
||||||
ret = os_snprintf(pos, end - pos, "[P2P]");
|
ret = os_snprintf(pos, end - pos, "[P2P]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_HS20
|
#ifdef CONFIG_HS20
|
||||||
if (wpa_bss_get_vendor_ie(bss, HS20_IE_VENDOR_TYPE)) {
|
if (wpa_bss_get_vendor_ie(bss, HS20_IE_VENDOR_TYPE)) {
|
||||||
ret = os_snprintf(pos, end - pos, "[HS20]");
|
ret = os_snprintf(pos, end - pos, "[HS20]");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_HS20 */
|
#endif /* CONFIG_HS20 */
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3853,7 +3853,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
if (mask & WPA_BSS_MASK_SSID) {
|
if (mask & WPA_BSS_MASK_SSID) {
|
||||||
ret = os_snprintf(pos, end - pos, "ssid=%s\n",
|
ret = os_snprintf(pos, end - pos, "ssid=%s\n",
|
||||||
wpa_ssid_txt(bss->ssid, bss->ssid_len));
|
wpa_ssid_txt(bss->ssid, bss->ssid_len));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3886,7 +3886,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
WFD_IE_VENDOR_TYPE);
|
WFD_IE_VENDOR_TYPE);
|
||||||
if (wfd) {
|
if (wfd) {
|
||||||
ret = os_snprintf(pos, end - pos, "wfd_subelems=");
|
ret = os_snprintf(pos, end - pos, "wfd_subelems=");
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
wpabuf_free(wfd);
|
wpabuf_free(wfd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3898,7 +3898,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
wpabuf_free(wfd);
|
wpabuf_free(wfd);
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -3948,7 +3948,7 @@ static int print_bss_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
|
|||||||
|
|
||||||
if (mask & WPA_BSS_MASK_DELIM) {
|
if (mask & WPA_BSS_MASK_DELIM) {
|
||||||
ret = os_snprintf(pos, end - pos, "====\n");
|
ret = os_snprintf(pos, end - pos, "====\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -4358,7 +4358,7 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
|
|||||||
return -1;
|
return -1;
|
||||||
if (wps_method == WPS_PIN_DISPLAY && pin == NULL) {
|
if (wps_method == WPS_PIN_DISPLAY && pin == NULL) {
|
||||||
ret = os_snprintf(buf, buflen, "%08d", new_pin);
|
ret = os_snprintf(buf, buflen, "%08d", new_pin);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return -1;
|
return -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -4473,7 +4473,7 @@ static int p2p_ctrl_serv_disc_req(struct wpa_supplicant *wpa_s, char *cmd,
|
|||||||
if (ref == 0)
|
if (ref == 0)
|
||||||
return -1;
|
return -1;
|
||||||
res = os_snprintf(buf, buflen, "%llx", (long long unsigned) ref);
|
res = os_snprintf(buf, buflen, "%llx", (long long unsigned) ref);
|
||||||
if (res < 0 || (unsigned) res >= buflen)
|
if (os_snprintf_error(buflen, res))
|
||||||
return -1;
|
return -1;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -4909,7 +4909,7 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd,
|
|||||||
info->dev_capab,
|
info->dev_capab,
|
||||||
info->group_capab,
|
info->group_capab,
|
||||||
info->level);
|
info->level);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
|
|
||||||
@ -4920,7 +4920,7 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd,
|
|||||||
res = os_snprintf(pos, end - pos, "sec_dev_type=%s\n",
|
res = os_snprintf(pos, end - pos, "sec_dev_type=%s\n",
|
||||||
wps_dev_type_bin2str(t, devtype,
|
wps_dev_type_bin2str(t, devtype,
|
||||||
sizeof(devtype)));
|
sizeof(devtype)));
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
@ -4928,7 +4928,7 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd,
|
|||||||
ssid = wpas_p2p_get_persistent(wpa_s, info->p2p_device_addr, NULL, 0);
|
ssid = wpas_p2p_get_persistent(wpa_s, info->p2p_device_addr, NULL, 0);
|
||||||
if (ssid) {
|
if (ssid) {
|
||||||
res = os_snprintf(pos, end - pos, "persistent=%d\n", ssid->id);
|
res = os_snprintf(pos, end - pos, "persistent=%d\n", ssid->id);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
@ -4940,7 +4940,7 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd,
|
|||||||
|
|
||||||
if (info->vendor_elems) {
|
if (info->vendor_elems) {
|
||||||
res = os_snprintf(pos, end - pos, "vendor_elems=");
|
res = os_snprintf(pos, end - pos, "vendor_elems=");
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
|
|
||||||
@ -4949,7 +4949,7 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd,
|
|||||||
wpabuf_len(info->vendor_elems));
|
wpabuf_len(info->vendor_elems));
|
||||||
|
|
||||||
res = os_snprintf(pos, end - pos, "\n");
|
res = os_snprintf(pos, end - pos, "\n");
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
@ -5804,7 +5804,7 @@ static int wpa_supplicant_signal_poll(struct wpa_supplicant *wpa_s, char *buf,
|
|||||||
if (si.avg_signal) {
|
if (si.avg_signal) {
|
||||||
ret = os_snprintf(pos, end - pos,
|
ret = os_snprintf(pos, end - pos,
|
||||||
"AVG_RSSI=%d\n", si.avg_signal);
|
"AVG_RSSI=%d\n", si.avg_signal);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return -1;
|
return -1;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -6023,7 +6023,7 @@ static int wpas_ctrl_radio_work_show(struct wpa_supplicant *wpa_s,
|
|||||||
ret = os_snprintf(pos, end - pos, "%s@%s:%u:%u:%ld.%06ld\n",
|
ret = os_snprintf(pos, end - pos, "%s@%s:%u:%u:%ld.%06ld\n",
|
||||||
work->type, work->wpa_s->ifname, work->freq,
|
work->type, work->wpa_s->ifname, work->freq,
|
||||||
work->started, diff.sec, diff.usec);
|
work->started, diff.sec, diff.usec);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
break;
|
break;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -6119,7 +6119,7 @@ static int wpas_ctrl_radio_work_add(struct wpa_supplicant *wpa_s, char *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(buf, buflen, "%u", ework->id);
|
ret = os_snprintf(buf, buflen, "%u", ework->id);
|
||||||
if (ret < 0 || (size_t) ret >= buflen)
|
if (os_snprintf_error(buflen, ret))
|
||||||
return -1;
|
return -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -7690,7 +7690,7 @@ static int wpa_supplicant_global_iface_list(struct wpa_global *global,
|
|||||||
res = os_snprintf(pos, end - pos, "%s\t%s\t%s\n",
|
res = os_snprintf(pos, end - pos, "%s\t%s\t%s\n",
|
||||||
tmp->drv_name, tmp->ifname,
|
tmp->drv_name, tmp->ifname,
|
||||||
tmp->desc ? tmp->desc : "");
|
tmp->desc ? tmp->desc : "");
|
||||||
if (res < 0 || res >= end - pos) {
|
if (os_snprintf_error(end - pos, res)) {
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -7716,7 +7716,7 @@ static int wpa_supplicant_global_iface_interfaces(struct wpa_global *global,
|
|||||||
|
|
||||||
while (wpa_s) {
|
while (wpa_s) {
|
||||||
res = os_snprintf(pos, end - pos, "%s\n", wpa_s->ifname);
|
res = os_snprintf(pos, end - pos, "%s\n", wpa_s->ifname);
|
||||||
if (res < 0 || res >= end - pos) {
|
if (os_snprintf_error(end - pos, res)) {
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -7931,12 +7931,12 @@ static int wpas_global_ctrl_iface_status(struct wpa_global *global,
|
|||||||
"p2p_state=%s\n",
|
"p2p_state=%s\n",
|
||||||
MAC2STR(global->p2p_dev_addr),
|
MAC2STR(global->p2p_dev_addr),
|
||||||
p2p_get_state_txt(global->p2p));
|
p2p_get_state_txt(global->p2p));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
} else if (global->p2p) {
|
} else if (global->p2p) {
|
||||||
ret = os_snprintf(pos, end - pos, "p2p_state=DISABLED\n");
|
ret = os_snprintf(pos, end - pos, "p2p_state=DISABLED\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -7945,7 +7945,7 @@ static int wpas_global_ctrl_iface_status(struct wpa_global *global,
|
|||||||
#ifdef CONFIG_WIFI_DISPLAY
|
#ifdef CONFIG_WIFI_DISPLAY
|
||||||
ret = os_snprintf(pos, end - pos, "wifi_display=%d\n",
|
ret = os_snprintf(pos, end - pos, "wifi_display=%d\n",
|
||||||
!!global->wifi_display);
|
!!global->wifi_display);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
#endif /* CONFIG_WIFI_DISPLAY */
|
#endif /* CONFIG_WIFI_DISPLAY */
|
||||||
@ -7954,7 +7954,7 @@ static int wpas_global_ctrl_iface_status(struct wpa_global *global,
|
|||||||
ret = os_snprintf(pos, end - pos, "ifname=%s\n"
|
ret = os_snprintf(pos, end - pos, "ifname=%s\n"
|
||||||
"address=" MACSTR "\n",
|
"address=" MACSTR "\n",
|
||||||
wpa_s->ifname, MAC2STR(wpa_s->own_addr));
|
wpa_s->ifname, MAC2STR(wpa_s->own_addr));
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ static char * wpa_supplicant_ctrl_iface_path(struct wpa_supplicant *wpa_s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = os_snprintf(buf, len, "%s/%s", dir, wpa_s->ifname);
|
res = os_snprintf(buf, len, "%s/%s", dir, wpa_s->ifname);
|
||||||
if (res < 0 || (size_t) res >= len) {
|
if (os_snprintf_error(len, res)) {
|
||||||
os_free(pbuf);
|
os_free(pbuf);
|
||||||
os_free(buf);
|
os_free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -671,7 +671,7 @@ static void wpa_supplicant_ctrl_iface_send(struct wpa_supplicant *wpa_s,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
res = os_snprintf(levelstr, sizeof(levelstr), "<%d>", level);
|
res = os_snprintf(levelstr, sizeof(levelstr), "<%d>", level);
|
||||||
if (res < 0 || (size_t) res >= sizeof(levelstr))
|
if (os_snprintf_error(sizeof(levelstr), res))
|
||||||
return;
|
return;
|
||||||
idx = 0;
|
idx = 0;
|
||||||
if (ifname) {
|
if (ifname) {
|
||||||
|
@ -136,7 +136,7 @@ static int is_signature_correct(DBusMessage *message,
|
|||||||
if (arg->dir == ARG_IN) {
|
if (arg->dir == ARG_IN) {
|
||||||
size_t blen = registered_sig + MAX_SIG_LEN - pos;
|
size_t blen = registered_sig + MAX_SIG_LEN - pos;
|
||||||
ret = os_snprintf(pos, blen, "%s", arg->type);
|
ret = os_snprintf(pos, blen, "%s", arg->type);
|
||||||
if (ret < 0 || (size_t) ret >= blen)
|
if (os_snprintf_error(blen, ret))
|
||||||
return 0;
|
return 0;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -461,7 +461,7 @@ static void eapol_test_eap_param_needed(void *ctx, enum wpa_ctrl_req_type field,
|
|||||||
len = os_snprintf(buf, buflen,
|
len = os_snprintf(buf, buflen,
|
||||||
WPA_CTRL_REQ "%s-%d:%s needed for SSID ",
|
WPA_CTRL_REQ "%s-%d:%s needed for SSID ",
|
||||||
field_name, ssid->id, txt);
|
field_name, ssid->id, txt);
|
||||||
if (len < 0 || (size_t) len >= buflen) {
|
if (os_snprintf_error(buflen, len)) {
|
||||||
os_free(buf);
|
os_free(buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -403,7 +403,7 @@ static int mesh_attr_text(const u8 *ies, size_t ies_len, char *buf, char *end)
|
|||||||
mesh_id[elems.mesh_id_len] = '\0';
|
mesh_id[elems.mesh_id_len] = '\0';
|
||||||
ret = os_snprintf(pos, end - pos, "mesh_id=%s\n", mesh_id);
|
ret = os_snprintf(pos, end - pos, "mesh_id=%s\n", mesh_id);
|
||||||
os_free(mesh_id);
|
os_free(mesh_id);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ static int mesh_attr_text(const u8 *ies, size_t ies_len, char *buf, char *end)
|
|||||||
elems.mesh_config[2], elems.mesh_config[3],
|
elems.mesh_config[2], elems.mesh_config[3],
|
||||||
elems.mesh_config[4], elems.mesh_config[5],
|
elems.mesh_config[4], elems.mesh_config[5],
|
||||||
elems.mesh_config[6]);
|
elems.mesh_config[6]);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
@ -446,20 +446,20 @@ static int mesh_attr_text(const u8 *ies, size_t ies_len, char *buf, char *end)
|
|||||||
if (bss_basic_rate_set_len > 0) {
|
if (bss_basic_rate_set_len > 0) {
|
||||||
ret = os_snprintf(pos, end - pos, "bss_basic_rate_set=%d",
|
ret = os_snprintf(pos, end - pos, "bss_basic_rate_set=%d",
|
||||||
bss_basic_rate_set[0]);
|
bss_basic_rate_set[0]);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
for (i = 1; i < bss_basic_rate_set_len; i++) {
|
for (i = 1; i < bss_basic_rate_set_len; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, " %d",
|
ret = os_snprintf(pos, end - pos, " %d",
|
||||||
bss_basic_rate_set[i]);
|
bss_basic_rate_set[i]);
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (ret < 0 || ret >= end - pos)
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ static int wpa_cli_open_connection(const char *ifname, int attach)
|
|||||||
return -1;
|
return -1;
|
||||||
res = os_snprintf(cfile, flen, "%s/%s", ctrl_iface_dir,
|
res = os_snprintf(cfile, flen, "%s/%s", ctrl_iface_dir,
|
||||||
ifname);
|
ifname);
|
||||||
if (res < 0 || res >= flen) {
|
if (os_snprintf_error(flen, res)) {
|
||||||
os_free(cfile);
|
os_free(cfile);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -448,13 +448,13 @@ static int write_cmd(char *buf, size_t buflen, const char *cmd, int argc,
|
|||||||
end = buf + buflen;
|
end = buf + buflen;
|
||||||
|
|
||||||
res = os_snprintf(pos, end - pos, "%s", cmd);
|
res = os_snprintf(pos, end - pos, "%s", cmd);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
goto fail;
|
goto fail;
|
||||||
pos += res;
|
pos += res;
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
res = os_snprintf(pos, end - pos, " %s", argv[i]);
|
res = os_snprintf(pos, end - pos, " %s", argv[i]);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
goto fail;
|
goto fail;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
@ -1085,14 +1085,14 @@ static int wpa_cli_cmd_identity(struct wpa_ctrl *ctrl, int argc, char *argv[])
|
|||||||
pos = cmd;
|
pos = cmd;
|
||||||
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "IDENTITY-%s:%s",
|
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "IDENTITY-%s:%s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long IDENTITY command.\n");
|
printf("Too long IDENTITY command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pos += ret;
|
pos += ret;
|
||||||
for (i = 2; i < argc; i++) {
|
for (i = 2; i < argc; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long IDENTITY command.\n");
|
printf("Too long IDENTITY command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1118,14 +1118,14 @@ static int wpa_cli_cmd_password(struct wpa_ctrl *ctrl, int argc, char *argv[])
|
|||||||
pos = cmd;
|
pos = cmd;
|
||||||
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "PASSWORD-%s:%s",
|
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "PASSWORD-%s:%s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long PASSWORD command.\n");
|
printf("Too long PASSWORD command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pos += ret;
|
pos += ret;
|
||||||
for (i = 2; i < argc; i++) {
|
for (i = 2; i < argc; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long PASSWORD command.\n");
|
printf("Too long PASSWORD command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1152,14 +1152,14 @@ static int wpa_cli_cmd_new_password(struct wpa_ctrl *ctrl, int argc,
|
|||||||
pos = cmd;
|
pos = cmd;
|
||||||
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "NEW_PASSWORD-%s:%s",
|
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "NEW_PASSWORD-%s:%s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long NEW_PASSWORD command.\n");
|
printf("Too long NEW_PASSWORD command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pos += ret;
|
pos += ret;
|
||||||
for (i = 2; i < argc; i++) {
|
for (i = 2; i < argc; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long NEW_PASSWORD command.\n");
|
printf("Too long NEW_PASSWORD command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1185,14 +1185,14 @@ static int wpa_cli_cmd_pin(struct wpa_ctrl *ctrl, int argc, char *argv[])
|
|||||||
pos = cmd;
|
pos = cmd;
|
||||||
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "PIN-%s:%s",
|
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "PIN-%s:%s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long PIN command.\n");
|
printf("Too long PIN command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pos += ret;
|
pos += ret;
|
||||||
for (i = 2; i < argc; i++) {
|
for (i = 2; i < argc; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long PIN command.\n");
|
printf("Too long PIN command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1217,14 +1217,14 @@ static int wpa_cli_cmd_otp(struct wpa_ctrl *ctrl, int argc, char *argv[])
|
|||||||
pos = cmd;
|
pos = cmd;
|
||||||
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "OTP-%s:%s",
|
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "OTP-%s:%s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long OTP command.\n");
|
printf("Too long OTP command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pos += ret;
|
pos += ret;
|
||||||
for (i = 2; i < argc; i++) {
|
for (i = 2; i < argc; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long OTP command.\n");
|
printf("Too long OTP command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1250,14 +1250,14 @@ static int wpa_cli_cmd_sim(struct wpa_ctrl *ctrl, int argc, char *argv[])
|
|||||||
pos = cmd;
|
pos = cmd;
|
||||||
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "SIM-%s:%s",
|
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "SIM-%s:%s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long SIM command.\n");
|
printf("Too long SIM command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pos += ret;
|
pos += ret;
|
||||||
for (i = 2; i < argc; i++) {
|
for (i = 2; i < argc; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long SIM command.\n");
|
printf("Too long SIM command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1283,14 +1283,14 @@ static int wpa_cli_cmd_passphrase(struct wpa_ctrl *ctrl, int argc,
|
|||||||
pos = cmd;
|
pos = cmd;
|
||||||
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "PASSPHRASE-%s:%s",
|
ret = os_snprintf(pos, end - pos, WPA_CTRL_RSP "PASSPHRASE-%s:%s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long PASSPHRASE command.\n");
|
printf("Too long PASSPHRASE command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pos += ret;
|
pos += ret;
|
||||||
for (i = 2; i < argc; i++) {
|
for (i = 2; i < argc; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
ret = os_snprintf(pos, end - pos, " %s", argv[i]);
|
||||||
if (ret < 0 || ret >= end - pos) {
|
if (os_snprintf_error(end - pos, ret)) {
|
||||||
printf("Too long PASSPHRASE command.\n");
|
printf("Too long PASSPHRASE command.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1626,7 +1626,7 @@ static int wpa_cli_cmd_interface_add(struct wpa_ctrl *ctrl, int argc,
|
|||||||
argc > 1 ? argv[1] : "", argc > 2 ? argv[2] : "",
|
argc > 1 ? argv[1] : "", argc > 2 ? argv[2] : "",
|
||||||
argc > 3 ? argv[3] : "", argc > 4 ? argv[4] : "",
|
argc > 3 ? argv[3] : "", argc > 4 ? argv[4] : "",
|
||||||
argc > 5 ? argv[5] : "");
|
argc > 5 ? argv[5] : "");
|
||||||
if (res < 0 || (size_t) res >= sizeof(cmd))
|
if (os_snprintf_error(sizeof(cmd), res))
|
||||||
return -1;
|
return -1;
|
||||||
cmd[sizeof(cmd) - 1] = '\0';
|
cmd[sizeof(cmd) - 1] = '\0';
|
||||||
return wpa_ctrl_command(ctrl, cmd);
|
return wpa_ctrl_command(ctrl, cmd);
|
||||||
@ -1933,7 +1933,7 @@ static int wpa_cli_cmd_p2p_serv_disc_resp(struct wpa_ctrl *ctrl, int argc,
|
|||||||
|
|
||||||
res = os_snprintf(cmd, sizeof(cmd), "P2P_SERV_DISC_RESP %s %s %s %s",
|
res = os_snprintf(cmd, sizeof(cmd), "P2P_SERV_DISC_RESP %s %s %s %s",
|
||||||
argv[0], argv[1], argv[2], argv[3]);
|
argv[0], argv[1], argv[2], argv[3]);
|
||||||
if (res < 0 || (size_t) res >= sizeof(cmd))
|
if (os_snprintf_error(sizeof(cmd), res))
|
||||||
return -1;
|
return -1;
|
||||||
cmd[sizeof(cmd) - 1] = '\0';
|
cmd[sizeof(cmd) - 1] = '\0';
|
||||||
return wpa_ctrl_command(ctrl, cmd);
|
return wpa_ctrl_command(ctrl, cmd);
|
||||||
@ -1981,7 +1981,7 @@ static int wpa_cli_cmd_p2p_service_add(struct wpa_ctrl *ctrl, int argc,
|
|||||||
res = os_snprintf(cmd, sizeof(cmd),
|
res = os_snprintf(cmd, sizeof(cmd),
|
||||||
"P2P_SERVICE_ADD %s %s %s",
|
"P2P_SERVICE_ADD %s %s %s",
|
||||||
argv[0], argv[1], argv[2]);
|
argv[0], argv[1], argv[2]);
|
||||||
if (res < 0 || (size_t) res >= sizeof(cmd))
|
if (os_snprintf_error(sizeof(cmd), res))
|
||||||
return -1;
|
return -1;
|
||||||
cmd[sizeof(cmd) - 1] = '\0';
|
cmd[sizeof(cmd) - 1] = '\0';
|
||||||
return wpa_ctrl_command(ctrl, cmd);
|
return wpa_ctrl_command(ctrl, cmd);
|
||||||
@ -2008,7 +2008,7 @@ static int wpa_cli_cmd_p2p_service_del(struct wpa_ctrl *ctrl, int argc,
|
|||||||
res = os_snprintf(cmd, sizeof(cmd),
|
res = os_snprintf(cmd, sizeof(cmd),
|
||||||
"P2P_SERVICE_DEL %s %s",
|
"P2P_SERVICE_DEL %s %s",
|
||||||
argv[0], argv[1]);
|
argv[0], argv[1]);
|
||||||
if (res < 0 || (size_t) res >= sizeof(cmd))
|
if (os_snprintf_error(sizeof(cmd), res))
|
||||||
return -1;
|
return -1;
|
||||||
cmd[sizeof(cmd) - 1] = '\0';
|
cmd[sizeof(cmd) - 1] = '\0';
|
||||||
return wpa_ctrl_command(ctrl, cmd);
|
return wpa_ctrl_command(ctrl, cmd);
|
||||||
@ -2230,7 +2230,7 @@ static int wpa_cli_cmd_wfd_subelem_set(struct wpa_ctrl *ctrl, int argc,
|
|||||||
|
|
||||||
res = os_snprintf(cmd, sizeof(cmd), "WFD_SUBELEM_SET %s %s",
|
res = os_snprintf(cmd, sizeof(cmd), "WFD_SUBELEM_SET %s %s",
|
||||||
argv[0], argc > 1 ? argv[1] : "");
|
argv[0], argc > 1 ? argv[1] : "");
|
||||||
if (res < 0 || (size_t) res >= sizeof(cmd))
|
if (os_snprintf_error(sizeof(cmd), res))
|
||||||
return -1;
|
return -1;
|
||||||
cmd[sizeof(cmd) - 1] = '\0';
|
cmd[sizeof(cmd) - 1] = '\0';
|
||||||
return wpa_ctrl_command(ctrl, cmd);
|
return wpa_ctrl_command(ctrl, cmd);
|
||||||
@ -2251,7 +2251,7 @@ static int wpa_cli_cmd_wfd_subelem_get(struct wpa_ctrl *ctrl, int argc,
|
|||||||
|
|
||||||
res = os_snprintf(cmd, sizeof(cmd), "WFD_SUBELEM_GET %s",
|
res = os_snprintf(cmd, sizeof(cmd), "WFD_SUBELEM_GET %s",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
if (res < 0 || (size_t) res >= sizeof(cmd))
|
if (os_snprintf_error(sizeof(cmd), res))
|
||||||
return -1;
|
return -1;
|
||||||
cmd[sizeof(cmd) - 1] = '\0';
|
cmd[sizeof(cmd) - 1] = '\0';
|
||||||
return wpa_ctrl_command(ctrl, cmd);
|
return wpa_ctrl_command(ctrl, cmd);
|
||||||
|
@ -800,7 +800,7 @@ static void wpa_supplicant_eap_param_needed(void *ctx,
|
|||||||
len = os_snprintf(buf, buflen,
|
len = os_snprintf(buf, buflen,
|
||||||
WPA_CTRL_REQ "%s-%d:%s needed for SSID ",
|
WPA_CTRL_REQ "%s-%d:%s needed for SSID ",
|
||||||
field_name, ssid->id, txt);
|
field_name, ssid->id, txt);
|
||||||
if (len < 0 || (size_t) len >= buflen) {
|
if (os_snprintf_error(buflen, len)) {
|
||||||
os_free(buf);
|
os_free(buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1254,7 +1254,7 @@ int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
|||||||
pos = val;
|
pos = val;
|
||||||
end = pos + sizeof(val);
|
end = pos + sizeof(val);
|
||||||
res = os_snprintf(pos, end - pos, "\"pin=%s", pin);
|
res = os_snprintf(pos, end - pos, "\"pin=%s", pin);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return -1;
|
return -1;
|
||||||
pos += res;
|
pos += res;
|
||||||
if (settings) {
|
if (settings) {
|
||||||
@ -1262,12 +1262,12 @@ int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
|||||||
"new_encr=%s new_key=%s",
|
"new_encr=%s new_key=%s",
|
||||||
settings->ssid_hex, settings->auth,
|
settings->ssid_hex, settings->auth,
|
||||||
settings->encr, settings->key_hex);
|
settings->encr, settings->key_hex);
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return -1;
|
return -1;
|
||||||
pos += res;
|
pos += res;
|
||||||
}
|
}
|
||||||
res = os_snprintf(pos, end - pos, "\"");
|
res = os_snprintf(pos, end - pos, "\"");
|
||||||
if (res < 0 || res >= end - pos)
|
if (os_snprintf_error(end - pos, res))
|
||||||
return -1;
|
return -1;
|
||||||
if (wpa_config_set(ssid, "phase1", val, 0) < 0)
|
if (wpa_config_set(ssid, "phase1", val, 0) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user