Skip to content

Commit d9612d9

Browse files
committed
Address more review comments
1 parent 362e90f commit d9612d9

5 files changed

Lines changed: 19 additions & 11 deletions

File tree

configure

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ int main(void) {
317317
return 0;
318318
}
319319
EOF
320-
if $CC -fsanitize=address _test.c -o _test 2>&3; then
320+
if $CC -fsanitize=address,undefined _test.c -o _test 2>&3; then
321321
echo "yes"
322322
echo "SANITIZEADDRESS= yes" >>$CONFIG_MK
323323
echo "CPPFLAGS+= -DASAN" >>$CONFIG_MK
@@ -614,7 +614,6 @@ fi
614614
if [ -z "$LINK_SRC" ]; then
615615
printf "Testing for netlink ... "
616616
cat << EOF >_netlink.c
617-
#include <asm/types.h>
618617
#include <linux/netlink.h>
619618
#include <linux/rtnetlink.h>
620619
#include <sys/socket.h>

src/netlink.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ netlink_link(struct link_ctx *lctx, struct nlmsghdr *nlm)
151151
loginfox("%s: interface has departed", ifp->if_name);
152152
else if (!(ifi->ifi_flags & IFF_UP))
153153
loginfox("%s: interface is down", ifp->if_name);
154-
else
155-
logerrx("%s: interface going away for no reason", ifp->if_name);
154+
156155
TAILQ_REMOVE(ctx->ctx_ifaces, ifp, if_next);
157156
if_free(ifp);
158157
return 0;
@@ -179,7 +178,11 @@ netlink_handle(void *arg, unsigned short e)
179178
.iov_len = sizeof(buf),
180179
};
181180

181+
#ifdef NDEBUG
182182
UNUSED(e);
183+
#else
184+
assert(e == ELE_READ);
185+
#endif
183186

184187
if (netlink_get(lctx, &iov, lctx->link_fd, MSG_DONTWAIT,
185188
netlink_dispatch) == -1)

src/priv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include "priv.h"
4444
#include "queue.h"
4545
#include "service.h"
46-
#include "src/eloop.h"
4746

4847
#define P_OPENBPF 1
4948
#define P_SENDBPF 2

src/route.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <net/if.h>
3131
#include <net/route.h>
3232

33+
#include <assert.h>
3334
#include <errno.h>
3435
#include <stddef.h>
3536
#include <stdlib.h>
@@ -114,9 +115,12 @@ route_dispatch(void *arg, unsigned short e)
114115
struct rtm rtm;
115116
ssize_t len;
116117

117-
if (e != ELE_READ) {
118-
logerrx("%s: unexpected event 0x%04x", __func__, e);
119-
}
118+
#ifdef NDEBUG
119+
UNUSED(e);
120+
#else
121+
assert(e == ELE_READ);
122+
#endif
123+
120124
len = read(lctx->link_fd, &rtm, sizeof(rtm));
121125
if (len == -1) {
122126
logerr("%s: read", __func__);

src/unpriv.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ unpriv_getifaddrs(struct srv_ctx *ctx, struct ifaddrs **ifahead,
9898
size_t rdata_len, len;
9999
int err;
100100

101-
err = srv_run(ctx, 0, U_GETIFADDRS, match_if_index,
101+
err = srv_run(ctx, NULL, U_GETIFADDRS, match_if_index,
102102
match_if_index != NULL ? sizeof(*match_if_index) : 0, &result,
103103
&rdata, &rdata_len);
104-
if (err == -1)
104+
if (err == -1 || result == -1)
105105
return -1;
106106

107107
/* Should be impossible - lo0 will always exist. */
@@ -258,11 +258,14 @@ unpriv_getaddrinfo(struct srv_ctx *ctx, const char *hostname,
258258
u_gai.u_gai_hints.u_ai_protocol = hints->ai_protocol;
259259
}
260260

261-
err = srv_run(ctx, 0, U_GETADDRINFO, &u_gai, sizeof(u_gai), &result,
261+
err = srv_run(ctx, NULL, U_GETADDRINFO, &u_gai, sizeof(u_gai), &result,
262262
&rdata, &rdata_len);
263263
if (err == -1)
264264
return -1;
265265

266+
if (result != 0)
267+
return (int)result;
268+
266269
for (u_ai = rdata; rdata_len != 0; rdata_len -= sizeof(*u_ai), u_ai++) {
267270
if (rdata_len < sizeof(*u_ai)) {
268271
logerrx("%s: ai_addrinfo truncated", __func__);

0 commit comments

Comments
 (0)