summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fastd.c7
-rw-r--r--src/protocol_ec25519_fhmqvc.c12
2 files changed, 7 insertions, 12 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 6cfa442..fa6ea65 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -981,9 +981,12 @@ static inline void handle_socket_receive(fastd_context_t *ctx, fastd_socket_t *s
fastd_peer_t *peer = NULL;
if (sock->peer) {
- if (fastd_peer_address_equal(&sock->peer->address, remote_addr)) {
- peer = sock->peer;
+ if (!fastd_peer_address_equal(&sock->peer->address, remote_addr)) {
+ fastd_buffer_free(buffer);
+ return;
}
+
+ peer = sock->peer;
}
else {
for (peer = ctx->peers; peer; peer = peer->next) {
diff --git a/src/protocol_ec25519_fhmqvc.c b/src/protocol_ec25519_fhmqvc.c
index 9e7174b..87eedef 100644
--- a/src/protocol_ec25519_fhmqvc.c
+++ b/src/protocol_ec25519_fhmqvc.c
@@ -569,16 +569,8 @@ static fastd_peer_t* find_sender_key(fastd_context_t *ctx, const fastd_peer_addr
static fastd_peer_t* match_sender_key(fastd_context_t *ctx, const fastd_socket_t *sock, const fastd_peer_address_t *address, fastd_peer_t *peer, const unsigned char key[32]) {
errno = 0;
- if (sock->peer) {
- if (peer != sock->peer) {
- if (peer && !fastd_peer_is_floating(peer) && !fastd_peer_is_dynamic(peer)) {
- errno = EPERM;
- return NULL;
- }
-
- peer = sock->peer;
- }
- }
+ if (sock->peer && peer != sock->peer)
+ exit_bug(ctx, "packet without correct peer set on dynamic socket");
if (peer) {
if (memcmp(peer->protocol_config->public_key.p, key, PUBLICKEYBYTES) == 0) {