@@ -71,6 +71,7 @@ typedef enum {
71
71
#define RADIUS_ACCESS_ACCEPT 2
72
72
#define RADIUS_ACCESS_REJECT 3
73
73
#define RADIUS_ACCESS_CHALLENGE 11
74
+ #define RADIUS_MESSAGE_NONE 0
74
75
75
76
#define MS_MPPE_RECV_KEY_SALT_LEN 2
76
77
#define MS_MPPE_RECV_KEY_BLOCK_LEN 16
@@ -239,14 +240,15 @@ static int8_t radius_client_sec_prot_init(sec_prot_t *prot)
239
240
data -> send_radius_msg = NULL ;
240
241
data -> identity_len = 0 ;
241
242
data -> identity = NULL ;
242
- data -> radius_code = 0 ;
243
+ data -> radius_code = RADIUS_MESSAGE_NONE ;
243
244
data -> radius_identifier = 0 ;
244
245
memset (data -> request_authenticator , 0 , 16 );
245
246
data -> state_len = 0 ;
246
247
data -> state = NULL ;
247
248
memset (data -> remote_eui_64_hash , 0 , 8 );
248
249
data -> remote_eui_64_hash_set = false;
249
250
data -> new_pmk_set = false;
251
+ data -> radius_id_range_set = false;
250
252
251
253
if (!shared_data ) {
252
254
shared_data = ns_dyn_mem_alloc (sizeof (radius_client_sec_prot_shared_t ));
@@ -379,6 +381,10 @@ static int8_t radius_client_sec_prot_receive(sec_prot_t *prot, void *pdu, uint16
379
381
uint8_t * radius_msg_ptr = pdu ;
380
382
381
383
uint8_t code = * radius_msg_ptr ++ ;
384
+ if (code != RADIUS_ACCESS_ACCEPT && code != RADIUS_ACCESS_REJECT && code != RADIUS_ACCESS_CHALLENGE ) {
385
+ return -1 ;
386
+ }
387
+
382
388
uint8_t identifier = * radius_msg_ptr ++ ;
383
389
/* If identifier does not match to sent identifier, silently ignore message,
384
390
already checked on socket if before routing the request to receive, so
@@ -430,6 +436,7 @@ static int8_t radius_client_sec_prot_receive(sec_prot_t *prot, void *pdu, uint16
430
436
// Message does not have radius EAP-TLS specific fields
431
437
data -> radius_code = code ;
432
438
prot -> state_machine (prot );
439
+ data -> radius_code = RADIUS_MESSAGE_NONE ;
433
440
434
441
return 0 ;
435
442
}
@@ -519,6 +526,7 @@ static int8_t radius_client_sec_prot_receive(sec_prot_t *prot, void *pdu, uint16
519
526
data -> radius_code = code ;
520
527
data -> recv_eap_msg_len += data -> radius_eap_tls_header_size ;
521
528
prot -> state_machine (prot );
529
+ data -> radius_code = RADIUS_MESSAGE_NONE ;
522
530
523
531
return 0 ;
524
532
}
@@ -1127,6 +1135,16 @@ static void radius_client_sec_prot_state_machine(sec_prot_t *prot)
1127
1135
return ;
1128
1136
}
1129
1137
1138
+ if (data -> radius_code != RADIUS_MESSAGE_NONE ) {
1139
+ // Received retry for already handled message from RADIUS server, ignore
1140
+ if (data -> recv_eap_msg ) {
1141
+ ns_dyn_mem_free (data -> recv_eap_msg );
1142
+ }
1143
+ data -> recv_eap_msg = NULL ;
1144
+ data -> recv_eap_msg_len = 0 ;
1145
+ return ;
1146
+ }
1147
+
1130
1148
tr_info ("Radius: send access request, eui-64: %s" , trace_array (sec_prot_remote_eui_64_addr_get (prot ), 8 ));
1131
1149
1132
1150
radius_client_sec_prot_allocate_and_create_radius_message (prot );
0 commit comments