Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix coverity issues
  • Loading branch information
Fabian Mauchle committed May 4, 2021
1 parent 1fcee6e commit 399e5ab
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions dtls.c
Expand Up @@ -425,7 +425,7 @@ int getConnectionInfo(int socket, struct sockaddr *from, socklen_t fromlen, stru
#endif
if(ctrlhdr->cmsg_level == IPPROTO_IPV6 && ctrlhdr->cmsg_type == IPV6_RECVPKTINFO) {
info6 = (struct in6_pktinfo *)CMSG_DATA(ctrlhdr);
debug(DBG_DBG, "udp packet to: %x", inet_ntop(AF_INET6, &info6->ipi6_addr, tmp, sizeof(tmp)));
debug(DBG_DBG, "udp packet to: %s", inet_ntop(AF_INET6, &info6->ipi6_addr, tmp, sizeof(tmp)));

((struct sockaddr_in6 *)to)->sin6_addr = info6->ipi6_addr;
((struct sockaddr_in6 *)to)->sin6_scope_id = info6->ipi6_ifindex;
Expand Down Expand Up @@ -595,7 +595,7 @@ int dtlsconnect(struct server *server, int timeout, char *text) {
if (sslconnecttimeout(server->ssl, 5) <= 0) {
while ((error = ERR_get_error()))
debug(DBG_ERR, "dtlsconnect: SSL connect to %s failed: %s", server->conf->name, ERR_error_string(error, NULL));
debug(DBG_ERR, "dtlsconnect: SSL connect to %s failed", server->conf->name, ERR_error_string(error, NULL));
debug(DBG_ERR, "dtlsconnect: SSL connect to %s failed", server->conf->name);
continue;
}
socktimeout.tv_sec = 5;
Expand Down Expand Up @@ -655,7 +655,7 @@ int clientradputdtls(struct server *server, unsigned char *rad) {
return 0;
}
}
debug(DBG_DBG, "clientradputdtls: Sent %d bytes, Radius packet of length %d to DTLS peer %s", cnt, len, conf->name);
debug(DBG_DBG, "clientradputdtls: Sent %d bytes, Radius packet of length %zu to DTLS peer %s", cnt, len, conf->name);
pthread_mutex_unlock(&server->lock);
return 1;
}
Expand Down
7 changes: 4 additions & 3 deletions hostport.c
Expand Up @@ -95,7 +95,7 @@ struct hostportres *newhostport(char *hostport, char *default_port, uint8_t pref
slash = hostport ? strchr(hostport, '/') : NULL;
if (slash) {
if (!prefixok) {
debug(DBG_WARN, "newhostport: prefix not allowed here", hp->host);
debug(DBG_WARN, "newhostport: prefix not allowed here (%s)", hp->host);
goto errexit;
}
s = slash + 1;
Expand Down Expand Up @@ -236,11 +236,12 @@ struct addrinfo *resolvepassiveaddrinfo(char **hostport, int af, char *default_p
ai = last_ai = hp->addrinfo;
} else {
last_ai->ai_next = hp->addrinfo;
last_ai = last_ai->ai_next;
}
while (last_ai->ai_next)
last_ai = last_ai->ai_next;
hp->addrinfo = NULL;
freehostport(hp);
}
freehostport(hp);
}
return ai;
}
Expand Down
7 changes: 4 additions & 3 deletions radsecproxy.c
Expand Up @@ -2173,6 +2173,7 @@ int dynamicconfig(struct server *server) {
ok = getgenericconfig(&cf, NULL, "Server", CONF_CBK, confserver_cb, (void *) conf, NULL);
freegconf(&cf);
}
fclose(pipein);

if (waitpid(pid, &status, 0) < 0) {
debugerrno(errno, DBG_ERR, "dynamicconfig: wait error");
Expand Down Expand Up @@ -2643,7 +2644,7 @@ int confserver_cb(struct gconffile **cf, void *arg, char *block, char *opt, char

if (retryinterval != LONG_MIN) {
if (retryinterval < 1 || retryinterval > conf->pdef->retryintervalmax) {
debug(DBG_ERR, "error in block %s, value of option RetryInterval is %d, must be 1-%d", block, retryinterval, conf->pdef->retryintervalmax);
debug(DBG_ERR, "error in block %s, value of option RetryInterval is %ld, must be 1-%d", block, retryinterval, conf->pdef->retryintervalmax);
goto errexit;
}
conf->retryinterval = (uint8_t)retryinterval;
Expand All @@ -2652,7 +2653,7 @@ int confserver_cb(struct gconffile **cf, void *arg, char *block, char *opt, char

if (retrycount != LONG_MIN) {
if (retrycount < 0 || retrycount > conf->pdef->retrycountmax) {
debug(DBG_ERR, "error in block %s, value of option RetryCount is %d, must be 0-%d", block, retrycount, conf->pdef->retrycountmax);
debug(DBG_ERR, "error in block %s, value of option RetryCount is %ld, must be 0-%d", block, retrycount, conf->pdef->retrycountmax);
goto errexit;
}
conf->retrycount = (uint8_t)retrycount;
Expand All @@ -2661,7 +2662,7 @@ int confserver_cb(struct gconffile **cf, void *arg, char *block, char *opt, char

if (addttl != LONG_MIN) {
if (addttl < 1 || addttl > 255) {
debug(DBG_ERR, "error in block %s, value of option addTTL is %d, must be 1-255", block, addttl);
debug(DBG_ERR, "error in block %s, value of option addTTL is %ld, must be 1-255", block, addttl);
goto errexit;
}
conf->addttl = (uint8_t)addttl;
Expand Down
2 changes: 1 addition & 1 deletion rewrite.c
Expand Up @@ -411,7 +411,7 @@ int dorewritemodattr(struct tlv *attr, struct modattr *modattr) {
}
reslen += i - start;
if (!resizeattr(attr, reslen)) {
debug(DBG_INFO, "rewritten attribute to length %d failed, discarding message", reslen);
debug(DBG_INFO, "rewritten attribute to length %zu failed, discarding message", reslen);
free(in);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion tcp.c
Expand Up @@ -219,7 +219,7 @@ int clientradputtcp(struct server *server, unsigned char *rad) {
debug(DBG_ERR, "clientradputtcp: write error");
return 0;
}
debug(DBG_DBG, "clientradputtcp: Sent %d bytes, Radius packet of length %d to TCP peer %s", cnt, len, conf->name);
debug(DBG_DBG, "clientradputtcp: Sent %d bytes, Radius packet of length %zu to TCP peer %s", cnt, len, conf->name);
return 1;
}

Expand Down
4 changes: 2 additions & 2 deletions tls.c
Expand Up @@ -156,7 +156,7 @@ int tlsconnect(struct server *server, int timeout, char *text) {
if (sslconnecttimeout(server->ssl, 5) <= 0) {
while ((error = ERR_get_error()))
debug(DBG_ERR, "tlsconnect: SSL connect to %s failed: %s", server->conf->name, ERR_error_string(error, NULL));
debug(DBG_ERR, "tlsconnect: SSL connect to %s failed", server->conf->name, ERR_error_string(error, NULL));
debug(DBG_ERR, "tlsconnect: SSL connect to %s failed", server->conf->name);
continue;
}

Expand Down Expand Up @@ -354,7 +354,7 @@ int clientradputtls(struct server *server, unsigned char *rad) {
return 0;
}

debug(DBG_DBG, "clientradputtls: Sent %d bytes, Radius packet of length %d to TLS peer %s", cnt, len, conf->name);
debug(DBG_DBG, "clientradputtls: Sent %d bytes, Radius packet of length %zu to TLS peer %s", cnt, len, conf->name);
pthread_mutex_unlock(&server->lock);
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion udp.c
Expand Up @@ -248,7 +248,7 @@ int clientradputudp(struct server *server, unsigned char *rad) {
len = RADLEN(rad);
ai = ((struct hostportres *)list_first(conf->hostports)->data)->addrinfo;
if (sendto(server->sock, rad, len, 0, ai->ai_addr, ai->ai_addrlen) >= 0) {
debug(DBG_DBG, "clienradputudp: sent UDP of length %d to %s port %d", len, addr2string(ai->ai_addr, tmp, sizeof(tmp)), port_get(ai->ai_addr));
debug(DBG_DBG, "clienradputudp: sent UDP of length %zu to %s port %d", len, addr2string(ai->ai_addr, tmp, sizeof(tmp)), port_get(ai->ai_addr));
return 1;
}

Expand Down

0 comments on commit 399e5ab

Please sign in to comment.