WPS ER: Clean up WPS session on PutMessage error cases

This is needed to allow new operation to be started after an error
without having to wait for the AP entry to time out.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-09-07 17:45:53 +03:00
parent db9c88ebb5
commit f0f82bd82f

View file

@ -1649,11 +1649,15 @@ static void wps_er_http_put_message_cb(void *ctx, struct http_client *c,
case HTTP_CLIENT_OK: case HTTP_CLIENT_OK:
wpa_printf(MSG_DEBUG, "WPS ER: PutMessage OK"); wpa_printf(MSG_DEBUG, "WPS ER: PutMessage OK");
reply = http_client_get_body(c); reply = http_client_get_body(c);
if (reply == NULL) if (reply)
break; msg = os_zalloc(wpabuf_len(reply) + 1);
msg = os_zalloc(wpabuf_len(reply) + 1); if (msg == NULL) {
if (msg == NULL) if (ap->wps) {
wps_deinit(ap->wps);
ap->wps = NULL;
}
break; break;
}
os_memcpy(msg, wpabuf_head(reply), wpabuf_len(reply)); os_memcpy(msg, wpabuf_head(reply), wpabuf_len(reply));
break; break;
case HTTP_CLIENT_FAILED: case HTTP_CLIENT_FAILED:
@ -1709,21 +1713,30 @@ static void wps_er_ap_put_message(struct wps_er_ap *ap,
url = http_client_url_parse(ap->control_url, &dst, &path); url = http_client_url_parse(ap->control_url, &dst, &path);
if (url == NULL) { if (url == NULL) {
wpa_printf(MSG_DEBUG, "WPS ER: Failed to parse controlURL"); wpa_printf(MSG_DEBUG, "WPS ER: Failed to parse controlURL");
return; goto fail;
} }
buf = wps_er_soap_hdr(msg, "PutMessage", "NewInMessage", path, &dst, buf = wps_er_soap_hdr(msg, "PutMessage", "NewInMessage", path, &dst,
&len_ptr, &body_ptr); &len_ptr, &body_ptr);
os_free(url); os_free(url);
if (buf == NULL) if (buf == NULL)
return; goto fail;
wps_er_soap_end(buf, "PutMessage", len_ptr, body_ptr); wps_er_soap_end(buf, "PutMessage", len_ptr, body_ptr);
ap->http = http_client_addr(&dst, buf, 10000, ap->http = http_client_addr(&dst, buf, 10000,
wps_er_http_put_message_cb, ap); wps_er_http_put_message_cb, ap);
if (ap->http == NULL) if (ap->http == NULL) {
wpabuf_free(buf); wpabuf_free(buf);
goto fail;
}
return;
fail:
if (ap->wps) {
wps_deinit(ap->wps);
ap->wps = NULL;
}
} }