X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=dtls.c;h=f1a0e1e67ed9d2453785adef50e1e9b04b49e98a;hb=7c62bcd00721941f7c28780266edb3076fc8b9d4;hp=a80c8fd8957c396a2fc6d449586c0c776b217409;hpb=52570225d77be0f9c751ab30e8ec6f98639be827;p=radsecproxy.git diff --git a/dtls.c b/dtls.c index a80c8fd..f1a0e1e 100644 --- a/dtls.c +++ b/dtls.c @@ -248,7 +248,8 @@ void *dtlsserverwr(void *arg) { } void dtlsserverrd(struct client *client) { - struct request rq; + struct request *rq; + uint8_t *buf; pthread_t dtlsserverwrth; debug(DBG_DBG, "dtlsserverrd: starting for %s", client->conf->host); @@ -259,18 +260,25 @@ void dtlsserverrd(struct client *client) { } for (;;) { - memset(&rq, 0, sizeof(struct request)); - rq.buf = raddtlsget(client->ssl, client->rbios, IDLE_TIMEOUT); - if (!rq.buf) { + buf = raddtlsget(client->ssl, client->rbios, IDLE_TIMEOUT); + if (!buf) { debug(DBG_ERR, "dtlsserverrd: connection from %s lost", client->conf->host); break; } debug(DBG_DBG, "dtlsserverrd: got Radius message from %s", client->conf->host); - rq.from = client; - if (!radsrv(&rq)) { + rq = newrequest(); + if (!rq) { + free(buf); + continue; + } + rq->buf = buf; + rq->from = client; + if (!radsrv(rq)) { + freerq(rq); debug(DBG_ERR, "dtlsserverrd: message authentication/validation failed, closing connection from %s", client->conf->host); break; } + freerq(rq); } /* stop writer by setting ssl to NULL and give signal in case waiting for data */ @@ -308,7 +316,7 @@ void *dtlsservernew(void *arg) { while (conf) { if (verifyconfcert(cert, conf)) { X509_free(cert); - client = addclient(conf); + client = addclient(conf, 1); if (client) { client->sock = params->sock; client->rbios = params->sesscache->rbios;