Skip to content

Commit

Permalink
All the free_opaque stuff in TLS and EAP was made redundant by talloc
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Oct 19, 2015
1 parent 97c425b commit 4b01cc6
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 45 deletions.
1 change: 0 additions & 1 deletion src/include/tls-h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ typedef struct _tls_session_t {
* Used by TTLS & PEAP to keep track of other per-session data.
*/
void *opaque;
void (*free_opaque)(void *opaque);

char const *prf_label;
bool allow_session_resumption; //!< Whether session resumption is allowed.
Expand Down
9 changes: 0 additions & 9 deletions src/main/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,6 @@ void tls_session_id(SSL_SESSION *session, char *buffer, size_t bufsize)

static int _tls_session_free(tls_session_t *session)
{
/*
* Free any opaque TTLS or PEAP data.
*/
if ((session->opaque) && (session->free_opaque)) {
session->free_opaque(session->opaque);
session->opaque = NULL;
}

session_close(session);

return 0;
Expand Down Expand Up @@ -687,7 +679,6 @@ static void session_init(tls_session_t *session)
session->record_out_total_len = 0;
session->length_flag = false;
session->opaque = NULL;
session->free_opaque = NULL;
}

static void session_close(tls_session_t *session)
Expand Down
25 changes: 8 additions & 17 deletions src/modules/rlm_eap/eap.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,13 @@ eap_rcode_t eap_method_select(rlm_eap_t *inst, eap_session_t *eap_session)
/*
* Allow per-user configuration of EAP types.
*/
vp = fr_pair_find_by_num(eap_session->request->config, PW_EAP_TYPE, 0,
TAG_ANY);
vp = fr_pair_find_by_num(eap_session->request->config, PW_EAP_TYPE, 0, TAG_ANY);
if (vp) next = vp->vp_integer;

/*
* Ensure it's valid.
*/
if ((next < PW_EAP_MD5) ||
(next >= PW_EAP_MAX_TYPES) ||
(!inst->methods[next])) {
if ((next < PW_EAP_MD5) || (next >= PW_EAP_MAX_TYPES) || (!inst->methods[next])) {
REDEBUG2("Tried to start unsupported method (%d)", next);

return EAP_INVALID;
Expand All @@ -395,23 +392,17 @@ eap_rcode_t eap_method_select(rlm_eap_t *inst, eap_session_t *eap_session)

case PW_EAP_NAK:
/*
* Delete old data, if necessary.
* Delete old data, if necessary. If we called a method
* before, and it initialized itself, we need to free
* the memory it alloced.
*/
if (eap_session->opaque && eap_session->free_opaque) {
eap_session->free_opaque(eap_session->opaque);
eap_session->free_opaque = NULL;
eap_session->opaque = NULL;
}

next = eap_process_nak(inst, eap_session->request,
eap_session->type, type);
TALLOC_FREE(eap_session->opaque);
next = eap_process_nak(inst, eap_session->request, eap_session->type, type);

/*
* We probably want to return 'fail' here...
*/
if (!next) {
return EAP_INVALID;
}
if (!next) return EAP_INVALID;

goto do_initiate;

Expand Down
1 change: 0 additions & 1 deletion src/modules/rlm_eap/eap.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ struct _eap_session {
//!< we're building.

void *opaque; //!< Opaque data used by EAP methods.
void (*free_opaque)(void *opaque); //!< Callback to free opaque data.

eap_process_t process; //!< Callback that should be used to process the next round.
//!< Usually set to the process functino of an EAP submodule.
Expand Down
8 changes: 0 additions & 8 deletions src/modules/rlm_eap/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ static int _eap_session_free(eap_session_t *eap_session)
if (eap_session->prev_round) eap_round_free(&(eap_session->prev_round));
if (eap_session->this_round) eap_round_free(&(eap_session->this_round));

if ((eap_session->opaque) && (eap_session->free_opaque)) {
eap_session->free_opaque(eap_session->opaque);
eap_session->opaque = NULL;
}

eap_session->opaque = NULL;
eap_session->free_opaque = NULL;

/*
* Give helpful debug messages if:
*
Expand Down
2 changes: 0 additions & 2 deletions src/modules/rlm_eap/types/rlm_eap_leap/rlm_eap_leap.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ static int CC_HINT(nonnull) mod_session_init(UNUSED void *instance, eap_session_
* we sent to the AP. The later stages will take care
* of filling in the peer response.
*/
eap_session->free_opaque = NULL;

session->stage = 4; /* the next stage we're in */
memcpy(session->peer_challenge, reply->challenge, reply->count);

Expand Down
1 change: 0 additions & 1 deletion src/modules/rlm_eap/types/rlm_eap_md5/rlm_eap_md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ static int mod_session_init(UNUSED void *instance, eap_session_t *eap_session)
eap_session->opaque = talloc_array(eap_session, uint8_t, reply->value_size);
rad_assert(eap_session->opaque != NULL);
memcpy(eap_session->opaque, reply->value, reply->value_size);
eap_session->free_opaque = NULL;

/*
* Compose the EAP-MD5 packet out of the data structure,
Expand Down
4 changes: 1 addition & 3 deletions src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ static int mod_process(void *arg, eap_session_t *eap_session)
* Session resumption requires the storage of data, so
* allocate it if it doesn't already exist.
*/
if (!tls_session->opaque) {
peap = tls_session->opaque = peap_alloc(tls_session, inst);
}
if (!tls_session->opaque) peap = tls_session->opaque = peap_alloc(tls_session, inst);

status = eap_tls_process(eap_session);
if ((status == FR_TLS_INVALID) || (status == FR_TLS_FAIL)) {
Expand Down
4 changes: 1 addition & 3 deletions src/modules/rlm_eap/types/rlm_eap_ttls/rlm_eap_ttls.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,7 @@ static int mod_process(void *arg, eap_session_t *eap_session)
* We may need TTLS data associated with the session, so
* allocate it here, if it wasn't already alloacted.
*/
if (!tls_session->opaque) {
tls_session->opaque = ttls_alloc(tls_session, inst);
}
if (!tls_session->opaque) tls_session->opaque = ttls_alloc(tls_session, inst);

/*
* Process the TTLS portion of the request.
Expand Down

0 comments on commit 4b01cc6

Please sign in to comment.