diff options
-rw-r--r-- | accel-pppd/auth/auth_chap_md5.c | 24 | ||||
-rw-r--r-- | accel-pppd/auth/auth_mschap_v1.c | 17 | ||||
-rw-r--r-- | accel-pppd/auth/auth_mschap_v2.c | 17 | ||||
-rw-r--r-- | accel-pppd/auth/auth_pap.c | 15 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_auth.c | 8 | ||||
-rw-r--r-- | accel-pppd/session.c | 1 |
6 files changed, 32 insertions, 50 deletions
diff --git a/accel-pppd/auth/auth_chap_md5.c b/accel-pppd/auth/auth_chap_md5.c index 9df39eff..7968762f 100644 --- a/accel-pppd/auth/auth_chap_md5.c +++ b/accel-pppd/auth/auth_chap_md5.c @@ -259,9 +259,10 @@ static void auth_result(struct chap_auth_data *ad, int res) if (res == PWDB_DENIED) { chap_send_failure(ad); - if (ad->started) + if (ad->started) { ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - else + _free(name); + } else ppp_auth_failed(ad->ppp, name); } else { if (ppp_auth_succeeded(ad->ppp, name)) { @@ -272,14 +273,10 @@ static void auth_result(struct chap_auth_data *ad, int res) ad->started = 1; if (conf_interval) triton_timer_add(ad->ppp->ses.ctrl->ctx, &ad->interval, 0); - name = NULL; } } ad->id++; - - if (name) - _free(name); } static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr) @@ -332,7 +329,6 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr) if (ppp_auth_succeeded(ad->ppp, name)) { chap_send_failure(ad); ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - _free(name); return; } chap_send_success(ad, ad->id); @@ -370,17 +366,16 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr) if (conf_ppp_verbose) log_ppp_warn("chap-md5: challenge response mismatch\n"); chap_send_failure(ad); - if (ad->started) + if (ad->started) { ap_session_terminate(&ad->ppp->ses, TERM_USER_ERROR, 0); - else + _free(name); + } else ppp_auth_failed(ad->ppp, name); - _free(name); } else { if (!ad->started) { if (ppp_auth_succeeded(ad->ppp, name)) { chap_send_failure(ad); ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - _free(name); } else { chap_send_success(ad, ad->id); ad->started = 1; @@ -395,17 +390,16 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr) _free(passwd); } else if (r == PWDB_DENIED) { chap_send_failure(ad); - if (ad->started) + if (ad->started) { ap_session_terminate(&ad->ppp->ses, TERM_USER_ERROR, 0); - else + _free(name); + } else ppp_auth_failed(ad->ppp, name); - _free(name); } else { if (!ad->started) { if (ppp_auth_succeeded(ad->ppp, name)) { chap_send_failure(ad); ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - _free(name); } else { chap_send_success(ad, ad->id); ad->started = 1; diff --git a/accel-pppd/auth/auth_mschap_v1.c b/accel-pppd/auth/auth_mschap_v1.c index bf78f23e..f40a8735 100644 --- a/accel-pppd/auth/auth_mschap_v1.c +++ b/accel-pppd/auth/auth_mschap_v1.c @@ -262,9 +262,10 @@ static void auth_result(struct chap_auth_data *ad, int res) if (res == PWDB_DENIED) { chap_send_failure(ad, ad->mschap_error); - if (ad->started) + if (ad->started) { ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - else + _free(name); + } else ppp_auth_failed(ad->ppp, name); } else { if (ppp_auth_succeeded(ad->ppp, name)) { @@ -275,7 +276,6 @@ static void auth_result(struct chap_auth_data *ad, int res) ad->started = 1; if (conf_interval) triton_timer_add(ad->ppp->ses.ctrl->ctx, &ad->interval, 0); - name = NULL; } } @@ -285,9 +285,6 @@ static void auth_result(struct chap_auth_data *ad, int res) _free(ad->mschap_error); ad->mschap_error = conf_msg_failure; } - - if (name) - _free(name); } static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr) @@ -346,7 +343,6 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr) if (ppp_auth_succeeded(ad->ppp, name)) { chap_send_failure(ad, ad->mschap_error); ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - _free(name); return; } chap_send_success(ad, ad->id); @@ -370,11 +366,11 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr) if (r == PWDB_DENIED) { chap_send_failure(ad, ad->mschap_error); - if (ad->started) + if (ad->started) { ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - else + _free(name); + } else ppp_auth_failed(ad->ppp, name); - _free(name); if (ad->mschap_error != conf_msg_failure) { _free(ad->mschap_error); ad->mschap_error = conf_msg_failure; @@ -384,7 +380,6 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr) if (ppp_auth_succeeded(ad->ppp, name)) { chap_send_failure(ad, ad->mschap_error); ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - _free(name); } else { chap_send_success(ad, ad->id); ad->started = 1; diff --git a/accel-pppd/auth/auth_mschap_v2.c b/accel-pppd/auth/auth_mschap_v2.c index f416c434..86917cb3 100644 --- a/accel-pppd/auth/auth_mschap_v2.c +++ b/accel-pppd/auth/auth_mschap_v2.c @@ -335,9 +335,10 @@ static void auth_result(struct chap_auth_data *ad, int res) if (res == PWDB_DENIED) { chap_send_failure(ad, ad->mschap_error, ad->reply_msg); - if (ad->started) + if (ad->started) { ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - else + _free(name); + } else ppp_auth_failed(ad->ppp, name); } else { if (ppp_auth_succeeded(ad->ppp, name)) { @@ -348,7 +349,6 @@ static void auth_result(struct chap_auth_data *ad, int res) ad->started = 1; if (conf_interval) triton_timer_add(ad->ppp->ses.ctrl->ctx, &ad->interval, 0); - name = NULL; } } @@ -363,9 +363,6 @@ static void auth_result(struct chap_auth_data *ad, int res) _free(ad->reply_msg); ad->reply_msg = conf_msg_failure2; } - - if (name) - _free(name); } @@ -445,13 +442,12 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr) if (r == PWDB_DENIED) { chap_send_failure(ad, ad->mschap_error, ad->reply_msg); - if (ad->started) + if (ad->started) { + _free(name); ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - else + } else ppp_auth_failed(ad->ppp, name); - _free(name); - if (ad->mschap_error != conf_msg_failure) { _free(ad->mschap_error); ad->mschap_error = conf_msg_failure; @@ -466,7 +462,6 @@ static void chap_recv_response(struct chap_auth_data *ad, struct chap_hdr *hdr) if (ppp_auth_succeeded(ad->ppp, name)) { chap_send_failure(ad, ad->mschap_error, ad->reply_msg); ap_session_terminate(&ad->ppp->ses, TERM_AUTH_ERROR, 0); - _free(name); } else { chap_send_success(ad, ad->id, authenticator); ad->started = 1; diff --git a/accel-pppd/auth/auth_pap.c b/accel-pppd/auth/auth_pap.c index 15154bf8..a290123e 100644 --- a/accel-pppd/auth/auth_pap.c +++ b/accel-pppd/auth/auth_pap.c @@ -179,9 +179,10 @@ static void pap_auth_result(struct pap_auth_data *p, int res) if (res == PWDB_DENIED) { pap_send_nak(p, p->req_id); - if (p->started) + if (p->started) { ap_session_terminate(&p->ppp->ses, TERM_AUTH_ERROR, 0); - else + _free(peer_id); + } else ppp_auth_failed(p->ppp, peer_id); } else { if (ppp_auth_succeeded(p->ppp, peer_id)) { @@ -193,8 +194,6 @@ static void pap_auth_result(struct pap_auth_data *p, int res) return; } } - - _free(peer_id); } static int pap_recv_req(struct pap_auth_data *p, struct pap_hdr *hdr) @@ -241,7 +240,6 @@ static int pap_recv_req(struct pap_auth_data *p, struct pap_hdr *hdr) if (ppp_auth_succeeded(p->ppp, peer_id)) { pap_send_nak(p, hdr->id); ap_session_terminate(&p->ppp->ses, TERM_AUTH_ERROR, 0); - _free(peer_id); return -1; } pap_send_ack(p, hdr->id); @@ -281,7 +279,6 @@ static int pap_recv_req(struct pap_auth_data *p, struct pap_hdr *hdr) if (ppp_auth_succeeded(p->ppp, peer_id)) { pap_send_nak(p, hdr->id); ap_session_terminate(&p->ppp->ses, TERM_AUTH_ERROR, 0); - _free(peer_id); ret = -1; } else { pap_send_ack(p, hdr->id); @@ -296,13 +293,13 @@ static int pap_recv_req(struct pap_auth_data *p, struct pap_hdr *hdr) failed: pap_send_nak(p, hdr->id); - if (p->started) + if (p->started) { ap_session_terminate(&p->ppp->ses, TERM_AUTH_ERROR, 0); - else + _free(peer_id); + } else ppp_auth_failed(p->ppp, peer_id); _free(passwd); - _free(peer_id); return -1; } diff --git a/accel-pppd/ppp/ppp_auth.c b/accel-pppd/ppp/ppp_auth.c index aa663bf0..79272886 100644 --- a/accel-pppd/ppp/ppp_auth.c +++ b/accel-pppd/ppp/ppp_auth.c @@ -343,10 +343,8 @@ int __export ppp_auth_succeeded(struct ppp_t *ppp, char *username) { struct auth_layer_data_t *ad = container_of(ppp_find_layer_data(ppp, &auth_layer), typeof(*ad), ld); - if (ap_session_set_username(&ppp->ses, username)) { - _free(username); + if (ap_session_set_username(&ppp->ses, username)) return -1; - } if (connect_ppp_channel(ppp)) return -1; @@ -361,7 +359,9 @@ void __export ppp_auth_failed(struct ppp_t *ppp, char *username) if (username) { pthread_rwlock_wrlock(&ses_lock); if (!ppp->ses.username) - ppp->ses.username = _strdup(username); + ppp->ses.username = username; + else + _free(username); ppp->ses.terminate_cause = TERM_AUTH_ERROR; pthread_rwlock_unlock(&ses_lock); log_ppp_info1("%s: authentication failed\n", username); diff --git a/accel-pppd/session.c b/accel-pppd/session.c index 6f7972d5..1ed10235 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -391,6 +391,7 @@ int __export ap_session_set_username(struct ap_session *s, char *username) if (conf_single_session == 0) { pthread_rwlock_unlock(&ses_lock); log_ppp_info1("%s: second session denied\n", username); + _free(username); return -1; } else { ap_session_ifdown(ses); |