X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_setup.c;h=501fecd385770ada23842b4de74966157b1e4977;hp=17c042520c2056909e2a5a5190a7bd6a8ee6031f;hb=HEAD;hpb=3fae14fae5a347823679ef694ab630b4991a201d diff --git a/src/net_setup.c b/src/net_setup.c index 17c04252..501fecd3 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "avl_tree.h" #include "conf.h" @@ -48,18 +49,6 @@ char *myport; devops_t devops; -#ifndef HAVE_RSA_SET0_KEY -int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) { - BN_free(r->n); - r->n = n; - BN_free(r->e); - r->e = e; - BN_free(r->d); - r->d = d; - return 1; -} -#endif - bool read_rsa_public_key(connection_t *c) { FILE *fp; char *pubname; @@ -76,7 +65,7 @@ bool read_rsa_public_key(connection_t *c) { /* First, check for simple PublicKey statement */ if(get_config_string(lookup_config(c->config_tree, "PublicKey"), &key)) { - if(BN_hex2bn(&n, key) != strlen(key)) { + if((size_t)BN_hex2bn(&n, key) != strlen(key)) { free(key); logger(LOG_ERR, "Invalid PublicKey for %s!", c->name); return false; @@ -191,7 +180,7 @@ static bool read_rsa_private_key(void) { myself->connection->rsa_key = RSA_new(); // RSA_blinding_on(myself->connection->rsa_key, NULL); - if(BN_hex2bn(&d, key) != strlen(key)) { + if((size_t)BN_hex2bn(&d, key) != strlen(key)) { logger(LOG_ERR, "Invalid PrivateKey for myself!"); free(key); return false; @@ -205,7 +194,7 @@ static bool read_rsa_private_key(void) { return false; } - if(BN_hex2bn(&n, pubkey) != strlen(pubkey)) { + if((size_t)BN_hex2bn(&n, pubkey) != strlen(pubkey)) { free(pubkey); BN_free(d); logger(LOG_ERR, "Invalid PublicKey for myself!"); @@ -388,7 +377,7 @@ static bool setup_myself(void) { char *address = NULL; char *proxy = NULL; char *space; - char *envp[5] = {NULL}; + char *envp[5] = {0}; struct addrinfo *ai, *aip, hint = {0}; bool choice; int i, err; @@ -588,7 +577,7 @@ static bool setup_myself(void) { free(mode); } - choice = true; + choice = !(myself->options & OPTION_TCPONLY); get_config_bool(lookup_config(config_tree, "PMTUDiscovery"), &choice); if(choice) { @@ -852,9 +841,9 @@ static bool setup_myself(void) { } /* 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 @@ -1068,7 +1057,7 @@ bool setup_network(void) { void close_network_connections(void) { avl_node_t *node, *next; connection_t *c; - char *envp[5] = {NULL}; + char *envp[5] = {0}; int i; for(node = connection_tree->head; node; node = next) { @@ -1099,9 +1088,9 @@ void close_network_connections(void) { 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();