aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2009-02-06 12:15:47 (GMT)
committerJouni Malinen <j@w1.fi>2009-02-08 10:36:33 (GMT)
commit3f25b3c602364cf75e0dd426e80b422b36eeb40f (patch)
treeef1240e2fbfd8e66cae83400241678c18d757042 /src
parent393d5fcf6eb597bb94ecb86e6acb652093edcbe9 (diff)
downloadhostap-06-3f25b3c602364cf75e0dd426e80b422b36eeb40f.zip
hostap-06-3f25b3c602364cf75e0dd426e80b422b36eeb40f.tar.gz
hostap-06-3f25b3c602364cf75e0dd426e80b422b36eeb40f.tar.bz2
WPS: Moved Version attribute validation into a shared function
(cherry picked from commit f65cbff3a337888cd11a6fc1748709172c98b744)
Diffstat (limited to 'src')
-rw-r--r--src/wps/wps_enrollee.c6
-rw-r--r--src/wps/wps_i.h6
-rw-r--r--src/wps/wps_registrar.c18
3 files changed, 19 insertions, 11 deletions
diff --git a/src/wps/wps_enrollee.c b/src/wps/wps_enrollee.c
index 6b6bc27..179f7db 100644
--- a/src/wps/wps_enrollee.c
+++ b/src/wps/wps_enrollee.c
@@ -956,7 +956,7 @@ static enum wps_process_res wps_process_wsc_msg(struct wps_data *wps,
if (wps_parse_msg(msg, &attr) < 0)
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",
attr.version ? *attr.version : 0);
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)
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",
attr.version ? *attr.version : 0);
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)
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",
attr.version ? *attr.version : 0);
return WPS_FAILURE;
diff --git a/src/wps/wps_i.h b/src/wps/wps_i.h
index b32a68f..b5b1232 100644
--- a/src/wps/wps_i.h
+++ b/src/wps/wps_i.h
@@ -238,4 +238,10 @@ enum wps_process_res wps_registrar_process_msg(struct wps_data *wps,
enum wsc_op_code op_code,
const struct wpabuf *msg);
+
+static inline int wps_version_supported(const u8 *version)
+{
+ return version && *version == WPS_VERSION;
+}
+
#endif /* WPS_I_H */
diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c
index 0fcc9ac..de76a00 100644
--- a/src/wps/wps_registrar.c
+++ b/src/wps/wps_registrar.c
@@ -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_data);
- if (wps_parse_msg(wps_data, &attr) < 0 ||
- attr.version == NULL || *attr.version != WPS_VERSION) {
+ if (wps_parse_msg(wps_data, &attr) < 0)
+ return;
+ if (!wps_version_supported(attr.version)) {
wpa_printf(MSG_DEBUG, "WPS: Unsupported ProbeReq WPS IE "
"version 0x%x", attr.version ? *attr.version : 0);
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)
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",
attr.version ? *attr.version : 0);
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)
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",
attr.version ? *attr.version : 0);
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)
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",
attr.version ? *attr.version : 0);
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)
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",
attr.version ? *attr.version : 0);
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",
msg);
- if (wps_parse_msg(msg, &attr) < 0 ||
- attr.version == NULL || *attr.version != WPS_VERSION) {
+ if (wps_parse_msg(msg, &attr) < 0)
+ return -1;
+ if (!wps_version_supported(attr.version)) {
wpa_printf(MSG_DEBUG, "WPS: Unsupported SetSelectedRegistrar "
"version 0x%x", attr.version ? *attr.version : 0);
return -1;