mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 16:58:41 -05:00
WPS: Moved Version attribute validation into a shared function
This commit is contained in:
parent
fda90ab4b7
commit
f65cbff3a3
@ -956,7 +956,7 @@ static enum wps_process_res wps_process_wsc_msg(struct wps_data *wps,
|
|||||||
if (wps_parse_msg(msg, &attr) < 0)
|
if (wps_parse_msg(msg, &attr) < 0)
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
|
|
||||||
if (attr.version == NULL || *attr.version != WPS_VERSION) {
|
if (!wps_version_supported(attr.version)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
||||||
attr.version ? *attr.version : 0);
|
attr.version ? *attr.version : 0);
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
@ -1029,7 +1029,7 @@ static enum wps_process_res wps_process_wsc_ack(struct wps_data *wps,
|
|||||||
if (wps_parse_msg(msg, &attr) < 0)
|
if (wps_parse_msg(msg, &attr) < 0)
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
|
|
||||||
if (attr.version == NULL || *attr.version != WPS_VERSION) {
|
if (!wps_version_supported(attr.version)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
||||||
attr.version ? *attr.version : 0);
|
attr.version ? *attr.version : 0);
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
@ -1081,7 +1081,7 @@ static enum wps_process_res wps_process_wsc_nack(struct wps_data *wps,
|
|||||||
if (wps_parse_msg(msg, &attr) < 0)
|
if (wps_parse_msg(msg, &attr) < 0)
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
|
|
||||||
if (attr.version == NULL || *attr.version != WPS_VERSION) {
|
if (!wps_version_supported(attr.version)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
||||||
attr.version ? *attr.version : 0);
|
attr.version ? *attr.version : 0);
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
|
@ -238,4 +238,10 @@ enum wps_process_res wps_registrar_process_msg(struct wps_data *wps,
|
|||||||
enum wsc_op_code op_code,
|
enum wsc_op_code op_code,
|
||||||
const struct wpabuf *msg);
|
const struct wpabuf *msg);
|
||||||
|
|
||||||
|
|
||||||
|
static inline int wps_version_supported(const u8 *version)
|
||||||
|
{
|
||||||
|
return version && *version == WPS_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* WPS_I_H */
|
#endif /* WPS_I_H */
|
||||||
|
@ -602,8 +602,9 @@ void wps_registrar_probe_req_rx(struct wps_registrar *reg, const u8 *addr,
|
|||||||
"WPS: Probe Request with WPS data received",
|
"WPS: Probe Request with WPS data received",
|
||||||
wps_data);
|
wps_data);
|
||||||
|
|
||||||
if (wps_parse_msg(wps_data, &attr) < 0 ||
|
if (wps_parse_msg(wps_data, &attr) < 0)
|
||||||
attr.version == NULL || *attr.version != WPS_VERSION) {
|
return;
|
||||||
|
if (!wps_version_supported(attr.version)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Unsupported ProbeReq WPS IE "
|
wpa_printf(MSG_DEBUG, "WPS: Unsupported ProbeReq WPS IE "
|
||||||
"version 0x%x", attr.version ? *attr.version : 0);
|
"version 0x%x", attr.version ? *attr.version : 0);
|
||||||
return;
|
return;
|
||||||
@ -1933,7 +1934,7 @@ static enum wps_process_res wps_process_wsc_msg(struct wps_data *wps,
|
|||||||
if (wps_parse_msg(msg, &attr) < 0)
|
if (wps_parse_msg(msg, &attr) < 0)
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
|
|
||||||
if (attr.version == NULL || *attr.version != WPS_VERSION) {
|
if (!wps_version_supported(attr.version)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
||||||
attr.version ? *attr.version : 0);
|
attr.version ? *attr.version : 0);
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
@ -2009,7 +2010,7 @@ static enum wps_process_res wps_process_wsc_ack(struct wps_data *wps,
|
|||||||
if (wps_parse_msg(msg, &attr) < 0)
|
if (wps_parse_msg(msg, &attr) < 0)
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
|
|
||||||
if (attr.version == NULL || *attr.version != WPS_VERSION) {
|
if (!wps_version_supported(attr.version)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
||||||
attr.version ? *attr.version : 0);
|
attr.version ? *attr.version : 0);
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
@ -2084,7 +2085,7 @@ static enum wps_process_res wps_process_wsc_nack(struct wps_data *wps,
|
|||||||
if (wps_parse_msg(msg, &attr) < 0)
|
if (wps_parse_msg(msg, &attr) < 0)
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
|
|
||||||
if (attr.version == NULL || *attr.version != WPS_VERSION) {
|
if (!wps_version_supported(attr.version)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
||||||
attr.version ? *attr.version : 0);
|
attr.version ? *attr.version : 0);
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
@ -2169,7 +2170,7 @@ static enum wps_process_res wps_process_wsc_done(struct wps_data *wps,
|
|||||||
if (wps_parse_msg(msg, &attr) < 0)
|
if (wps_parse_msg(msg, &attr) < 0)
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
|
|
||||||
if (attr.version == NULL || *attr.version != WPS_VERSION) {
|
if (!wps_version_supported(attr.version)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
wpa_printf(MSG_DEBUG, "WPS: Unsupported message version 0x%x",
|
||||||
attr.version ? *attr.version : 0);
|
attr.version ? *attr.version : 0);
|
||||||
return WPS_FAILURE;
|
return WPS_FAILURE;
|
||||||
@ -2360,8 +2361,9 @@ int wps_registrar_set_selected_registrar(struct wps_registrar *reg,
|
|||||||
wpa_hexdump_buf(MSG_MSGDUMP, "WPS: SetSelectedRegistrar attributes",
|
wpa_hexdump_buf(MSG_MSGDUMP, "WPS: SetSelectedRegistrar attributes",
|
||||||
msg);
|
msg);
|
||||||
|
|
||||||
if (wps_parse_msg(msg, &attr) < 0 ||
|
if (wps_parse_msg(msg, &attr) < 0)
|
||||||
attr.version == NULL || *attr.version != WPS_VERSION) {
|
return -1;
|
||||||
|
if (!wps_version_supported(attr.version)) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: Unsupported SetSelectedRegistrar "
|
wpa_printf(MSG_DEBUG, "WPS: Unsupported SetSelectedRegistrar "
|
||||||
"version 0x%x", attr.version ? *attr.version : 0);
|
"version 0x%x", attr.version ? *attr.version : 0);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user