]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wps_registrar: Use monotonic time for PIN timeout
authorJohannes Berg <johannes.berg@intel.com>
Mon, 16 Dec 2013 20:08:35 +0000 (21:08 +0100)
committerJouni Malinen <j@w1.fi>
Tue, 24 Dec 2013 05:51:41 +0000 (07:51 +0200)
If the PIN expires, then a timeout is given, so that monotonic
time should be used.

Signed-hostap: Johannes Berg <johannes.berg@intel.com>

src/wps/wps_registrar.c

index ef17617085edd66867240ec76806a7b02629dbf2..a18f91b932176054ffcfed3ade76877c9371142f 100644 (file)
@@ -82,7 +82,7 @@ struct wps_uuid_pin {
 #define PIN_LOCKED BIT(0)
 #define PIN_EXPIRES BIT(1)
        int flags;
-       struct os_time expiration;
+       struct os_reltime expiration;
        u8 enrollee_addr[ETH_ALEN];
 };
 
@@ -748,7 +748,7 @@ int wps_registrar_add_pin(struct wps_registrar *reg, const u8 *addr,
 
        if (timeout) {
                p->flags |= PIN_EXPIRES;
-               os_get_time(&p->expiration);
+               os_get_reltime(&p->expiration);
                p->expiration.sec += timeout;
        }
 
@@ -797,13 +797,13 @@ static void wps_registrar_remove_pin(struct wps_registrar *reg,
 static void wps_registrar_expire_pins(struct wps_registrar *reg)
 {
        struct wps_uuid_pin *pin, *prev;
-       struct os_time now;
+       struct os_reltime now;
 
-       os_get_time(&now);
+       os_get_reltime(&now);
        dl_list_for_each_safe(pin, prev, &reg->pins, struct wps_uuid_pin, list)
        {
                if ((pin->flags & PIN_EXPIRES) &&
-                   os_time_before(&pin->expiration, &now)) {
+                   os_reltime_before(&pin->expiration, &now)) {
                        wpa_hexdump(MSG_DEBUG, "WPS: Expired PIN for UUID",
                                    pin->uuid, WPS_UUID_LEN);
                        wps_registrar_remove_pin(reg, pin);