]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - src/wps/wps_attr_parse.c
hostapd: Support Multi-AP backhaul STA onboarding with WPS
[thirdparty/hostap.git] / src / wps / wps_attr_parse.c
index a1330ded14649c52029b7ad576f553928ab778b6..fd51635158ac5c646bf8772e0d83200972e9c595 100644 (file)
@@ -67,6 +67,17 @@ static int wps_set_vendor_ext_wfa_subelem(struct wps_parse_attr *attr,
                }
                attr->registrar_configuration_methods = pos;
                break;
+       case WFA_ELEM_MULTI_AP:
+               if (len != 1) {
+                       wpa_printf(MSG_DEBUG,
+                                  "WPS: Invalid Multi-AP Extension length %u",
+                                  len);
+                       return -1;
+               }
+               attr->multi_ap_ext = *pos;
+               wpa_printf(MSG_DEBUG, "WPS: Multi-AP Extension 0x%02x",
+                          attr->multi_ap_ext);
+               break;
        default:
                wpa_printf(MSG_MSGDUMP, "WPS: Skipped unknown WFA Vendor "
                           "Extension subelement %u", id);
@@ -83,10 +94,10 @@ static int wps_parse_vendor_ext_wfa(struct wps_parse_attr *attr, const u8 *pos,
        const u8 *end = pos + len;
        u8 id, elen;
 
-       while (pos + 2 <= end) {
+       while (end - pos >= 2) {
                id = *pos++;
                elen = *pos++;
-               if (pos + elen > end)
+               if (elen > end - pos)
                        break;
                if (wps_set_vendor_ext_wfa_subelem(attr, id, elen, pos) < 0)
                        return -1;
@@ -484,6 +495,18 @@ static int wps_set_attr(struct wps_parse_attr *attr, u16 type,
                attr->dev_name_len = len;
                break;
        case ATTR_PUBLIC_KEY:
+               /*
+                * The Public Key attribute is supposed to be exactly 192 bytes
+                * in length. Allow couple of bytes shorter one to try to
+                * interoperate with implementations that do not use proper
+                * zero-padding.
+                */
+               if (len < 190 || len > 192) {
+                       wpa_printf(MSG_DEBUG,
+                                  "WPS: Ignore Public Key with unexpected length %u",
+                                  len);
+                       break;
+               }
                attr->public_key = pos;
                attr->public_key_len = len;
                break;