summaryrefslogtreecommitdiffstats
path: root/src/fastd.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-04-22 14:08:33 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-04-22 14:08:33 +0200
commitadaedb9299c77e18150b685a96d51b1ce67ec423 (patch)
treeedf42edefb24dcace8a133bcf85220de8f007600 /src/fastd.c
parent7b8a9acd7a3a31f5d393c1632d68379f8353e7d1 (diff)
downloadfastd-adaedb9299c77e18150b685a96d51b1ce67ec423.tar
fastd-adaedb9299c77e18150b685a96d51b1ce67ec423.zip
Miscellaneous fixes in ethernet address handling
Check the length of ethernet frames, and the fastd_eth_addr_t structure must be packed.
Diffstat (limited to 'src/fastd.c')
-rw-r--r--src/fastd.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 70bd99e..1f606c0 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -602,6 +602,12 @@ void fastd_send_handshake(fastd_context_t *ctx, const fastd_socket_t *sock, cons
void fastd_handle_receive(fastd_context_t *ctx, fastd_peer_t *peer, fastd_buffer_t buffer) {
if (ctx->conf->mode == MODE_TAP) {
+ if (buffer.len < ETH_HLEN) {
+ pr_debug(ctx, "received truncated packet");
+ fastd_buffer_free(buffer);
+ return;
+ }
+
const fastd_eth_addr_t *src_addr = fastd_get_source_address(ctx, buffer);
if (fastd_eth_addr_is_unicast(src_addr))
@@ -841,6 +847,12 @@ static void handle_tun(fastd_context_t *ctx) {
fastd_peer_t *peer = NULL;
if (ctx->conf->mode == MODE_TAP) {
+ if (buffer.len < ETH_HLEN) {
+ pr_debug(ctx, "truncated packet on tap interface");
+ fastd_buffer_free(buffer);
+ return;
+ }
+
const fastd_eth_addr_t *dest_addr = fastd_get_dest_address(ctx, buffer);
if (fastd_eth_addr_is_unicast(dest_addr)) {
peer = fastd_peer_find_by_eth_addr(ctx, dest_addr);