diff options
Diffstat (limited to 'ffvisd')
-rw-r--r-- | ffvisd/ffvisd.c | 5 |
1 files changed, 4 insertions, 1 deletions
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; |