summaryrefslogtreecommitdiff
path: root/radsecproxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'radsecproxy.c')
-rw-r--r--radsecproxy.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/radsecproxy.c b/radsecproxy.c
index 7029d8a..f428e6c 100644
--- a/radsecproxy.c
+++ b/radsecproxy.c
@@ -222,12 +222,7 @@ void freebios(struct gqueue *q) {
}
struct client *addclient(struct clsrvconf *conf, uint8_t lock) {
- struct client *new = malloc(sizeof(struct client));
-
- if (!new) {
- debug(DBG_ERR, "malloc failed");
- return NULL;
- }
+ struct client *new = NULL;
if (lock)
pthread_mutex_lock(conf->lock);
@@ -241,7 +236,11 @@ struct client *addclient(struct clsrvconf *conf, uint8_t lock) {
}
}
- memset(new, 0, sizeof(struct client));
+ new = calloc(1, sizeof(struct client));
+ if (!new) {
+ debug(DBG_ERR, "malloc failed");
+ return NULL;
+ }
new->conf = conf;
if (conf->pdef->addclient)
conf->pdef->addclient(new);
@@ -537,7 +536,8 @@ errexit:
if (rq->from)
rmclientrq(rq, rq->msg->id);
freerq(rq);
- pthread_mutex_unlock(&to->newrq_mutex);
+ if (to)
+ pthread_mutex_unlock(&to->newrq_mutex);
removeclientrqs_sendrq_freeserver_lock(0);
}
@@ -1066,6 +1066,7 @@ int dorewritemodattr(struct tlv *attr, struct modattr *modattr) {
i++;
}
}
+ free(in);
memcpy(attr->v + reslen, out + start, i - start);
return 1;
@@ -1130,9 +1131,8 @@ makevendortlv(uint32_t vendor, struct tlv *attr)
tlv2buf(v + 4, attr);
v[5] += 2; /* Vendor length increased for type and length fields. */
newtlv = maketlv(RAD_Attr_Vendor_Specific, l, v);
- if (newtlv == NULL)
- free(v);
- else
+ free(v);
+ if (newtlv)
freetlv(attr);
}
return newtlv;
@@ -1524,7 +1524,7 @@ int radsrv(struct request *rq) {
userascii = radattr2ascii(attr);
if (!userascii)
goto rmclrqexit;
- debug(DBG_DBG, "%s with username: %s", radmsgtype2string(msg->code), userascii);
+ debug(DBG_DBG, "radsrv: got %s (id %d) with username: %s from client %s (%s)", radmsgtype2string(msg->code), msg->id, userascii, from->conf->name, addr2string(from->addr));
/* will return with lock on the realm */
to = findserver(&realm, attr, msg->code == RAD_Accounting_Request);
@@ -1773,8 +1773,7 @@ void replyh(struct server *server, unsigned char *buf) {
if (ttlres == -1 && (options.addttl || from->conf->addttl))
addttlattr(msg, options.ttlattrtype, from->conf->addttl ? from->conf->addttl : options.addttl);
- debug(msg->code == RAD_Access_Accept || msg->code == RAD_Access_Reject || msg->code == RAD_Accounting_Response ? DBG_WARN : DBG_INFO,
- "replyh: passing %s to client %s (%s)", radmsgtype2string(msg->code), from->conf->name, addr2string(from->addr));
+ debug(DBG_DBG, "replyh: passing %s (id %d) to client %s (%s)", radmsgtype2string(msg->code), msg->id, from->conf->name, addr2string(from->addr));
radmsg_free(rqout->rq->msg);
rqout->rq->msg = msg;
@@ -1920,7 +1919,8 @@ void *clientwr(void *arg) {
for (i = 0; i < MAX_REQUESTS; i++) {
if (server->clientrdgone) {
- pthread_join(clientrdth, NULL);
+ if (conf->pdef->connecter)
+ pthread_join(clientrdth, NULL);
goto errexit;
}
@@ -2016,13 +2016,15 @@ void createlistener(uint8_t type, char *arg) {
debugerrno(errno, DBG_WARN, "createlistener: socket failed");
continue;
}
- setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
+ if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1)
+ debugerrno(errno, DBG_WARN, "createlistener: SO_REUSEADDR");
disable_DF_bit(s, res);
#ifdef IPV6_V6ONLY
if (res->ai_family == AF_INET6)
- setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
+ if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) == -1)
+ debugerrno(errno, DBG_WARN, "createlistener: IPV6_V6ONLY");
#endif
if (bind(s, res->ai_addr, res->ai_addrlen)) {
debugerrno(errno, DBG_WARN, "createlistener: bind failed");
@@ -3114,8 +3116,7 @@ int confserver_cb(struct gconffile **cf, void *arg, char *block, char *opt, char
if (resconf || !conf->dynamiclookupcommand) {
if (!compileserverconfig(conf, block))
- return 0; /* Don't goto errexit and free resconf -- it's
- * not ours to free. */
+ goto errexit;
}
if (!conf->secret) {