}
bool get_config_subnet(const config_t *cfg, subnet_t **result) {
- subnet_t subnet = {};
+ subnet_t subnet = {0};
if(!cfg) {
return false;
// And we try to read the ones that end with ".conf"
if(l > 5 && !strcmp(".conf", & ep->d_name[ l - 5 ])) {
- if(snprintf(fname, sizeof(fname), "%s/%s", dname, ep->d_name) >= sizeof(fname)) {
+ if((size_t)snprintf(fname, sizeof(fname), "%s/%s", dname, ep->d_name) >= sizeof(fname)) {
logger(LOG_ERR, "Pathname too long: %s/%s", dname, ep->d_name);
return false;
}
/* The directory is a relative path or a filename. */
getcwd(directory, sizeof(directory));
- if(snprintf(abspath, sizeof(abspath), "%s/%s", directory, fn) >= sizeof(abspath)) {
+ if((size_t)snprintf(abspath, sizeof(abspath), "%s/%s", directory, fn) >= sizeof(abspath)) {
fprintf(stderr, "Pathname too long: %s/%s\n", directory, fn);
return NULL;
}
n->mtuevent = NULL;
}
- xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
- xasprintf(&envp[1], "DEVICE=%s", device ? : "");
- xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
+ xasprintf(&envp[0], "NETNAME=%s", netname ? netname : "");
+ xasprintf(&envp[1], "DEVICE=%s", device ? device : "");
+ xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : "");
xasprintf(&envp[3], "NODE=%s", n->name);
sockaddr2str(&n->address, &address, &port);
xasprintf(&envp[4], "REMOTEADDRESS=%s", address);
pits[next_pit++] = fd;
- if(next_pit >= sizeof pits / sizeof pits[0]) {
+ if(next_pit >= (int)(sizeof pits / sizeof pits[0])) {
next_pit = 0;
}
}
char *address = NULL;
char *proxy = NULL;
char *space;
- char *envp[5] = {};
- struct addrinfo *ai, *aip, hint = {};
+ char *envp[5] = {0};
+ struct addrinfo *ai, *aip, hint = {0};
bool choice;
int i, err;
int replaywin_int;
}
/* Run tinc-up script to further initialize the tap interface */
- xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
- xasprintf(&envp[1], "DEVICE=%s", device ? : "");
- xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
+ xasprintf(&envp[0], "NETNAME=%s", netname ? netname : "");
+ xasprintf(&envp[1], "DEVICE=%s", device ? device : "");
+ xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : "");
xasprintf(&envp[3], "NAME=%s", myself->name);
#ifdef HAVE_MINGW
void close_network_connections(void) {
avl_node_t *node, *next;
connection_t *c;
- char *envp[5] = {};
+ char *envp[5] = {0};
int i;
for(node = connection_tree->head; node; node = next) {
close(listen_socket[i].udp);
}
- xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
- xasprintf(&envp[1], "DEVICE=%s", device ? : "");
- xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
+ xasprintf(&envp[0], "NETNAME=%s", netname ? netname : "");
+ xasprintf(&envp[1], "DEVICE=%s", device ? device : "");
+ xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : "");
xasprintf(&envp[3], "NAME=%s", myself->name);
exit_requests();
Return NULL on failure.
*/
struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype) {
- struct addrinfo *ai = NULL, hint = {};
+ struct addrinfo *ai = NULL, hint = {0};
int err;
hint.ai_family = addressfamily;
}
sockaddr_t str2sockaddr(const char *address, const char *port) {
- struct addrinfo *ai = NULL, hint = {};
+ struct addrinfo *ai = NULL, hint = {0};
sockaddr_t result;
int err;
}
node_t *lookup_node(char *name) {
- node_t n = {};
+ node_t n = {0};
n.name = name;
}
node_t *lookup_node_udp(const sockaddr_t *sa) {
- node_t n = {};
+ node_t n = {0};
n.address = *sa;
n.name = NULL;
}
bool seen_request(char *request) {
- past_request_t *new, p = {};
+ past_request_t *new, p = {0};
p.request = request;
char subnetstr[MAX_STRING_SIZE];
char name[MAX_STRING_SIZE];
node_t *owner;
- subnet_t s = {}, *new, *old;
+ subnet_t s = {0}, *new, *old;
if(sscanf(c->buffer, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) {
logger(LOG_ERR, "Got bad %s from %s (%s)", "ADD_SUBNET", c->name,
char subnetstr[MAX_STRING_SIZE];
char name[MAX_STRING_SIZE];
node_t *owner;
- subnet_t s = {}, *find;
+ subnet_t s = {0}, *find;
if(sscanf(c->buffer, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) {
logger(LOG_ERR, "Got bad %s from %s (%s)", "DEL_SUBNET", c->name,
/* RFC 792 */
static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, length_t ether_size, uint8_t type, uint8_t code) {
- struct ip ip = {};
- struct icmp icmp = {};
+ struct ip ip = {0};
+ struct icmp icmp = {0};
struct in_addr ip_src;
struct in_addr ip_dst;
static void route_ipv6_unreachable(node_t *source, vpn_packet_t *packet, length_t ether_size, uint8_t type, uint8_t code) {
struct ip6_hdr ip6;
- struct icmp6_hdr icmp6 = {};
+ struct icmp6_hdr icmp6 = {0};
uint16_t checksum;
struct {
}
if(!subnet->owner->status.reachable) {
- return route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_UNREACH);
+ route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_UNREACH);
+ return;
}
if(forwarding_mode == FMODE_OFF && source != myself && subnet->owner != myself) {
- return route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_ANO);
+ route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_ANO);
+ return;
}
if(decrement_ttl && source != myself && subnet->owner != myself)
}
if(directonly && subnet->owner != via) {
- return route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_ANO);
+ route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_ANO);
+ return;
}
if(via && packet->len > MAX(via->mtu, 590) && via != myself) {
}
if(!subnet->owner->status.reachable) {
- return route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOROUTE);
+ route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOROUTE);
+ return;
}
if(forwarding_mode == FMODE_OFF && source != myself && subnet->owner != myself) {
- return route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN);
+ route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN);
+ return;
}
- if(decrement_ttl && source != myself && subnet->owner != myself)
+ if(decrement_ttl && source != myself && subnet->owner != myself) {
if(!do_decrement_ttl(source, packet)) {
return;
}
+ }
if(priorityinheritance) {
packet->priority = ((packet->data[14] & 0x0f) << 4) | (packet->data[15] >> 4);
}
if(directonly && subnet->owner != via) {
- return route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN);
+ route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN);
+ return;
}
if(via && packet->len > MAX(via->mtu, 1294) && via != myself) {
bool net2str(char *netstr, int len, const subnet_t *subnet) {
if(!netstr || !subnet) {
- logger(LOG_ERR, "net2str() was called with netstr=%p, subnet=%p!", netstr, subnet);
+ logger(LOG_ERR, "net2str() was called with netstr=%p, subnet=%p!", (void *)netstr, (void *)subnet);
return false;
}
// Prepare environment variables to be passed to the script
- xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
- xasprintf(&envp[1], "DEVICE=%s", device ? : "");
- xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
+ xasprintf(&envp[0], "NETNAME=%s", netname ? netname : "");
+ xasprintf(&envp[1], "DEVICE=%s", device ? device : "");
+ xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : "");
xasprintf(&envp[3], "NODE=%s", owner->name);
xasprintf(&envp[4], "NAME=%s", myself->name);