Check os_snprintf() result more consistently - success case
This converts os_snprintf() result validation cases to use os_snprintf_error() in cases where success condition was used to execute a step. These changes were done automatically with spatch using the following semantic patch: @@ expression E1,E2,E3; statement S1; @@ E1 = os_snprintf(E2, E3, ...); - if (\( E1 >= 0 \| E1 > 0 \) && \( (size_t) E1 < E3 \| E1 < (int) E3 \| E1 < E3 \)) + if (!os_snprintf_error(E3, E1)) S1 Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
a9aaacbb50
commit
a80ba67a26
7 changed files with 7 additions and 7 deletions
|
@ -185,7 +185,7 @@ static void hostapd_wps_pin_needed_cb(void *ctx, const u8 *uuid_e,
|
||||||
dev->model_number, dev->serial_number,
|
dev->model_number, dev->serial_number,
|
||||||
wps_dev_type_bin2str(dev->pri_dev_type, devtype,
|
wps_dev_type_bin2str(dev->pri_dev_type, devtype,
|
||||||
sizeof(devtype)));
|
sizeof(devtype)));
|
||||||
if (len > 0 && len < (int) sizeof(txt))
|
if (!os_snprintf_error(sizeof(txt), len))
|
||||||
wpa_msg(hapd->msg_ctx, MSG_INFO, "%s", txt);
|
wpa_msg(hapd->msg_ctx, MSG_INFO, "%s", txt);
|
||||||
|
|
||||||
if (hapd->conf->wps_pin_requests) {
|
if (hapd->conf->wps_pin_requests) {
|
||||||
|
|
|
@ -1015,7 +1015,7 @@ static void send_scan_event(struct wpa_driver_nl80211_data *drv, int aborted,
|
||||||
freqs[num_freqs] = nla_get_u32(nl);
|
freqs[num_freqs] = nla_get_u32(nl);
|
||||||
res = os_snprintf(pos, end - pos, " %d",
|
res = os_snprintf(pos, end - pos, " %d",
|
||||||
freqs[num_freqs]);
|
freqs[num_freqs]);
|
||||||
if (res > 0 && end - pos > res)
|
if (!os_snprintf_error(end - pos, res))
|
||||||
pos += res;
|
pos += res;
|
||||||
num_freqs++;
|
num_freqs++;
|
||||||
if (num_freqs == MAX_REPORT_FREQS - 1)
|
if (num_freqs == MAX_REPORT_FREQS - 1)
|
||||||
|
|
|
@ -409,7 +409,7 @@ static struct wpabuf * eap_ttls_build_phase2_mschapv2(
|
||||||
RADIUS_VENDOR_ID_MICROSOFT, 1, 43);
|
RADIUS_VENDOR_ID_MICROSOFT, 1, 43);
|
||||||
*pos++ = data->mschapv2_ident;
|
*pos++ = data->mschapv2_ident;
|
||||||
ret = os_snprintf((char *) pos, end - pos, "S=");
|
ret = os_snprintf((char *) pos, end - pos, "S=");
|
||||||
if (ret >= 0 && ret < end - pos)
|
if (!os_snprintf_error(end - pos, ret))
|
||||||
pos += ret;
|
pos += ret;
|
||||||
pos += wpa_snprintf_hex_uppercase(
|
pos += wpa_snprintf_hex_uppercase(
|
||||||
(char *) pos, end - pos, data->mschapv2_auth_response,
|
(char *) pos, end - pos, data->mschapv2_auth_response,
|
||||||
|
|
|
@ -1310,7 +1310,7 @@ static int wpa_config_parse_wep_key(u8 *key, size_t *len, int line,
|
||||||
os_memcpy(key, buf, *len);
|
os_memcpy(key, buf, *len);
|
||||||
str_clear_free(buf);
|
str_clear_free(buf);
|
||||||
res = os_snprintf(title, sizeof(title), "wep_key%d", idx);
|
res = os_snprintf(title, sizeof(title), "wep_key%d", idx);
|
||||||
if (res >= 0 && (size_t) res < sizeof(title))
|
if (!os_snprintf_error(sizeof(title), res))
|
||||||
wpa_hexdump_key(MSG_MSGDUMP, title, key, *len);
|
wpa_hexdump_key(MSG_MSGDUMP, title, key, *len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2260,7 +2260,7 @@ static char * wpa_supplicant_wps_ie_txt_buf(struct wpa_supplicant *wpa_s,
|
||||||
txt = "[WPS]";
|
txt = "[WPS]";
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "%s", txt);
|
ret = os_snprintf(pos, end - pos, "%s", txt);
|
||||||
if (ret >= 0 && ret < end - pos)
|
if (!os_snprintf_error(end - pos, ret))
|
||||||
pos += ret;
|
pos += ret;
|
||||||
wpabuf_free(wps_ie);
|
wpabuf_free(wps_ie);
|
||||||
return pos;
|
return pos;
|
||||||
|
|
|
@ -3681,7 +3681,7 @@ static void update_ifnames(struct wpa_ctrl *ctrl)
|
||||||
break;
|
break;
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
ret = os_snprintf(txt, sizeof(txt), "ifname=%s", pos);
|
ret = os_snprintf(txt, sizeof(txt), "ifname=%s", pos);
|
||||||
if (ret > 0 && ret < (int) sizeof(txt))
|
if (!os_snprintf_error(sizeof(txt), ret))
|
||||||
cli_txt_list_add(&ifnames, txt);
|
cli_txt_list_add(&ifnames, txt);
|
||||||
pos = end + 1;
|
pos = end + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1318,7 +1318,7 @@ static void wpas_wps_pin_needed_cb(void *ctx, const u8 *uuid_e,
|
||||||
dev->model_number, dev->serial_number,
|
dev->model_number, dev->serial_number,
|
||||||
wps_dev_type_bin2str(dev->pri_dev_type, devtype,
|
wps_dev_type_bin2str(dev->pri_dev_type, devtype,
|
||||||
sizeof(devtype)));
|
sizeof(devtype)));
|
||||||
if (len > 0 && len < (int) sizeof(txt))
|
if (!os_snprintf_error(sizeof(txt), len))
|
||||||
wpa_printf(MSG_INFO, "%s", txt);
|
wpa_printf(MSG_INFO, "%s", txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue