Skip to content

Commit 4beea81

Browse files
committed
various bug fixes in rlm_eap_mschapv2
1 parent aef528b commit 4beea81

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ static CONF_PARSER module_config[] = {
4444
CONF_PARSER_TERMINATOR
4545
};
4646

47+
/*
48+
* 0 1 2 3
49+
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
50+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51+
* | Code | Identifier | Length |
52+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53+
* | Type | OpCode | MS-CHAPv2-ID | MS-Length...
54+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55+
* | MS-Length | Data...
56+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57+
*/
4758

4859
static void fix_mppe_keys(eap_handler_t *handler, mschapv2_opaque_t *data)
4960
{
@@ -423,8 +434,8 @@ static int CC_HINT(nonnull) mod_process(void *arg, eap_handler_t *handler)
423434
int mschap_id;
424435
int copied = 0 ,seq = 1;
425436

426-
if (eap_ds->response->type.length < 544) {
427-
RDEBUG2("Password change has invalid length %zu < 544",
437+
if (eap_ds->response->type.length < 586) {
438+
RDEBUG2("Password change has invalid length %zu < 586",
428439
eap_ds->response->type.length);
429440
return 0;
430441
}
@@ -492,19 +503,19 @@ static int CC_HINT(nonnull) mod_process(void *arg, eap_handler_t *handler)
492503

493504
case PW_EAP_MSCHAPV2_SUCCESS:
494505
/*
495-
* we sent a success to the client; some clients send a
506+
* we <sent a success to the client; some clients send a
496507
* success back as-per the RFC, some send an ACK. Permit
497508
* both, I guess...
498509
*/
499510

500511
switch (ccode) {
501512
case PW_EAP_MSCHAPV2_SUCCESS:
513+
case PW_EAP_MSCHAPV2_ACK:
502514
eap_ds->request->code = PW_EAP_SUCCESS;
503515

504516
fr_pair_list_mcopy_by_num(request->reply, &request->reply->vps, &data->mppe_keys, 0, 0, TAG_ANY);
505517
/* FALL-THROUGH */
506518

507-
case PW_EAP_MSCHAPV2_ACK:
508519
#ifdef WITH_PROXY
509520
/*
510521
* It's a success. Don't proxy it.
@@ -578,8 +589,8 @@ static int CC_HINT(nonnull) mod_process(void *arg, eap_handler_t *handler)
578589
}
579590

580591
length = (eap_ds->response->type.data[2] << 8) | eap_ds->response->type.data[3];
581-
if ((length < (5 + 49)) || (length > (256 + 5 + 49))) {
582-
REDEBUG("Response contains contradictory length %zu %d", length, 5 + 49);
592+
if ((length < (5 + 49)) || (length > (256 + 5 + 49)) || (length != (eap_ds->response->type.length - 5))) {
593+
REDEBUG("Response contains invalid length %zd", length);
583594
return 0;
584595
}
585596

0 commit comments

Comments
 (0)