]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Limit number of active wildcard PINs to one
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 10 Oct 2012 14:38:06 +0000 (17:38 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 10 Oct 2012 14:38:06 +0000 (17:38 +0300)
Previously, WPS Registrar allowed multiple wildcard PINs to be
configured. This can get confusing since these PINs get assigned to any
Enrollee that does not have a specific PIN and as such, cannot really be
used with different PIN values in reasonable ways. To avoid confusion
with multiple enabled PINs, invalidate any previously configured
wildcard PIN whenever adding a new one.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/wps/wps_registrar.c

index 2d0b545d449107f25e3be7569875076795f5c69f..6ce7d168c85f82e9971bba6b14c94ca38467c20a 100644 (file)
@@ -187,6 +187,8 @@ static int wps_set_ie(struct wps_registrar *reg);
 static void wps_registrar_pbc_timeout(void *eloop_ctx, void *timeout_ctx);
 static void wps_registrar_set_selected_timeout(void *eloop_ctx,
                                               void *timeout_ctx);
+static void wps_registrar_remove_pin(struct wps_registrar *reg,
+                                    struct wps_uuid_pin *pin);
 
 
 static void wps_registrar_add_authorized_mac(struct wps_registrar *reg,
@@ -691,6 +693,21 @@ void wps_registrar_deinit(struct wps_registrar *reg)
 }
 
 
+static void wps_registrar_invalidate_unused(struct wps_registrar *reg)
+{
+       struct wps_uuid_pin *pin;
+
+       dl_list_for_each(pin, &reg->pins, struct wps_uuid_pin, list) {
+               if (pin->wildcard_uuid == 1 && !(pin->flags & PIN_LOCKED)) {
+                       wpa_printf(MSG_DEBUG, "WPS: Invalidate previously "
+                                  "configured wildcard PIN");
+                       wps_registrar_remove_pin(reg, pin);
+                       break;
+               }
+       }
+}
+
+
 /**
  * wps_registrar_add_pin - Configure a new PIN for Registrar
  * @reg: Registrar data from wps_registrar_init()
@@ -730,6 +747,9 @@ int wps_registrar_add_pin(struct wps_registrar *reg, const u8 *addr,
                p->expiration.sec += timeout;
        }
 
+       if (p->wildcard_uuid)
+               wps_registrar_invalidate_unused(reg);
+
        dl_list_add(&reg->pins, &p->list);
 
        wpa_printf(MSG_DEBUG, "WPS: A new PIN configured (timeout=%d)",