From de3da7a6e42478f9092c82cd8b767a5c93730e84 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 30 Aug 2012 01:27:34 +0200 Subject: Fix minimum packet size --- ffvisd/ffvisd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ffvisd') diff --git a/ffvisd/ffvisd.c b/ffvisd/ffvisd.c index d1b36f0..93e9b1b 100644 --- a/ffvisd/ffvisd.c +++ b/ffvisd/ffvisd.c @@ -462,7 +462,8 @@ static void send_announcement(const char *ifname, unsigned ifindex, void *arg) { sa.sll_halen = ETH_ALEN; memcpy(sa.sll_addr, ffd_addr.address, ETH_ALEN); - sendto(sockfd, packet, sizeof(ffvisd_packet_announce_t) + ntohs(packet->n_servers)*sizeof(ffvisd_packet_server_announce_t), 0, (struct sockaddr*)&sa, sizeof(sa)); + unsigned len = sizeof(ffvisd_packet_announce_t) + ntohs(packet->n_servers)*sizeof(ffvisd_packet_server_announce_t); + sendto(sockfd, packet, len > 46 ? len : 46, 0, (struct sockaddr*)&sa, sizeof(sa)); } free(if_mesh); } @@ -470,6 +471,8 @@ static void send_announcement(const char *ifname, unsigned ifindex, void *arg) { static void send_announcements() { ffvisd_packet_announce_t *packet = alloca(sizeof(ffvisd_packet_announce_t) + 75*sizeof(ffvisd_packet_server_announce_t)); + memset(packet, 0, 46); /* minimum ethernet packet size is 46 bytes */ + packet->magic = htons(FFD_MAGIC); packet->version = htons(FFVISD_VERSION); packet->csum = 0; -- cgit v1.2.3