aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2018-07-20 18:24:20 +0200
committerToni Uhlig <matzeton@googlemail.com>2018-07-20 18:24:20 +0200
commitb821e069cd21d212e64cbacc1d3dd1bd22419623 (patch)
treec2fff3fc82a4bea9fcbc52e7b8d8a984a114ef95 /src
parent4bf632672502bc59ca2e8fb1010cf2081b16521e (diff)
fixed/ignore coverity errors/false-positives
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r--src/main.c6
-rw-r--r--src/socket.c10
2 files changed, 12 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 9600176..494e235 100644
--- a/src/main.c
+++ b/src/main.c
@@ -241,7 +241,7 @@ static int process_options(int validate_only)
siz = validate_hostport_option(OPT_JAIL, 0);
if (siz && !validate_only) {
jl_siz = siz;
- jl_ctx = (jail_ctx **) calloc(siz, sizeof **jl_ctx);
+ jl_ctx = (jail_ctx **) calloc(siz, sizeof(jail_ctx));
assert(jl_ctx);
ol = NULL;
@@ -265,7 +265,7 @@ static int process_options(int validate_only)
siz = validate_hostport_option(OPT_PROTOCOL, 1);
if (siz && !validate_only) {
prt_siz = siz;
- prt_ctx = (protocol_ctx **) calloc(siz, sizeof **prt_ctx);
+ prt_ctx = (protocol_ctx **) calloc(siz, sizeof(protocol_ctx));
assert(prt_ctx);
ol = NULL;
@@ -290,7 +290,7 @@ static int process_options(int validate_only)
siz = validate_hostport_option(OPT_REDIRECT, 1);
if (siz && !validate_only) {
rdr_siz = siz;
- rdr_ctx = (redirector_ctx **) calloc(siz, sizeof **rdr_ctx);
+ rdr_ctx = (redirector_ctx **) calloc(siz, sizeof(redirector_ctx));
assert(rdr_ctx);
ol = NULL;
diff --git a/src/socket.c b/src/socket.c
index 4f271fe..5b37cf1 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -137,6 +137,8 @@ int socket_bind_in(psocket *psock, struct addrinfo **results)
finalise:
socket_freeaddr(results);
+ /* suppress coverity fals-positive: fd out of scope */
+ /* coverity[leaked_handle] */
return s;
}
@@ -209,6 +211,8 @@ int socket_connect_in(psocket *psock, struct addrinfo **results)
finalise:
socket_freeaddr(results);
+ /* suppress coverity fals-positive: fd out of scope */
+ /* coverity[leaked_handle] */
return s;
}
@@ -329,12 +333,15 @@ ssize_t socket_get_ifnames(const psocket *test_sock, char name[][IFNAMSIZ],
int socket_set_ifaddr(const psocket *test_sock,
const char *ifname, const char *addr, const char *mask)
{
- struct ifreq ifr = {0};
+ struct ifreq ifr;
int sock;
assert(test_sock);
+ memset(&ifr, 0, sizeof ifr);
sock = socket(test_sock->family, test_sock->socktype,
test_sock->protocol);
+ if (sock < 0)
+ return 1;
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
ifr.ifr_addr.sa_family = AF_INET;
@@ -345,6 +352,7 @@ int socket_set_ifaddr(const psocket *test_sock,
ioctl(sock, SIOCSIFNETMASK, &ifr);
ioctl(sock, SIOCGIFFLAGS, &ifr);
+ /* coverity[buffer_size_warning] */
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);