From daf3d6e8db9ef39b50dce040f864fb409bd7044a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 17 Apr 2013 21:42:22 +0200 Subject: Fix handling of the local address in shell commands Without this fix, using on-establish/disestablish/verify would cause a strange zero port when a bind with a random port was used, and a segmentation fault with dynamic binds. --- src/fastd.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/fastd.h') diff --git a/src/fastd.h b/src/fastd.h index 9b1191a..9736e08 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -142,6 +142,7 @@ struct fastd_bind_address { struct fastd_socket { int fd; const fastd_bind_address_t *addr; + fastd_peer_address_t *bound_addr; fastd_peer_t *peer; }; @@ -458,6 +459,11 @@ static inline void fastd_socket_close(fastd_context_t *ctx, fastd_socket_t *sock sock->fd = -2; } + + if (sock->bound_addr) { + free(sock->bound_addr); + sock->bound_addr = NULL; + } } static inline bool timespec_after(const struct timespec *tp1, const struct timespec *tp2) { -- cgit v1.2.3