Skip to content

Commit

Permalink
receive: fix buffer leak when receiving invalid packets
Browse files Browse the repository at this point in the history
For fastd versions before v20, this was just a memory leak (which could
still be used for DoS, as it's remotely triggerable). With the new
buffer management of fastd v20, this will trigger an assertion failure
instead as soon as the buffer pool is empty.
  • Loading branch information
neocturne committed Oct 19, 2020
1 parent 0442abc commit 7379251
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ static inline void handle_socket_receive_known(

case PACKET_HANDSHAKE:
fastd_handshake_handle(sock, local_addr, remote_addr, peer, buffer);
break;

default:
fastd_buffer_free(buffer);
pr_debug("received packet with invalid type from %P[%I]", peer, remote_addr);
}
}

Expand All @@ -195,6 +200,11 @@ static inline void handle_socket_receive_unknown(

case PACKET_HANDSHAKE:
fastd_handshake_handle(sock, local_addr, remote_addr, NULL, buffer);
break;

default:
fastd_buffer_free(buffer);
pr_debug("received packet with invalid type from unknown address %I", remote_addr);
}
}

Expand Down

0 comments on commit 7379251

Please sign in to comment.