/*
net_setup.c -- Setup.
Copyright (C) 1998-2005 Ivo Timmermans,
- 2000-2016 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2017 Guus Sliepen <guus@tinc-vpn.org>
2006 Scott Lamb <slamb@slamb.org>
2010 Brandon Black <blblack@gmail.com>
free(name);
return false;
}
- if(gethostname(hostname, sizeof hostname) || !*hostname) {
+ if(gethostname(hostname, sizeof(hostname)) || !*hostname) {
fprintf(stderr, "Could not get hostname: %s\n", strerror(errno));
free(name);
return false;
/* We need to use a stream mode for the meta protocol. Use AES for this,
but try to match the key size with the one from the cipher selected
by Cipher.
+
+ If Cipher is set to none, still use a low level of encryption for the
+ meta protocol.
*/
- int keylen = EVP_CIPHER_key_length(myself->incipher);
+ int keylen = myself->incipher ? EVP_CIPHER_key_length(myself->incipher) : 0;
if(keylen <= 16)
myself->connection->outcipher = EVP_aes_128_cfb();
else if(keylen <= 24)
}
for(i = 0; i < listen_sockets; i++) {
- salen = sizeof sa;
+ salen = sizeof(sa);
if(getsockname(i + 3, &sa.sa, &salen) < 0) {
logger(LOG_ERR, "Could not get address of listen fd %d: %s", i + 3, sockstrerror(errno));
return false;
if(!port_specified) {
sockaddr_t sa;
- socklen_t salen = sizeof sa;
+ socklen_t salen = sizeof(sa);
if(!getsockname(listen_socket[0].udp, &sa.sa, &salen)) {
free(myport);
sockaddr2str(&sa, NULL, &myport);