mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
Add WPS_DEV_NAME_MAX_LEN define and use it when comparing length
This make code easier to understand. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
dd3d8578d0
commit
cc6f24380c
@ -2837,7 +2837,7 @@ static int hostapd_config_fill(struct hostapd_config *conf,
|
|||||||
os_free(bss->wps_pin_requests);
|
os_free(bss->wps_pin_requests);
|
||||||
bss->wps_pin_requests = os_strdup(pos);
|
bss->wps_pin_requests = os_strdup(pos);
|
||||||
} else if (os_strcmp(buf, "device_name") == 0) {
|
} else if (os_strcmp(buf, "device_name") == 0) {
|
||||||
if (os_strlen(pos) > 32) {
|
if (os_strlen(pos) > WPS_DEV_NAME_MAX_LEN) {
|
||||||
wpa_printf(MSG_ERROR, "Line %d: Too long "
|
wpa_printf(MSG_ERROR, "Line %d: Too long "
|
||||||
"device_name", line);
|
"device_name", line);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -268,7 +268,7 @@ struct p2p_peer_info {
|
|||||||
/**
|
/**
|
||||||
* device_name - Device Name (0..32 octets encoded in UTF-8)
|
* device_name - Device Name (0..32 octets encoded in UTF-8)
|
||||||
*/
|
*/
|
||||||
char device_name[33];
|
char device_name[WPS_DEV_NAME_MAX_LEN + 1];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* manufacturer - Manufacturer (0..64 octets encoded in UTF-8)
|
* manufacturer - Manufacturer (0..64 octets encoded in UTF-8)
|
||||||
|
@ -578,7 +578,7 @@ struct p2p_message {
|
|||||||
const u8 *p2p_device_addr;
|
const u8 *p2p_device_addr;
|
||||||
const u8 *pri_dev_type;
|
const u8 *pri_dev_type;
|
||||||
u8 num_sec_dev_types;
|
u8 num_sec_dev_types;
|
||||||
char device_name[33];
|
char device_name[WPS_DEV_NAME_MAX_LEN + 1];
|
||||||
u16 config_methods;
|
u16 config_methods;
|
||||||
|
|
||||||
/* WPS IE */
|
/* WPS IE */
|
||||||
|
@ -149,7 +149,8 @@ static int p2p_parse_attribute(u8 id, const u8 *data, u16 len,
|
|||||||
pos += 2;
|
pos += 2;
|
||||||
nlen = WPA_GET_BE16(pos);
|
nlen = WPA_GET_BE16(pos);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
if (data + len - pos < (int) nlen || nlen > 32) {
|
if (data + len - pos < (int) nlen ||
|
||||||
|
nlen > WPS_DEV_NAME_MAX_LEN) {
|
||||||
wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name "
|
wpa_printf(MSG_DEBUG, "P2P: Invalid Device Name "
|
||||||
"length %d (buf len %d)", (int) nlen,
|
"length %d (buf len %d)", (int) nlen,
|
||||||
(int) (data + len - pos));
|
(int) (data + len - pos));
|
||||||
@ -674,8 +675,8 @@ int p2p_group_info_parse(const u8 *gi, size_t gi_len,
|
|||||||
t += 2;
|
t += 2;
|
||||||
if (count > cend - t)
|
if (count > cend - t)
|
||||||
return -1; /* invalid Device Name TLV */
|
return -1; /* invalid Device Name TLV */
|
||||||
if (count >= 32)
|
if (count >= WPS_DEV_NAME_MAX_LEN)
|
||||||
count = 32;
|
count = WPS_DEV_NAME_MAX_LEN;
|
||||||
cli->dev_name = (const char *) t;
|
cli->dev_name = (const char *) t;
|
||||||
cli->dev_name_len = count;
|
cli->dev_name_len = count;
|
||||||
|
|
||||||
@ -703,7 +704,7 @@ static int p2p_group_info_text(const u8 *gi, size_t gi_len, char *buf,
|
|||||||
|
|
||||||
for (i = 0; i < info.num_clients; i++) {
|
for (i = 0; i < info.num_clients; i++) {
|
||||||
struct p2p_client_info *cli;
|
struct p2p_client_info *cli;
|
||||||
char name[33];
|
char name[WPS_DEV_NAME_MAX_LEN + 1];
|
||||||
char devtype[WPS_DEV_TYPE_BUFSIZE];
|
char devtype[WPS_DEV_TYPE_BUFSIZE];
|
||||||
u8 s;
|
u8 s;
|
||||||
int count;
|
int count;
|
||||||
|
@ -41,6 +41,7 @@ extern int wps_corrupt_pkhash;
|
|||||||
#define WPS_OOB_DEVICE_PASSWORD_MIN_LEN 16
|
#define WPS_OOB_DEVICE_PASSWORD_MIN_LEN 16
|
||||||
#define WPS_OOB_DEVICE_PASSWORD_LEN 32
|
#define WPS_OOB_DEVICE_PASSWORD_LEN 32
|
||||||
#define WPS_OOB_PUBKEY_HASH_LEN 20
|
#define WPS_OOB_PUBKEY_HASH_LEN 20
|
||||||
|
#define WPS_DEV_NAME_MAX_LEN 32
|
||||||
|
|
||||||
/* Attribute Types */
|
/* Attribute Types */
|
||||||
enum wps_attribute {
|
enum wps_attribute {
|
||||||
|
@ -4141,7 +4141,8 @@ static const struct global_parse_data global_fields[] = {
|
|||||||
{ FUNC_NO_VAR(load_dynamic_eap), 0 },
|
{ FUNC_NO_VAR(load_dynamic_eap), 0 },
|
||||||
#ifdef CONFIG_WPS
|
#ifdef CONFIG_WPS
|
||||||
{ FUNC(uuid), CFG_CHANGED_UUID },
|
{ FUNC(uuid), CFG_CHANGED_UUID },
|
||||||
{ STR_RANGE(device_name, 0, 32), CFG_CHANGED_DEVICE_NAME },
|
{ STR_RANGE(device_name, 0, WPS_DEV_NAME_MAX_LEN),
|
||||||
|
CFG_CHANGED_DEVICE_NAME },
|
||||||
{ STR_RANGE(manufacturer, 0, 64), CFG_CHANGED_WPS_STRING },
|
{ STR_RANGE(manufacturer, 0, 64), CFG_CHANGED_WPS_STRING },
|
||||||
{ STR_RANGE(model_name, 0, 32), CFG_CHANGED_WPS_STRING },
|
{ STR_RANGE(model_name, 0, 32), CFG_CHANGED_WPS_STRING },
|
||||||
{ STR_RANGE(model_number, 0, 32), CFG_CHANGED_WPS_STRING },
|
{ STR_RANGE(model_number, 0, 32), CFG_CHANGED_WPS_STRING },
|
||||||
|
Loading…
Reference in New Issue
Block a user