diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c index c4d7194a3..69434c8c9 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -185,7 +185,7 @@ static void hostapd_wps_pin_needed_cb(void *ctx, const u8 *uuid_e, dev->model_number, dev->serial_number, wps_dev_type_bin2str(dev->pri_dev_type, 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); if (hapd->conf->wps_pin_requests) { diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index ab5208ee0..1faf3fd7c 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -1015,7 +1015,7 @@ static void send_scan_event(struct wpa_driver_nl80211_data *drv, int aborted, freqs[num_freqs] = nla_get_u32(nl); res = os_snprintf(pos, end - pos, " %d", freqs[num_freqs]); - if (res > 0 && end - pos > res) + if (!os_snprintf_error(end - pos, res)) pos += res; num_freqs++; if (num_freqs == MAX_REPORT_FREQS - 1) diff --git a/src/eap_server/eap_server_ttls.c b/src/eap_server/eap_server_ttls.c index 7f662d9db..12a31b07a 100644 --- a/src/eap_server/eap_server_ttls.c +++ b/src/eap_server/eap_server_ttls.c @@ -409,7 +409,7 @@ static struct wpabuf * eap_ttls_build_phase2_mschapv2( RADIUS_VENDOR_ID_MICROSOFT, 1, 43); *pos++ = data->mschapv2_ident; ret = os_snprintf((char *) pos, end - pos, "S="); - if (ret >= 0 && ret < end - pos) + if (!os_snprintf_error(end - pos, ret)) pos += ret; pos += wpa_snprintf_hex_uppercase( (char *) pos, end - pos, data->mschapv2_auth_response, diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 5ebc1a8fd..91550c747 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -1310,7 +1310,7 @@ static int wpa_config_parse_wep_key(u8 *key, size_t *len, int line, os_memcpy(key, buf, *len); str_clear_free(buf); 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); return 0; } diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index a70d2b538..f1b1e5eb3 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2260,7 +2260,7 @@ static char * wpa_supplicant_wps_ie_txt_buf(struct wpa_supplicant *wpa_s, txt = "[WPS]"; ret = os_snprintf(pos, end - pos, "%s", txt); - if (ret >= 0 && ret < end - pos) + if (!os_snprintf_error(end - pos, ret)) pos += ret; wpabuf_free(wps_ie); return pos; diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index 778adf9ce..ee65e1098 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -3681,7 +3681,7 @@ static void update_ifnames(struct wpa_ctrl *ctrl) break; *end = '\0'; 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); pos = end + 1; } diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index d934b1adf..94064df0a 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -1318,7 +1318,7 @@ static void wpas_wps_pin_needed_cb(void *ctx, const u8 *uuid_e, dev->model_number, dev->serial_number, wps_dev_type_bin2str(dev->pri_dev_type, devtype, sizeof(devtype))); - if (len > 0 && len < (int) sizeof(txt)) + if (!os_snprintf_error(sizeof(txt), len)) wpa_printf(MSG_INFO, "%s", txt); }