summaryrefslogtreecommitdiffstats
path: root/contrib/wpa_supplicant/eap_gtc.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2006-03-07 05:26:33 +0000
committersam <sam@FreeBSD.org>2006-03-07 05:26:33 +0000
commit840099f34d8de1ca769f02fae379c4d8e5d6688a (patch)
tree0c0ff34569d807e7bceb062a6210ce68490a8764 /contrib/wpa_supplicant/eap_gtc.c
parent34dbcde8dfa5b3d152d250b6d69965e001238e49 (diff)
downloadFreeBSD-src-840099f34d8de1ca769f02fae379c4d8e5d6688a.zip
FreeBSD-src-840099f34d8de1ca769f02fae379c4d8e5d6688a.tar.gz
Import of WPA supplicant 0.4.8
Diffstat (limited to 'contrib/wpa_supplicant/eap_gtc.c')
-rw-r--r--contrib/wpa_supplicant/eap_gtc.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/contrib/wpa_supplicant/eap_gtc.c b/contrib/wpa_supplicant/eap_gtc.c
index 42a7a49..3665746 100644
--- a/contrib/wpa_supplicant/eap_gtc.c
+++ b/contrib/wpa_supplicant/eap_gtc.c
@@ -53,29 +53,27 @@ static void eap_gtc_deinit(struct eap_sm *sm, void *priv)
static u8 * eap_gtc_process(struct eap_sm *sm, void *priv,
struct eap_method_ret *ret,
- u8 *reqData, size_t reqDataLen,
+ const u8 *reqData, size_t reqDataLen,
size_t *respDataLen)
{
struct eap_gtc_data *data = priv;
struct wpa_ssid *config = eap_get_config(sm);
- struct eap_hdr *req, *resp;
- u8 *pos, *password;
- size_t password_len, len, msg_len;
-
- req = (struct eap_hdr *) reqData;
- pos = (u8 *) (req + 1);
- if (reqDataLen < sizeof(*req) + 1 || *pos != EAP_TYPE_GTC ||
- (len = be_to_host16(req->length)) > reqDataLen) {
- wpa_printf(MSG_INFO, "EAP-GTC: Invalid frame");
+ const struct eap_hdr *req;
+ struct eap_hdr *resp;
+ const u8 *pos, *password;
+ u8 *rpos;
+ size_t password_len, len;
+
+ pos = eap_hdr_validate(EAP_TYPE_GTC, reqData, reqDataLen, &len);
+ if (pos == NULL) {
ret->ignore = TRUE;
return NULL;
}
- pos++;
- msg_len = len - sizeof(*req) - 1;
- wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-GTC: Request message",
- pos, msg_len);
+ req = (const struct eap_hdr *) reqData;
+
+ wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-GTC: Request message", pos, len);
if (data->prefix &&
- (msg_len < 10 || memcmp(pos, "CHALLENGE=", 10) != 0)) {
+ (len < 10 || memcmp(pos, "CHALLENGE=", 10) != 0)) {
wpa_printf(MSG_DEBUG, "EAP-GTC: Challenge did not start with "
"expected prefix");
@@ -90,16 +88,15 @@ static u8 * eap_gtc_process(struct eap_sm *sm, void *priv,
resp->code = EAP_CODE_RESPONSE;
resp->identifier = req->identifier;
resp->length = host_to_be16(*respDataLen);
- pos = (u8 *) (resp + 1);
- *pos++ = EAP_TYPE_GTC;
+ rpos = (u8 *) (resp + 1);
+ *rpos++ = EAP_TYPE_GTC;
return (u8 *) resp;
}
if (config == NULL ||
(config->password == NULL && config->otp == NULL)) {
wpa_printf(MSG_INFO, "EAP-GTC: Password not configured");
- eap_sm_request_otp(sm, config, (char *) pos,
- len - sizeof(*req) - 1);
+ eap_sm_request_otp(sm, config, (const char *) pos, len);
ret->ignore = TRUE;
return NULL;
}
@@ -128,16 +125,16 @@ static u8 * eap_gtc_process(struct eap_sm *sm, void *priv,
resp->code = EAP_CODE_RESPONSE;
resp->identifier = req->identifier;
resp->length = host_to_be16(*respDataLen);
- pos = (u8 *) (resp + 1);
- *pos++ = EAP_TYPE_GTC;
+ rpos = (u8 *) (resp + 1);
+ *rpos++ = EAP_TYPE_GTC;
if (data->prefix) {
- memcpy(pos, "RESPONSE=", 9);
- pos += 9;
- memcpy(pos, config->identity, config->identity_len);
- pos += config->identity_len;
- *pos++ = '\0';
+ memcpy(rpos, "RESPONSE=", 9);
+ rpos += 9;
+ memcpy(rpos, config->identity, config->identity_len);
+ rpos += config->identity_len;
+ *rpos++ = '\0';
}
- memcpy(pos, password, password_len);
+ memcpy(rpos, password, password_len);
wpa_hexdump_ascii_key(MSG_MSGDUMP, "EAP-GTC: Response",
(u8 *) (resp + 1) + 1,
*respDataLen - sizeof(struct eap_hdr) - 1);
OpenPOWER on IntegriCloud