summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-12-24 02:24:30 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-12-24 02:24:30 +0100
commit39cad1bbbef547018ce231d307fcaab08c0aca28 (patch)
tree92784b8bb36fbfb7ba35855900ece938bf3aa9ab /src
parent960b06de85cc62c6187e6996b9253e34a1d7f68b (diff)
downloadfastd-39cad1bbbef547018ce231d307fcaab08c0aca28.tar
fastd-39cad1bbbef547018ce231d307fcaab08c0aca28.zip
Fix invalid memory accesses after failed resolves
Diffstat (limited to 'src')
-rw-r--r--src/fastd.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/fastd.c b/src/fastd.c
index c03a730..10fd0a3 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -407,8 +407,17 @@ static inline void update_time(fastd_context_t *ctx) {
clock_gettime(CLOCK_MONOTONIC, &ctx->now);
}
+static inline void no_valid_address_debug(fastd_context_t *ctx, const fastd_peer_t *peer) {
+ pr_debug(ctx, "not sending a handshake to %P (no valid address resolved)", peer);
+}
+
static void send_handshake(fastd_context_t *ctx, fastd_peer_t *peer) {
if (!fastd_peer_is_established(peer)) {
+ if (!peer->next_remote->n_addresses) {
+ no_valid_address_debug(ctx, peer);
+ return;
+ }
+
fastd_peer_claim_address(ctx, peer, NULL, NULL, &peer->next_remote->addresses[peer->next_remote->current_address]);
fastd_peer_reset_socket(ctx, peer);
}
@@ -417,7 +426,7 @@ static void send_handshake(fastd_context_t *ctx, fastd_peer_t *peer) {
return;
if (peer->address.sa.sa_family == AF_UNSPEC) {
- pr_debug(ctx, "not sending a handshake to %P (no valid address resolved)", peer);
+ no_valid_address_debug(ctx, peer);
return;
}