X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fmulticast_device.c;h=ea43e2c04a6efbaf4abb555ea97b098ce5fd9fe6;hp=99fafcc87f50eae4bac1e36a5441f83b2fe601df;hb=8fce1eacd7fd7496a740be3ffc236fde37c681d7;hpb=fb5fcc575d25a51acf73d476f63ce72f30cda6c2 diff --git a/src/multicast_device.c b/src/multicast_device.c index 99fafcc8..ea43e2c0 100644 --- a/src/multicast_device.c +++ b/src/multicast_device.c @@ -1,7 +1,7 @@ /* device.c -- multicast socket Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2013 Guus Sliepen + 2002-2014 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -56,6 +56,7 @@ static bool setup_device(void) { space = strchr(host, ' '); if(!space) { logger(LOG_ERR, "Port number required for %s", device_info); + free(host); return false; } @@ -75,6 +76,7 @@ static bool setup_device(void) { device_fd = socket(ai->ai_family, SOCK_DGRAM, IPPROTO_UDP); if(device_fd < 0) { logger(LOG_ERR, "Creating socket failed: %s", sockstrerror(sockerrno)); + free(host); return false; } @@ -88,6 +90,7 @@ static bool setup_device(void) { if(bind(device_fd, ai->ai_addr, ai->ai_addrlen)) { closesocket(device_fd); logger(LOG_ERR, "Can't bind to %s %s: %s", host, port, sockstrerror(sockerrno)); + free(host); return false; } @@ -102,6 +105,7 @@ static bool setup_device(void) { if(setsockopt(device_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof mreq)) { logger(LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno)); closesocket(device_fd); + free(host); return false; } #ifdef IP_MULTICAST_LOOP @@ -123,6 +127,7 @@ static bool setup_device(void) { if(setsockopt(device_fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, (void *)&mreq, sizeof mreq)) { logger(LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno)); closesocket(device_fd); + free(host); return false; } #ifdef IPV6_MULTICAST_LOOP @@ -135,11 +140,13 @@ static bool setup_device(void) { #endif default: - logger(LOG_ERR, "Multicast for address family %hx unsupported", ai->ai_family); + logger(LOG_ERR, "Multicast for address family %x unsupported", ai->ai_family); closesocket(device_fd); + free(host); return false; } + free(host); logger(LOG_INFO, "%s is a %s", device, device_info); return true;