diff options
author | Jean-Michel Bachot <jean-michelx.bachot@linux.intel.com> | 2011-03-19 12:16:20 +0200 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2011-03-19 12:22:21 +0200 |
commit | 6f2c0607112354744cec693968f1bb689ffb070f (patch) | |
tree | edfb0bee02bf4a1898d4bfb2e8e40e0ff7e745b6 /src/wps | |
parent | f95cac271b06ed2ad15cfe7b4d6caad5b8ba2ad2 (diff) | |
download | external_wpa_supplicant_8_ti-6f2c0607112354744cec693968f1bb689ffb070f.zip external_wpa_supplicant_8_ti-6f2c0607112354744cec693968f1bb689ffb070f.tar.gz external_wpa_supplicant_8_ti-6f2c0607112354744cec693968f1bb689ffb070f.tar.bz2 |
P2P: Keep track of peer WPS vendor extensions
Make the P2P code keep track of WPS vendor extensions received from
peers so they can be exposed via DBus later.
Signed-off-by: Jean-Michel Bachot <jean-michelx.bachot@linux.intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'src/wps')
-rw-r--r-- | src/wps/wps.h | 4 | ||||
-rw-r--r-- | src/wps/wps_attr_parse.c | 25 | ||||
-rw-r--r-- | src/wps/wps_i.h | 4 |
3 files changed, 29 insertions, 4 deletions
diff --git a/src/wps/wps.h b/src/wps/wps.h index 8b29982..fc706d9 100644 --- a/src/wps/wps.h +++ b/src/wps/wps.h @@ -66,6 +66,10 @@ struct wps_credential { #define WPS_SEC_DEV_TYPE_MAX_LEN 128 /* maximum number of advertised WPS vendor extension attributes */ #define MAX_WPS_VENDOR_EXTENSIONS 10 +/* maximum size of WPS Vendor extension attribute */ +#define WPS_MAX_VENDOR_EXT_LEN 1024 +/* maximum number of parsed WPS vendor extension attributes */ +#define MAX_WPS_PARSE_VENDOR_EXT 10 /** * struct wps_device_data - WPS Device Data diff --git a/src/wps/wps_attr_parse.c b/src/wps/wps_attr_parse.c index 0c4a4b4..bc3766c 100644 --- a/src/wps/wps_attr_parse.c +++ b/src/wps/wps_attr_parse.c @@ -108,12 +108,29 @@ static int wps_parse_vendor_ext(struct wps_parse_attr *attr, const u8 *pos, switch (vendor_id) { case WPS_VENDOR_ID_WFA: return wps_parse_vendor_ext_wfa(attr, pos + 3, len - 3); - default: - wpa_printf(MSG_MSGDUMP, "WPS: Skip unknown Vendor Extension " - "(Vendor ID %u)", vendor_id); - break; } + /* Handle unknown vendor extensions */ + + wpa_printf(MSG_MSGDUMP, "WPS: Unknown Vendor Extension (Vendor ID %u)", + vendor_id); + + if (len > WPS_MAX_VENDOR_EXT_LEN) { + wpa_printf(MSG_DEBUG, "WPS: Too long Vendor Extension (%u)", + len); + return -1; + } + + if (attr->num_vendor_ext > MAX_WPS_PARSE_VENDOR_EXT) { + wpa_printf(MSG_DEBUG, "WPS: Skipped Vendor Extension " + "attribute (max %d vendor extensions)", + MAX_WPS_PARSE_VENDOR_EXT); + return -1; + } + attr->vendor_ext[attr->num_vendor_ext] = pos; + attr->vendor_ext_len[attr->num_vendor_ext] = len; + attr->num_vendor_ext++; + return 0; } diff --git a/src/wps/wps_i.h b/src/wps/wps_i.h index 827a82a..437999b 100644 --- a/src/wps/wps_i.h +++ b/src/wps/wps_i.h @@ -207,6 +207,10 @@ struct wps_parse_attr { #define MAX_REQ_DEV_TYPE_COUNT 10 const u8 *req_dev_type[MAX_REQ_DEV_TYPE_COUNT]; size_t num_req_dev_type; + + const u8 *vendor_ext[MAX_WPS_PARSE_VENDOR_EXT]; + size_t vendor_ext_len[MAX_WPS_PARSE_VENDOR_EXT]; + size_t num_vendor_ext; }; /* wps_common.c */ |