diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-04-21 22:42:42 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-05-08 18:52:55 +0200 |
commit | 5a877d1d7f3de5ba826a5d1f849fde7ec5f89827 (patch) | |
tree | 1bac3786600f281a5f09b5d360761b9f1440dd28 /sysdep | |
parent | f74539e0023430df6429a01187481cadc10d679f (diff) |
Wireguard: free sockets on error and eof
Diffstat (limited to 'sysdep')
-rw-r--r-- | sysdep/unix/wg_user.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sysdep/unix/wg_user.c b/sysdep/unix/wg_user.c index 49f6d89c..db92ea8e 100644 --- a/sysdep/unix/wg_user.c +++ b/sysdep/unix/wg_user.c @@ -54,9 +54,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 @@ -222,7 +220,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); @@ -235,7 +236,7 @@ wg_user_set_device(struct pool *pool, if (len < 0) { - /* FIXME close */ + rfree(sock); return -1; } res = sk_send(sock, tbsize - size); |