mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
WPS UFD: Remove oob_dev pointer from wps_context
This pointer and the especially the oob_dev->device_path does not remain valid, so better not save it any longer than it is needed.
This commit is contained in:
parent
1b39bad109
commit
7cbf51bbd8
@ -713,14 +713,15 @@ int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
|
|||||||
char *path, char *method)
|
char *path, char *method)
|
||||||
{
|
{
|
||||||
struct wps_context *wps = hapd->wps;
|
struct wps_context *wps = hapd->wps;
|
||||||
|
struct oob_device_data *oob_dev;
|
||||||
|
|
||||||
wps->oob_dev = wps_get_oob_device(device_type);
|
oob_dev = wps_get_oob_device(device_type);
|
||||||
if (wps->oob_dev == NULL)
|
if (oob_dev == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
wps->oob_dev->device_path = path;
|
oob_dev->device_path = path;
|
||||||
wps->oob_conf.oob_method = wps_get_oob_method(method);
|
wps->oob_conf.oob_method = wps_get_oob_method(method);
|
||||||
|
|
||||||
if (wps_process_oob(wps, 1) < 0)
|
if (wps_process_oob(wps, oob_dev, 1) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ||
|
if ((wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ||
|
||||||
|
@ -408,11 +408,6 @@ struct wps_context {
|
|||||||
*/
|
*/
|
||||||
struct wps_device_data dev;
|
struct wps_device_data dev;
|
||||||
|
|
||||||
/**
|
|
||||||
* oob_dev - OOB Device data
|
|
||||||
*/
|
|
||||||
struct oob_device_data *oob_dev;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* oob_conf - OOB Config data
|
* oob_conf - OOB Config data
|
||||||
*/
|
*/
|
||||||
@ -532,7 +527,8 @@ struct wps_context {
|
|||||||
|
|
||||||
struct oob_device_data {
|
struct oob_device_data {
|
||||||
char *device_path;
|
char *device_path;
|
||||||
void * (*init_func)(struct wps_context *, int);
|
void * (*init_func)(struct wps_context *, struct oob_device_data *,
|
||||||
|
int);
|
||||||
struct wpabuf * (*read_func)(void *);
|
struct wpabuf * (*read_func)(void *);
|
||||||
int (*write_func)(void *, struct wpabuf *);
|
int (*write_func)(void *, struct wpabuf *);
|
||||||
void (*deinit_func)(void *);
|
void (*deinit_func)(void *);
|
||||||
@ -560,6 +556,7 @@ void wps_free_pending_msgs(struct upnp_pending_message *msgs);
|
|||||||
|
|
||||||
struct oob_device_data * wps_get_oob_device(char *device_type);
|
struct oob_device_data * wps_get_oob_device(char *device_type);
|
||||||
int wps_get_oob_method(char *method);
|
int wps_get_oob_method(char *method);
|
||||||
int wps_process_oob(struct wps_context *wps, int registrar);
|
int wps_process_oob(struct wps_context *wps, struct oob_device_data *oob_dev,
|
||||||
|
int registrar);
|
||||||
|
|
||||||
#endif /* WPS_H */
|
#endif /* WPS_H */
|
||||||
|
@ -468,16 +468,16 @@ static int wps_parse_oob_cred(struct wps_context *wps, struct wpabuf *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wps_process_oob(struct wps_context *wps, int registrar)
|
int wps_process_oob(struct wps_context *wps, struct oob_device_data *oob_dev,
|
||||||
|
int registrar)
|
||||||
{
|
{
|
||||||
struct oob_device_data *oob_dev = wps->oob_dev;
|
|
||||||
struct wpabuf *data;
|
struct wpabuf *data;
|
||||||
int ret, write_f, oob_method = wps->oob_conf.oob_method;
|
int ret, write_f, oob_method = wps->oob_conf.oob_method;
|
||||||
void *oob_priv;
|
void *oob_priv;
|
||||||
|
|
||||||
write_f = oob_method == OOB_METHOD_DEV_PWD_E ? !registrar : registrar;
|
write_f = oob_method == OOB_METHOD_DEV_PWD_E ? !registrar : registrar;
|
||||||
|
|
||||||
oob_priv = oob_dev->init_func(wps, registrar);
|
oob_priv = oob_dev->init_func(wps, oob_dev, registrar);
|
||||||
if (oob_priv == NULL) {
|
if (oob_priv == NULL) {
|
||||||
wpa_printf(MSG_ERROR, "WPS: Failed to initialize OOB device");
|
wpa_printf(MSG_ERROR, "WPS: Failed to initialize OOB device");
|
||||||
return -1;
|
return -1;
|
||||||
@ -490,8 +490,7 @@ int wps_process_oob(struct wps_context *wps, int registrar)
|
|||||||
data = wps_get_oob_dev_pwd(wps);
|
data = wps_get_oob_dev_pwd(wps);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if (data == NULL ||
|
if (data == NULL || oob_dev->write_func(oob_priv, data) < 0)
|
||||||
wps->oob_dev->write_func(oob_priv, data) < 0)
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
} else {
|
} else {
|
||||||
data = oob_dev->read_func(oob_priv);
|
data = oob_dev->read_func(oob_priv);
|
||||||
|
@ -80,7 +80,7 @@ static int wps_get_dev_pwd_e_file_name(char *path, char *file_name)
|
|||||||
|
|
||||||
|
|
||||||
static int get_file_name(struct wps_context *wps, int registrar,
|
static int get_file_name(struct wps_context *wps, int registrar,
|
||||||
char *file_name)
|
const char *path, char *file_name)
|
||||||
{
|
{
|
||||||
switch (wps->oob_conf.oob_method) {
|
switch (wps->oob_conf.oob_method) {
|
||||||
case OOB_METHOD_CRED:
|
case OOB_METHOD_CRED:
|
||||||
@ -89,8 +89,7 @@ static int get_file_name(struct wps_context *wps, int registrar,
|
|||||||
case OOB_METHOD_DEV_PWD_E:
|
case OOB_METHOD_DEV_PWD_E:
|
||||||
if (registrar) {
|
if (registrar) {
|
||||||
char temp[128];
|
char temp[128];
|
||||||
os_snprintf(temp, sizeof(temp), UFD_DIR2,
|
os_snprintf(temp, sizeof(temp), UFD_DIR2, path);
|
||||||
wps->oob_dev->device_path);
|
|
||||||
if (wps_get_dev_pwd_e_file_name(temp, file_name) < 0)
|
if (wps_get_dev_pwd_e_file_name(temp, file_name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
@ -123,11 +122,12 @@ static int ufd_mkdir(const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void * init_ufd(struct wps_context *wps, int registrar)
|
static void * init_ufd(struct wps_context *wps,
|
||||||
|
struct oob_device_data *oob_dev, int registrar)
|
||||||
{
|
{
|
||||||
int write_f;
|
int write_f;
|
||||||
char temp[128];
|
char temp[128];
|
||||||
char *path = wps->oob_dev->device_path;
|
char *path = oob_dev->device_path;
|
||||||
char filename[13];
|
char filename[13];
|
||||||
struct wps_ufd_data *data;
|
struct wps_ufd_data *data;
|
||||||
int ufd_fd;
|
int ufd_fd;
|
||||||
@ -138,7 +138,7 @@ static void * init_ufd(struct wps_context *wps, int registrar)
|
|||||||
write_f = wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ?
|
write_f = wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ?
|
||||||
!registrar : registrar;
|
!registrar : registrar;
|
||||||
|
|
||||||
if (get_file_name(wps, registrar, filename) < 0) {
|
if (get_file_name(wps, registrar, path, filename) < 0) {
|
||||||
wpa_printf(MSG_ERROR, "WPS (UFD): Failed to get file name");
|
wpa_printf(MSG_ERROR, "WPS (UFD): Failed to get file name");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -466,17 +466,18 @@ int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
|
|||||||
char *path, char *method)
|
char *path, char *method)
|
||||||
{
|
{
|
||||||
struct wps_context *wps = wpa_s->wps;
|
struct wps_context *wps = wpa_s->wps;
|
||||||
|
struct oob_device_data *oob_dev;
|
||||||
|
|
||||||
wps->oob_dev = wps_get_oob_device(device_type);
|
oob_dev = wps_get_oob_device(device_type);
|
||||||
if (wps->oob_dev == NULL)
|
if (oob_dev == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
wps->oob_dev->device_path = path;
|
oob_dev->device_path = path;
|
||||||
wps->oob_conf.oob_method = wps_get_oob_method(method);
|
wps->oob_conf.oob_method = wps_get_oob_method(method);
|
||||||
|
|
||||||
if (wps->oob_conf.oob_method == OOB_METHOD_CRED)
|
if (wps->oob_conf.oob_method == OOB_METHOD_CRED)
|
||||||
wpas_clear_wps(wpa_s);
|
wpas_clear_wps(wpa_s);
|
||||||
|
|
||||||
if (wps_process_oob(wps, 0) < 0)
|
if (wps_process_oob(wps, oob_dev, 0) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ||
|
if ((wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ||
|
||||||
|
Loading…
Reference in New Issue
Block a user