summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2020-04-21 22:42:42 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2021-01-12 23:34:17 +0100
commit99d15342327cdc1f9d6fb06ded4e77c3820df5e6 (patch)
treea36e60663b47473d79952b51d62db5ecac22402d
parent20a0499e37a2c00dc3355aa3ff4deee4b79ac9f7 (diff)
Wg-user: Free sockets on error and eof
-rw-r--r--sysdep/unix/wg_user.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sysdep/unix/wg_user.c b/sysdep/unix/wg_user.c
index 4668b2c6..5f5428bf 100644
--- a/sysdep/unix/wg_user.c
+++ b/sysdep/unix/wg_user.c
@@ -55,9 +55,7 @@ void user_err_hook(struct birdsock *bs, int err)
/* return; */
log(L_TRACE "WG: ERR %p %d %s", bs, err, bs->err);
- if (bs->fd >= 0)
- close(bs->fd);
- bs->fd = -1;
+ rfree(bs);
}
static void
@@ -223,7 +221,10 @@ wg_user_set_device(struct pool *pool,
int res = sk_connect_unix(sock, path);
DBG(L_TRACE "WG: socket %d %d %s", res, sock->fd, path);
if (res < 0)
- return -1;
+ {
+ rfree(sock);
+ return -1;
+ }
uint tbsize = 8192;
sk_set_tbsize(sock, tbsize);
@@ -236,7 +237,7 @@ wg_user_set_device(struct pool *pool,
if (len < 0)
{
- /* FIXME close */
+ rfree(sock);
return -1;
}
res = sk_send(sock, tbsize - size);