summaryrefslogtreecommitdiff
path: root/accel-pptpd/auth
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2010-09-20 01:09:07 +0400
committerDmitry Kozlov <xeb@mail.ru>2010-09-20 01:09:34 +0400
commitb96fbc3f966b012720d2b74b1dfd2a0ab95086cf (patch)
tree606750874faf65029f756dc0b401ee40cc4da89f /accel-pptpd/auth
parentd860a4beaf5f99d5045d03b931b4829426a2f7b0 (diff)
downloadaccel-ppp-b96fbc3f966b012720d2b74b1dfd2a0ab95086cf.tar.gz
accel-ppp-b96fbc3f966b012720d2b74b1dfd2a0ab95086cf.zip
fixed many bugs and memory leaks
Diffstat (limited to 'accel-pptpd/auth')
-rw-r--r--accel-pptpd/auth/auth_chap_md5.c14
-rw-r--r--accel-pptpd/auth/auth_mschap_v1.c16
-rw-r--r--accel-pptpd/auth/auth_mschap_v2.c22
-rw-r--r--accel-pptpd/auth/auth_pap.c14
4 files changed, 37 insertions, 29 deletions
diff --git a/accel-pptpd/auth/auth_chap_md5.c b/accel-pptpd/auth/auth_chap_md5.c
index 058dc677..7681fb5c 100644
--- a/accel-pptpd/auth/auth_chap_md5.c
+++ b/accel-pptpd/auth/auth_chap_md5.c
@@ -15,6 +15,8 @@
#include "ppp_lcp.h"
#include "pwdb.h"
+#include "memdebug.h"
+
#define CHAP_CHALLENGE 1
#define CHAP_RESPONSE 2
#define CHAP_SUCCESS 3
@@ -89,7 +91,7 @@ static void print_str(const char *buf,int size)
static struct auth_data_t* auth_data_init(struct ppp_t *ppp)
{
- struct chap_auth_data_t *d=malloc(sizeof(*d));
+ struct chap_auth_data_t *d=_malloc(sizeof(*d));
memset(d,0,sizeof(*d));
d->auth.proto=PPP_CHAP;
@@ -102,7 +104,7 @@ static void auth_data_free(struct ppp_t *ppp,struct auth_data_t *auth)
{
struct chap_auth_data_t *d=container_of(auth,typeof(*d),auth);
- free(d);
+ _free(d);
}
static int chap_start(struct ppp_t *ppp, struct auth_data_t *auth)
@@ -223,7 +225,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
ppp_terminate(ad->ppp, 0);
}
- name = strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
+ name = _strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
r = pwdb_check(ad->ppp, name, PPP_CHAP, CHAP_MD5, ad->id, ad->val, VALUE_SIZE, msg->val);
@@ -231,7 +233,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
passwd = pwdb_get_passwd(ad->ppp,name);
if (!passwd)
{
- free(name);
+ _free(name);
log_ppp_debug("chap-md5: user not found\n");
chap_send_failure(ad);
return;
@@ -253,11 +255,11 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
chap_send_success(ad);
auth_successed(ad->ppp, name);
}
- free(passwd);
+ _free(passwd);
} else if (r == PWDB_DENIED) {
chap_send_failure(ad);
auth_failed(ad->ppp);
- free(name);
+ _free(name);
} else {
chap_send_success(ad);
auth_successed(ad->ppp, name);
diff --git a/accel-pptpd/auth/auth_mschap_v1.c b/accel-pptpd/auth/auth_mschap_v1.c
index bc54ed46..818d60db 100644
--- a/accel-pptpd/auth/auth_mschap_v1.c
+++ b/accel-pptpd/auth/auth_mschap_v1.c
@@ -17,6 +17,8 @@
#include "ppp_lcp.h"
#include "pwdb.h"
+#include "memdebug.h"
+
#define MSCHAP_V1 0x80
#define CHAP_CHALLENGE 1
@@ -101,7 +103,7 @@ static void print_str(const char *buf,int size)
static struct auth_data_t* auth_data_init(struct ppp_t *ppp)
{
- struct chap_auth_data_t *d=malloc(sizeof(*d));
+ struct chap_auth_data_t *d=_malloc(sizeof(*d));
memset(d,0,sizeof(*d));
d->auth.proto=PPP_CHAP;
@@ -114,7 +116,7 @@ static void auth_data_free(struct ppp_t *ppp,struct auth_data_t *auth)
{
struct chap_auth_data_t *d=container_of(auth,typeof(*d),auth);
- free(d);
+ _free(d);
}
static int chap_start(struct ppp_t *ppp, struct auth_data_t *auth)
@@ -234,7 +236,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
auth_failed(ad->ppp);
}
- name = strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
+ name = _strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
if (!name) {
log_emerg("mschap-v2: out of memory\n");
auth_failed(ad->ppp);
@@ -248,7 +250,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
if (r == PWDB_DENIED) {
chap_send_failure(ad);
auth_failed(ad->ppp);
- free(name);
+ _free(name);
} else {
chap_send_success(ad);
auth_successed(ad->ppp, name);
@@ -301,7 +303,7 @@ static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response
return PWDB_DENIED;
}
- u_passwd=malloc(strlen(passwd)*2);
+ u_passwd=_malloc(strlen(passwd)*2);
for(i=0; i<strlen(passwd); i++)
{
u_passwd[i*2]=passwd[i];
@@ -317,8 +319,8 @@ static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response
des_encrypt(ad->val,z_hash+7,nt_hash+8);
des_encrypt(ad->val,z_hash+14,nt_hash+16);
- free(passwd);
- free(u_passwd);
+ _free(passwd);
+ _free(u_passwd);
return memcmp(nt_hash,msg->nt_hash,24) ? PWDB_DENIED : PWDB_SUCCESS;
}
diff --git a/accel-pptpd/auth/auth_mschap_v2.c b/accel-pptpd/auth/auth_mschap_v2.c
index 798f6eed..8e507759 100644
--- a/accel-pptpd/auth/auth_mschap_v2.c
+++ b/accel-pptpd/auth/auth_mschap_v2.c
@@ -18,6 +18,8 @@
#include "ppp_lcp.h"
#include "pwdb.h"
+#include "memdebug.h"
+
#define MSCHAP_V2 0x81
#define CHAP_CHALLENGE 1
@@ -116,7 +118,7 @@ static void print_str(const char *buf,int size)
static struct auth_data_t* auth_data_init(struct ppp_t *ppp)
{
- struct chap_auth_data_t *d=malloc(sizeof(*d));
+ struct chap_auth_data_t *d=_malloc(sizeof(*d));
memset(d,0,sizeof(*d));
d->auth.proto=PPP_CHAP;
@@ -129,7 +131,7 @@ static void auth_data_free(struct ppp_t *ppp,struct auth_data_t *auth)
{
struct chap_auth_data_t *d=container_of(auth,typeof(*d),auth);
- free(d);
+ _free(d);
}
static int chap_start(struct ppp_t *ppp, struct auth_data_t *auth)
@@ -199,7 +201,7 @@ static int generate_response(struct chap_auth_data_t *ad, struct chap_response_t
if (!passwd)
return -1;
- u_passwd=malloc(strlen(passwd)*2);
+ u_passwd=_malloc(strlen(passwd)*2);
for(i=0; i<strlen(passwd); i++)
{
u_passwd[i*2]=passwd[i];
@@ -235,8 +237,8 @@ static int generate_response(struct chap_auth_data_t *ad, struct chap_response_t
for(i=0; i<20; i++)
sprintf(authenticator+i*2,"%02X",response[i]);
- free(passwd);
- free(u_passwd);
+ _free(passwd);
+ _free(u_passwd);
return 0;
}
@@ -309,7 +311,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
ppp_terminate(ad->ppp, 0);
}
- name=strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
+ name=_strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2);
if (!name) {
log_emerg("mschap-v2: out of memory\n");
auth_failed(ad->ppp);
@@ -327,7 +329,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
if (r == PWDB_DENIED) {
chap_send_failure(ad);
auth_failed(ad->ppp);
- free(name);
+ _free(name);
} else {
chap_send_success(ad, msg, authenticator);
auth_successed(ad->ppp, name);
@@ -382,7 +384,7 @@ static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response
return -1;
}
- u_passwd=malloc(strlen(passwd)*2);
+ u_passwd=_malloc(strlen(passwd)*2);
for(i=0; i<strlen(passwd); i++)
{
u_passwd[i*2]=passwd[i];
@@ -404,8 +406,8 @@ static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response
des_encrypt(c_hash,z_hash+7,nt_hash+8);
des_encrypt(c_hash,z_hash+14,nt_hash+16);
- free(passwd);
- free(u_passwd);
+ _free(passwd);
+ _free(u_passwd);
return memcmp(nt_hash,msg->nt_hash,24);
}
diff --git a/accel-pptpd/auth/auth_pap.c b/accel-pptpd/auth/auth_pap.c
index 81098ce9..2abf5720 100644
--- a/accel-pptpd/auth/auth_pap.c
+++ b/accel-pptpd/auth/auth_pap.c
@@ -9,6 +9,8 @@
#include "ppp_lcp.h"
#include "pwdb.h"
+#include "memdebug.h"
+
#define MSG_FAILED "Authentication failed"
#define MSG_SUCCESSED "Authentication successed"
@@ -63,7 +65,7 @@ static struct ppp_auth_handler_t pap=
static struct auth_data_t* auth_data_init(struct ppp_t *ppp)
{
- struct pap_auth_data_t *d=malloc(sizeof(*d));
+ struct pap_auth_data_t *d=_malloc(sizeof(*d));
memset(d,0,sizeof(*d));
d->auth.proto=PPP_PAP;
@@ -76,7 +78,7 @@ static void auth_data_free(struct ppp_t *ppp,struct auth_data_t *auth)
{
struct pap_auth_data_t *d=container_of(auth,typeof(*d),auth);
- free(d);
+ _free(d);
}
static int pap_start(struct ppp_t *ppp, struct auth_data_t *auth)
@@ -168,8 +170,8 @@ static int pap_recv_req(struct pap_auth_data_t *p,struct pap_hdr_t *hdr)
return -1;
}
- peer_id=strndup((const char*)peer_id,peer_id_len);
- passwd=strndup((const char*)ptr,passwd_len);
+ peer_id=_strndup((const char*)peer_id,peer_id_len);
+ passwd=_strndup((const char*)ptr,passwd_len);
r = pwdb_check(p->ppp, peer_id, PPP_PAP, passwd);
if (r == PWDB_NO_IMPL) {
@@ -184,14 +186,14 @@ static int pap_recv_req(struct pap_auth_data_t *p,struct pap_hdr_t *hdr)
pap_send_nak(p, hdr->id);
auth_failed(p->ppp);
ret=-1;
- free(peer_id);
+ _free(peer_id);
} else {
pap_send_ack(p, hdr->id);
auth_successed(p->ppp, peer_id);
ret = 0;
}
- free(passwd);
+ _free(passwd);
return ret;
}