tests: Fix eapol-key-auth memory use for the callback pointer struct

This struct needs to remain valid through the lifetime of the
authenticator state machine, so move it to the context struct instead of
being a local stack variable inside the setup function that returns
before the actual test functionality is executed.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2019-06-07 23:54:20 +03:00
parent 9c7e4f94de
commit 009c4d79d3

View file

@ -28,6 +28,7 @@ struct wpa {
u8 *supp_eapol; u8 *supp_eapol;
size_t supp_eapol_len; size_t supp_eapol_len;
struct wpa_auth_callbacks auth_cb;
struct wpa_authenticator *auth_group; struct wpa_authenticator *auth_group;
struct wpa_state_machine *auth; struct wpa_state_machine *auth;
@ -193,7 +194,6 @@ static int auth_set_key(void *ctx, int vlan_id, enum wpa_alg alg,
static int auth_init_group(struct wpa *wpa) static int auth_init_group(struct wpa *wpa)
{ {
struct wpa_auth_config conf; struct wpa_auth_config conf;
struct wpa_auth_callbacks cb;
wpa_printf(MSG_DEBUG, "AUTH: Initializing group state machine"); wpa_printf(MSG_DEBUG, "AUTH: Initializing group state machine");
@ -216,13 +216,12 @@ static int auth_init_group(struct wpa *wpa)
conf.wpa_group_update_count = 4; conf.wpa_group_update_count = 4;
conf.wpa_pairwise_update_count = 4; conf.wpa_pairwise_update_count = 4;
os_memset(&cb, 0, sizeof(cb)); wpa->auth_cb.logger = auth_logger;
cb.logger = auth_logger; wpa->auth_cb.send_eapol = auth_send_eapol;
cb.send_eapol = auth_send_eapol; wpa->auth_cb.get_psk = auth_get_psk;
cb.get_psk = auth_get_psk; wpa->auth_cb.set_key = auth_set_key;
cb.set_key = auth_set_key,
wpa->auth_group = wpa_init(wpa->auth_addr, &conf, &cb, wpa); wpa->auth_group = wpa_init(wpa->auth_addr, &conf, &wpa->auth_cb, wpa);
if (!wpa->auth_group) { if (!wpa->auth_group) {
wpa_printf(MSG_DEBUG, "AUTH: wpa_init() failed"); wpa_printf(MSG_DEBUG, "AUTH: wpa_init() failed");
return -1; return -1;