Updated to hostap_2_6
[mech_eap.git] / libeap / src / wps / wps_enrollee.c
index 9321b72..4175077 100644 (file)
@@ -173,7 +173,8 @@ static struct wpabuf * wps_build_m3(struct wps_data *wps)
                wpa_printf(MSG_DEBUG, "WPS: No Device Password available");
                return NULL;
        }
-       wps_derive_psk(wps, wps->dev_password, wps->dev_password_len);
+       if (wps_derive_psk(wps, wps->dev_password, wps->dev_password_len) < 0)
+               return NULL;
 
        if (wps->wps->ap && random_pool_ready() != 1) {
                wpa_printf(MSG_INFO,
@@ -224,11 +225,11 @@ static struct wpabuf * wps_build_m5(struct wps_data *wps)
            wps_build_encr_settings(wps, msg, plain) ||
            wps_build_wfa_ext(msg, 0, NULL, 0) ||
            wps_build_authenticator(wps, msg)) {
-               wpabuf_free(plain);
+               wpabuf_clear_free(plain);
                wpabuf_free(msg);
                return NULL;
        }
-       wpabuf_free(plain);
+       wpabuf_clear_free(plain);
 
        wps->state = RECV_M6;
        return msg;
@@ -394,11 +395,11 @@ static struct wpabuf * wps_build_m7(struct wps_data *wps)
            wps_build_encr_settings(wps, msg, plain) ||
            wps_build_wfa_ext(msg, 0, NULL, 0) ||
            wps_build_authenticator(wps, msg)) {
-               wpabuf_free(plain);
+               wpabuf_clear_free(plain);
                wpabuf_free(msg);
                return NULL;
        }
-       wpabuf_free(plain);
+       wpabuf_clear_free(plain);
 
        if (wps->wps->ap && wps->wps->registrar) {
                /*
@@ -1007,11 +1008,11 @@ static enum wps_process_res wps_process_m2(struct wps_data *wps,
                                              eattr.key_wrap_auth) ||
                    wps_process_creds(wps, eattr.cred, eattr.cred_len,
                                      eattr.num_cred, attr->version2 != NULL)) {
-                       wpabuf_free(decrypted);
+                       wpabuf_clear_free(decrypted);
                        wps->state = SEND_WSC_NACK;
                        return WPS_CONTINUE;
                }
-               wpabuf_free(decrypted);
+               wpabuf_clear_free(decrypted);
 
                wps->state = WPS_MSG_DONE;
                return WPS_CONTINUE;
@@ -1112,7 +1113,7 @@ static enum wps_process_res wps_process_m4(struct wps_data *wps,
        }
 
        if (wps_validate_m4_encr(decrypted, attr->version2 != NULL) < 0) {
-               wpabuf_free(decrypted);
+               wpabuf_clear_free(decrypted);
                wps->state = SEND_WSC_NACK;
                return WPS_CONTINUE;
        }
@@ -1122,11 +1123,11 @@ static enum wps_process_res wps_process_m4(struct wps_data *wps,
        if (wps_parse_msg(decrypted, &eattr) < 0 ||
            wps_process_key_wrap_auth(wps, decrypted, eattr.key_wrap_auth) ||
            wps_process_r_snonce1(wps, eattr.r_snonce1)) {
-               wpabuf_free(decrypted);
+               wpabuf_clear_free(decrypted);
                wps->state = SEND_WSC_NACK;
                return WPS_CONTINUE;
        }
-       wpabuf_free(decrypted);
+       wpabuf_clear_free(decrypted);
 
        wps->state = SEND_M5;
        return WPS_CONTINUE;
@@ -1165,7 +1166,7 @@ static enum wps_process_res wps_process_m6(struct wps_data *wps,
        }
 
        if (wps_validate_m6_encr(decrypted, attr->version2 != NULL) < 0) {
-               wpabuf_free(decrypted);
+               wpabuf_clear_free(decrypted);
                wps->state = SEND_WSC_NACK;
                return WPS_CONTINUE;
        }
@@ -1175,11 +1176,11 @@ static enum wps_process_res wps_process_m6(struct wps_data *wps,
        if (wps_parse_msg(decrypted, &eattr) < 0 ||
            wps_process_key_wrap_auth(wps, decrypted, eattr.key_wrap_auth) ||
            wps_process_r_snonce2(wps, eattr.r_snonce2)) {
-               wpabuf_free(decrypted);
+               wpabuf_clear_free(decrypted);
                wps->state = SEND_WSC_NACK;
                return WPS_CONTINUE;
        }
-       wpabuf_free(decrypted);
+       wpabuf_clear_free(decrypted);
 
        if (wps->wps->ap)
                wps->wps->event_cb(wps->wps->cb_ctx, WPS_EV_AP_PIN_SUCCESS,
@@ -1236,7 +1237,7 @@ static enum wps_process_res wps_process_m8(struct wps_data *wps,
 
        if (wps_validate_m8_encr(decrypted, wps->wps->ap,
                                 attr->version2 != NULL) < 0) {
-               wpabuf_free(decrypted);
+               wpabuf_clear_free(decrypted);
                wps->state = SEND_WSC_NACK;
                return WPS_CONTINUE;
        }
@@ -1249,11 +1250,11 @@ static enum wps_process_res wps_process_m8(struct wps_data *wps,
                              eattr.num_cred, attr->version2 != NULL) ||
            wps_process_ap_settings_e(wps, &eattr, decrypted,
                                      attr->version2 != NULL)) {
-               wpabuf_free(decrypted);
+               wpabuf_clear_free(decrypted);
                wps->state = SEND_WSC_NACK;
                return WPS_CONTINUE;
        }
-       wpabuf_free(decrypted);
+       wpabuf_clear_free(decrypted);
 
        wps->state = WPS_MSG_DONE;
        return WPS_CONTINUE;