mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Run our #else/#endif annotator on our source code.
This commit is contained in:
parent
7a597718bb
commit
c1deabd3b0
@ -33,7 +33,7 @@
|
|||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@ -198,7 +198,7 @@ tor_sockaddr_to_str(const struct sockaddr *sa)
|
|||||||
tor_asprintf(&result, "unix:%s", s_un->sun_path);
|
tor_asprintf(&result, "unix:%s", s_un->sun_path);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_SYS_UN_H) */
|
||||||
if (sa->sa_family == AF_UNSPEC)
|
if (sa->sa_family == AF_UNSPEC)
|
||||||
return tor_strdup("unspec");
|
return tor_strdup("unspec");
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ tor_addr_lookup,(const char *name, uint16_t family, tor_addr_t *addr))
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return (err == EAI_AGAIN) ? 1 : -1;
|
return (err == EAI_AGAIN) ? 1 : -1;
|
||||||
#else
|
#else /* !(defined(HAVE_GETADDRINFO)) */
|
||||||
struct hostent *ent;
|
struct hostent *ent;
|
||||||
int err;
|
int err;
|
||||||
#ifdef HAVE_GETHOSTBYNAME_R_6_ARG
|
#ifdef HAVE_GETHOSTBYNAME_R_6_ARG
|
||||||
@ -330,7 +330,7 @@ tor_addr_lookup,(const char *name, uint16_t family, tor_addr_t *addr))
|
|||||||
#else
|
#else
|
||||||
err = h_errno;
|
err = h_errno;
|
||||||
#endif
|
#endif
|
||||||
#endif /* endif HAVE_GETHOSTBYNAME_R_6_ARG. */
|
#endif /* defined(HAVE_GETHOSTBYNAME_R_6_ARG) || ... */
|
||||||
if (ent) {
|
if (ent) {
|
||||||
if (ent->h_addrtype == AF_INET) {
|
if (ent->h_addrtype == AF_INET) {
|
||||||
tor_addr_from_in(addr, (struct in_addr*) ent->h_addr);
|
tor_addr_from_in(addr, (struct in_addr*) ent->h_addr);
|
||||||
@ -346,7 +346,7 @@ tor_addr_lookup,(const char *name, uint16_t family, tor_addr_t *addr))
|
|||||||
#else
|
#else
|
||||||
return (err == TRY_AGAIN) ? 1 : -1;
|
return (err == TRY_AGAIN) ? 1 : -1;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(HAVE_GETADDRINFO) */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1409,7 +1409,7 @@ get_interface_addresses_ifaddrs(int severity, sa_family_t family)
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_IFADDRS_TO_SMARTLIST) */
|
||||||
|
|
||||||
#ifdef HAVE_IP_ADAPTER_TO_SMARTLIST
|
#ifdef HAVE_IP_ADAPTER_TO_SMARTLIST
|
||||||
|
|
||||||
@ -1500,7 +1500,7 @@ get_interface_addresses_win32(int severity, sa_family_t family)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* defined(HAVE_IP_ADAPTER_TO_SMARTLIST) */
|
||||||
|
|
||||||
#ifdef HAVE_IFCONF_TO_SMARTLIST
|
#ifdef HAVE_IFCONF_TO_SMARTLIST
|
||||||
|
|
||||||
@ -1602,7 +1602,7 @@ get_interface_addresses_ioctl(int severity, sa_family_t family)
|
|||||||
tor_free(ifc.ifc_buf);
|
tor_free(ifc.ifc_buf);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_IFCONF_TO_SMARTLIST) */
|
||||||
|
|
||||||
/** Try to ask our network interfaces what addresses they are bound to.
|
/** Try to ask our network interfaces what addresses they are bound to.
|
||||||
* Return a new smartlist of tor_addr_t on success, and NULL on failure.
|
* Return a new smartlist of tor_addr_t on success, and NULL on failure.
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO win32 specific includes
|
// TODO win32 specific includes
|
||||||
#endif // ADDRESS_PRIVATE
|
#endif /* defined(ADDRESS_PRIVATE) */
|
||||||
|
|
||||||
/** The number of bits from an address to consider while doing a masked
|
/** The number of bits from an address to consider while doing a masked
|
||||||
* comparison. */
|
* comparison. */
|
||||||
@ -358,23 +358,23 @@ STATIC smartlist_t *ifaddrs_to_smartlist(const struct ifaddrs *ifa,
|
|||||||
sa_family_t family);
|
sa_family_t family);
|
||||||
STATIC smartlist_t *get_interface_addresses_ifaddrs(int severity,
|
STATIC smartlist_t *get_interface_addresses_ifaddrs(int severity,
|
||||||
sa_family_t family);
|
sa_family_t family);
|
||||||
#endif
|
#endif /* defined(HAVE_IFADDRS_TO_SMARTLIST) */
|
||||||
|
|
||||||
#ifdef HAVE_IP_ADAPTER_TO_SMARTLIST
|
#ifdef HAVE_IP_ADAPTER_TO_SMARTLIST
|
||||||
STATIC smartlist_t *ip_adapter_addresses_to_smartlist(
|
STATIC smartlist_t *ip_adapter_addresses_to_smartlist(
|
||||||
const IP_ADAPTER_ADDRESSES *addresses);
|
const IP_ADAPTER_ADDRESSES *addresses);
|
||||||
STATIC smartlist_t *get_interface_addresses_win32(int severity,
|
STATIC smartlist_t *get_interface_addresses_win32(int severity,
|
||||||
sa_family_t family);
|
sa_family_t family);
|
||||||
#endif
|
#endif /* defined(HAVE_IP_ADAPTER_TO_SMARTLIST) */
|
||||||
|
|
||||||
#ifdef HAVE_IFCONF_TO_SMARTLIST
|
#ifdef HAVE_IFCONF_TO_SMARTLIST
|
||||||
STATIC smartlist_t *ifreq_to_smartlist(char *ifr,
|
STATIC smartlist_t *ifreq_to_smartlist(char *ifr,
|
||||||
size_t buflen);
|
size_t buflen);
|
||||||
STATIC smartlist_t *get_interface_addresses_ioctl(int severity,
|
STATIC smartlist_t *get_interface_addresses_ioctl(int severity,
|
||||||
sa_family_t family);
|
sa_family_t family);
|
||||||
#endif
|
#endif /* defined(HAVE_IFCONF_TO_SMARTLIST) */
|
||||||
|
|
||||||
#endif // ADDRESS_PRIVATE
|
#endif /* defined(ADDRESS_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_ADDRESS_H) */
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ ENABLE_GCC_WARNING(redundant-decls)
|
|||||||
|
|
||||||
#define USE_EVP_AES_CTR
|
#define USE_EVP_AES_CTR
|
||||||
|
|
||||||
#endif
|
#endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_V_NOPATCH(1,1,0) || ... */
|
||||||
|
|
||||||
/* We have 2 strategies for getting the AES block cipher: Via OpenSSL's
|
/* We have 2 strategies for getting the AES block cipher: Via OpenSSL's
|
||||||
* AES_encrypt function, or via OpenSSL's EVP_EncryptUpdate function.
|
* AES_encrypt function, or via OpenSSL's EVP_EncryptUpdate function.
|
||||||
@ -142,7 +142,7 @@ evaluate_ctr_for_aes(void)
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(USE_EVP_AES_CTR)) */
|
||||||
|
|
||||||
/*======================================================================*/
|
/*======================================================================*/
|
||||||
/* Interface to AES code, and counter implementation */
|
/* Interface to AES code, and counter implementation */
|
||||||
@ -163,7 +163,7 @@ struct aes_cnt_cipher {
|
|||||||
uint32_t counter2;
|
uint32_t counter2;
|
||||||
uint32_t counter1;
|
uint32_t counter1;
|
||||||
uint32_t counter0;
|
uint32_t counter0;
|
||||||
#endif
|
#endif /* !defined(WORDS_BIGENDIAN) */
|
||||||
|
|
||||||
union {
|
union {
|
||||||
/** The counter, in big-endian order, as bytes. */
|
/** The counter, in big-endian order, as bytes. */
|
||||||
@ -212,7 +212,7 @@ evaluate_evp_for_aes(int force_val)
|
|||||||
log_info(LD_CRYPTO, "No AES engine found; using AES_* functions.");
|
log_info(LD_CRYPTO, "No AES engine found; using AES_* functions.");
|
||||||
should_use_EVP = 0;
|
should_use_EVP = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(DISABLE_ENGINES) */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -312,7 +312,7 @@ aes_set_key(aes_cnt_cipher_t *cipher, const uint8_t *key, int key_bits)
|
|||||||
cipher->counter1 = 0;
|
cipher->counter1 = 0;
|
||||||
cipher->counter2 = 0;
|
cipher->counter2 = 0;
|
||||||
cipher->counter3 = 0;
|
cipher->counter3 = 0;
|
||||||
#endif
|
#endif /* defined(USING_COUNTER_VARS) */
|
||||||
|
|
||||||
memset(cipher->ctr_buf.buf, 0, sizeof(cipher->ctr_buf.buf));
|
memset(cipher->ctr_buf.buf, 0, sizeof(cipher->ctr_buf.buf));
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ aes_cipher_free(aes_cnt_cipher_t *cipher)
|
|||||||
STMT_END
|
STMT_END
|
||||||
#else
|
#else
|
||||||
#define UPDATE_CTR_BUF(c, n)
|
#define UPDATE_CTR_BUF(c, n)
|
||||||
#endif
|
#endif /* defined(USING_COUNTER_VARS) */
|
||||||
|
|
||||||
/* Helper function to use EVP with openssl's counter-mode wrapper. */
|
/* Helper function to use EVP with openssl's counter-mode wrapper. */
|
||||||
static void
|
static void
|
||||||
@ -396,10 +396,10 @@ aes_set_iv(aes_cnt_cipher_t *cipher, const uint8_t *iv)
|
|||||||
cipher->counter2 = ntohl(get_uint32(iv+4));
|
cipher->counter2 = ntohl(get_uint32(iv+4));
|
||||||
cipher->counter1 = ntohl(get_uint32(iv+8));
|
cipher->counter1 = ntohl(get_uint32(iv+8));
|
||||||
cipher->counter0 = ntohl(get_uint32(iv+12));
|
cipher->counter0 = ntohl(get_uint32(iv+12));
|
||||||
#endif
|
#endif /* defined(USING_COUNTER_VARS) */
|
||||||
cipher->pos = 0;
|
cipher->pos = 0;
|
||||||
memcpy(cipher->ctr_buf.buf, iv, 16);
|
memcpy(cipher->ctr_buf.buf, iv, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* defined(USE_EVP_AES_CTR) */
|
||||||
|
|
||||||
|
@ -23,5 +23,5 @@ void aes_crypt_inplace(aes_cnt_cipher_t *cipher, char *data, size_t len);
|
|||||||
int evaluate_evp_for_aes(int force_value);
|
int evaluate_evp_for_aes(int force_value);
|
||||||
int evaluate_ctr_for_aes(void);
|
int evaluate_ctr_for_aes(void);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_AES_H) */
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <sys/ucontext.h>
|
#include <sys/ucontext.h>
|
||||||
#elif defined(HAVE_UCONTEXT_H)
|
#elif defined(HAVE_UCONTEXT_H)
|
||||||
#include <ucontext.h>
|
#include <ucontext.h>
|
||||||
#endif
|
#endif /* defined(HAVE_CYGWIN_SIGNAL_H) || ... */
|
||||||
|
|
||||||
#define EXPOSE_CLEAN_BACKTRACE
|
#define EXPOSE_CLEAN_BACKTRACE
|
||||||
#include "backtrace.h"
|
#include "backtrace.h"
|
||||||
@ -81,16 +81,16 @@ clean_backtrace(void **stack, size_t depth, const ucontext_t *ctx)
|
|||||||
const size_t n = 2;
|
const size_t n = 2;
|
||||||
#else
|
#else
|
||||||
const size_t n = 1;
|
const size_t n = 1;
|
||||||
#endif
|
#endif /* defined(__linux__) || ... */
|
||||||
if (depth <= n)
|
if (depth <= n)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stack[n] = (void*) ctx->PC_FROM_UCONTEXT;
|
stack[n] = (void*) ctx->PC_FROM_UCONTEXT;
|
||||||
#else
|
#else /* !(defined(PC_FROM_UCONTEXT)) */
|
||||||
(void) depth;
|
(void) depth;
|
||||||
(void) ctx;
|
(void) ctx;
|
||||||
(void) stack;
|
(void) stack;
|
||||||
#endif
|
#endif /* defined(PC_FROM_UCONTEXT) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Log a message <b>msg</b> at <b>severity</b> in <b>domain</b>, and follow
|
/** Log a message <b>msg</b> at <b>severity</b> in <b>domain</b>, and follow
|
||||||
@ -202,7 +202,7 @@ remove_bt_handler(void)
|
|||||||
{
|
{
|
||||||
tor_mutex_uninit(&cb_buf_mutex);
|
tor_mutex_uninit(&cb_buf_mutex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(USE_BACKTRACE) */
|
||||||
|
|
||||||
#ifdef NO_BACKTRACE_IMPL
|
#ifdef NO_BACKTRACE_IMPL
|
||||||
void
|
void
|
||||||
@ -221,7 +221,7 @@ static void
|
|||||||
remove_bt_handler(void)
|
remove_bt_handler(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(NO_BACKTRACE_IMPL) */
|
||||||
|
|
||||||
/** Set up code to handle generating error messages on crashes. */
|
/** Set up code to handle generating error messages on crashes. */
|
||||||
int
|
int
|
||||||
|
@ -15,7 +15,7 @@ void clean_up_backtrace_handler(void);
|
|||||||
defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION)
|
defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION)
|
||||||
void clean_backtrace(void **stack, size_t depth, const ucontext_t *ctx);
|
void clean_backtrace(void **stack, size_t depth, const ucontext_t *ctx);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(EXPOSE_CLEAN_BACKTRACE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_BACKTRACE_H) */
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#define check() STMT_BEGIN buf_assert_ok(buf); STMT_END
|
#define check() STMT_BEGIN buf_assert_ok(buf); STMT_END
|
||||||
#else
|
#else
|
||||||
#define check() STMT_NIL
|
#define check() STMT_NIL
|
||||||
#endif
|
#endif /* defined(PARANOIA) */
|
||||||
|
|
||||||
/* Implementation notes:
|
/* Implementation notes:
|
||||||
*
|
*
|
||||||
@ -98,7 +98,7 @@
|
|||||||
DBG_S(tor_assert(a == b)); \
|
DBG_S(tor_assert(a == b)); \
|
||||||
memset(a,0,SENTINEL_LEN); \
|
memset(a,0,SENTINEL_LEN); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif /* defined(DISABLE_MEMORY_SENTINELS) */
|
||||||
|
|
||||||
/** Move all bytes stored in <b>chunk</b> to the front of <b>chunk</b>->mem,
|
/** Move all bytes stored in <b>chunk</b> to the front of <b>chunk</b>->mem,
|
||||||
* to free up space at the end. */
|
* to free up space at the end. */
|
||||||
@ -311,7 +311,7 @@ buf_new_with_data(const char *cp, size_t sz)
|
|||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/** Remove the first <b>n</b> bytes from buf. */
|
/** Remove the first <b>n</b> bytes from buf. */
|
||||||
void
|
void
|
||||||
|
@ -119,7 +119,7 @@ CHUNK_WRITE_PTR(chunk_t *chunk)
|
|||||||
return chunk->data + chunk->datalen;
|
return chunk->data + chunk->datalen;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* defined(BUFFERS_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_BUFFERS_H) */
|
||||||
|
|
||||||
|
@ -15,5 +15,5 @@ int buf_read_from_tls(struct buf_t *buf,
|
|||||||
int buf_flush_to_tls(struct buf_t *buf, struct tor_tls_t *tls,
|
int buf_flush_to_tls(struct buf_t *buf, struct tor_tls_t *tls,
|
||||||
size_t sz, size_t *buf_flushlen);
|
size_t sz, size_t *buf_flushlen);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_BUFFERS_TLS_H) */
|
||||||
|
|
||||||
|
@ -88,12 +88,12 @@ SecureZeroMemory(PVOID ptr, SIZE_T cnt)
|
|||||||
while (cnt--)
|
while (cnt--)
|
||||||
*vcptr++ = 0;
|
*vcptr++ = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_DECL_SECUREZEROMEMORY) && !HAVE_DECL_SECUREZEROMEMORY */
|
||||||
#elif defined(HAVE_READPASSPHRASE_H)
|
#elif defined(HAVE_READPASSPHRASE_H)
|
||||||
#include <readpassphrase.h>
|
#include <readpassphrase.h>
|
||||||
#else
|
#else
|
||||||
#include "tor_readpassphrase.h"
|
#include "tor_readpassphrase.h"
|
||||||
#endif
|
#endif /* defined(_WIN32) || ... */
|
||||||
|
|
||||||
/* Includes for the process attaching prevention */
|
/* Includes for the process attaching prevention */
|
||||||
#if defined(HAVE_SYS_PRCTL_H) && defined(__linux__)
|
#if defined(HAVE_SYS_PRCTL_H) && defined(__linux__)
|
||||||
@ -102,7 +102,7 @@ SecureZeroMemory(PVOID ptr, SIZE_T cnt)
|
|||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
#endif
|
#endif /* defined(HAVE_SYS_PRCTL_H) && defined(__linux__) || ... */
|
||||||
|
|
||||||
#ifdef HAVE_NETDB_H
|
#ifdef HAVE_NETDB_H
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
@ -161,7 +161,7 @@ tor_open_cloexec(const char *path, int flags, unsigned mode)
|
|||||||
* are running on one without. */
|
* are running on one without. */
|
||||||
if (errno != EINVAL)
|
if (errno != EINVAL)
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif /* defined(O_CLOEXEC) */
|
||||||
|
|
||||||
log_debug(LD_FS, "Opening %s with flags %x", p, flags);
|
log_debug(LD_FS, "Opening %s with flags %x", p, flags);
|
||||||
fd = open(p, flags, mode);
|
fd = open(p, flags, mode);
|
||||||
@ -173,7 +173,7 @@ tor_open_cloexec(const char *path, int flags, unsigned mode)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(FD_CLOEXEC) */
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ tor_fopen_cloexec(const char *path, const char *mode)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(FD_CLOEXEC) */
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ tor_munmap_file(tor_mmap_t *handle)
|
|||||||
/* Can't fail in this mmap()/munmap()-free case */
|
/* Can't fail in this mmap()/munmap()-free case */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(COMPAT_HAS_MMAN_AND_PAGESIZE) || ... || ... */
|
||||||
|
|
||||||
/** Replacement for snprintf. Differs from platform snprintf in two
|
/** Replacement for snprintf. Differs from platform snprintf in two
|
||||||
* ways: First, always NUL-terminates its output. Second, always
|
* ways: First, always NUL-terminates its output. Second, always
|
||||||
@ -591,7 +591,7 @@ tor_vasprintf(char **strp, const char *fmt, va_list args)
|
|||||||
}
|
}
|
||||||
*strp = strp_tmp;
|
*strp = strp_tmp;
|
||||||
return len;
|
return len;
|
||||||
#endif
|
#endif /* defined(HAVE_VASPRINTF) || ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Given <b>hlen</b> bytes at <b>haystack</b> and <b>nlen</b> bytes at
|
/** Given <b>hlen</b> bytes at <b>haystack</b> and <b>nlen</b> bytes at
|
||||||
@ -637,7 +637,7 @@ tor_memmem(const void *_haystack, size_t hlen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif /* defined(HAVE_MEMMEM) && (!defined(__GNUC__) || __GNUC__ >= 2) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -775,7 +775,7 @@ tor_fix_source_file(const char *fname)
|
|||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a 16-bit value beginning at <b>cp</b>. Equivalent to
|
* Read a 16-bit value beginning at <b>cp</b>. Equivalent to
|
||||||
@ -869,7 +869,7 @@ replace_file(const char *from, const char *to)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return tor_rename(from,to);
|
return tor_rename(from,to);
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Change <b>fname</b>'s modification time to now. */
|
/** Change <b>fname</b>'s modification time to now. */
|
||||||
@ -955,7 +955,7 @@ tor_lockfile_lock(const char *filename, int blocking, int *locked_out)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) || ... */
|
||||||
|
|
||||||
result = tor_malloc(sizeof(tor_lockfile_t));
|
result = tor_malloc(sizeof(tor_lockfile_t));
|
||||||
result->filename = tor_strdup(filename);
|
result->filename = tor_strdup(filename);
|
||||||
@ -983,7 +983,7 @@ tor_lockfile_unlock(tor_lockfile_t *lockfile)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Closing the lockfile is sufficient. */
|
/* Closing the lockfile is sufficient. */
|
||||||
#endif
|
#endif /* defined(_WIN32) || ... */
|
||||||
|
|
||||||
close(lockfile->fd);
|
close(lockfile->fd);
|
||||||
lockfile->fd = -1;
|
lockfile->fd = -1;
|
||||||
@ -1031,9 +1031,9 @@ tor_fd_seekend(int fd)
|
|||||||
* no need to worry. */
|
* no need to worry. */
|
||||||
if (rc < 0 && errno == ESPIPE)
|
if (rc < 0 && errno == ESPIPE)
|
||||||
rc = 0;
|
rc = 0;
|
||||||
#endif
|
#endif /* defined(ESPIPE) */
|
||||||
return (rc < 0) ? -1 : 0;
|
return (rc < 0) ? -1 : 0;
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Move <b>fd</b> to position <b>pos</b> in the file. Return -1 on error, 0
|
/** Move <b>fd</b> to position <b>pos</b> in the file. Return -1 on error, 0
|
||||||
@ -1072,7 +1072,7 @@ tor_ftruncate(int fd)
|
|||||||
static bitarray_t *open_sockets = NULL;
|
static bitarray_t *open_sockets = NULL;
|
||||||
/** The size of <b>open_sockets</b>, in bits. */
|
/** The size of <b>open_sockets</b>, in bits. */
|
||||||
static int max_socket = -1;
|
static int max_socket = -1;
|
||||||
#endif
|
#endif /* defined(DEBUG_SOCKET_COUNTING) */
|
||||||
|
|
||||||
/** Count of number of sockets currently open. (Undercounts sockets opened by
|
/** Count of number of sockets currently open. (Undercounts sockets opened by
|
||||||
* eventdns and libevent.) */
|
* eventdns and libevent.) */
|
||||||
@ -1142,7 +1142,7 @@ tor_close_socket,(tor_socket_t s))
|
|||||||
tor_assert(open_sockets && s <= max_socket);
|
tor_assert(open_sockets && s <= max_socket);
|
||||||
bitarray_clear(open_sockets, s);
|
bitarray_clear(open_sockets, s);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(DEBUG_SOCKET_COUNTING) */
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
--n_sockets_open;
|
--n_sockets_open;
|
||||||
} else {
|
} else {
|
||||||
@ -1152,7 +1152,7 @@ tor_close_socket,(tor_socket_t s))
|
|||||||
#else
|
#else
|
||||||
if (r != EBADF)
|
if (r != EBADF)
|
||||||
--n_sockets_open; // LCOV_EXCL_LINE -- EIO and EINTR too hard to force.
|
--n_sockets_open; // LCOV_EXCL_LINE -- EIO and EINTR too hard to force.
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
r = -1;
|
r = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1185,9 +1185,9 @@ mark_socket_open(tor_socket_t s)
|
|||||||
}
|
}
|
||||||
bitarray_set(open_sockets, s);
|
bitarray_set(open_sockets, s);
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(DEBUG_SOCKET_COUNTING)) */
|
||||||
#define mark_socket_open(s) STMT_NIL
|
#define mark_socket_open(s) STMT_NIL
|
||||||
#endif
|
#endif /* defined(DEBUG_SOCKET_COUNTING) */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/** As socket(), but counts the number of open sockets. */
|
/** As socket(), but counts the number of open sockets. */
|
||||||
@ -1245,7 +1245,7 @@ tor_open_socket_with_extensions(int domain, int type, int protocol,
|
|||||||
* support, we are running on one without. */
|
* support, we are running on one without. */
|
||||||
if (errno != EINVAL)
|
if (errno != EINVAL)
|
||||||
return s;
|
return s;
|
||||||
#endif /* SOCK_CLOEXEC && SOCK_NONBLOCK */
|
#endif /* defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK) */
|
||||||
|
|
||||||
s = socket(domain, type, protocol);
|
s = socket(domain, type, protocol);
|
||||||
if (! SOCKET_OK(s))
|
if (! SOCKET_OK(s))
|
||||||
@ -1259,9 +1259,9 @@ tor_open_socket_with_extensions(int domain, int type, int protocol,
|
|||||||
return TOR_INVALID_SOCKET;
|
return TOR_INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(FD_CLOEXEC)) */
|
||||||
(void)cloexec;
|
(void)cloexec;
|
||||||
#endif
|
#endif /* defined(FD_CLOEXEC) */
|
||||||
|
|
||||||
if (nonblock) {
|
if (nonblock) {
|
||||||
if (set_socket_nonblocking(s) == -1) {
|
if (set_socket_nonblocking(s) == -1) {
|
||||||
@ -1330,7 +1330,7 @@ tor_accept_socket_with_extensions(tor_socket_t sockfd, struct sockaddr *addr,
|
|||||||
* we are missing SOCK_CLOEXEC/SOCK_NONBLOCK support. */
|
* we are missing SOCK_CLOEXEC/SOCK_NONBLOCK support. */
|
||||||
if (errno != EINVAL && errno != ENOSYS)
|
if (errno != EINVAL && errno != ENOSYS)
|
||||||
return s;
|
return s;
|
||||||
#endif
|
#endif /* defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) ... */
|
||||||
|
|
||||||
s = accept(sockfd, addr, len);
|
s = accept(sockfd, addr, len);
|
||||||
if (!SOCKET_OK(s))
|
if (!SOCKET_OK(s))
|
||||||
@ -1344,9 +1344,9 @@ tor_accept_socket_with_extensions(tor_socket_t sockfd, struct sockaddr *addr,
|
|||||||
return TOR_INVALID_SOCKET;
|
return TOR_INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(FD_CLOEXEC)) */
|
||||||
(void)cloexec;
|
(void)cloexec;
|
||||||
#endif
|
#endif /* defined(FD_CLOEXEC) */
|
||||||
|
|
||||||
if (nonblock) {
|
if (nonblock) {
|
||||||
if (set_socket_nonblocking(s) == -1) {
|
if (set_socket_nonblocking(s) == -1) {
|
||||||
@ -1406,7 +1406,7 @@ set_socket_nonblocking(tor_socket_t sock)
|
|||||||
log_warn(LD_NET, "Couldn't set file status flags: %s", strerror(errno));
|
log_warn(LD_NET, "Couldn't set file status flags: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1444,7 +1444,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
|
|||||||
* are running on one without. */
|
* are running on one without. */
|
||||||
if (errno != EINVAL)
|
if (errno != EINVAL)
|
||||||
return -errno;
|
return -errno;
|
||||||
#endif
|
#endif /* defined(SOCK_CLOEXEC) */
|
||||||
|
|
||||||
r = socketpair(family, type, protocol, fd);
|
r = socketpair(family, type, protocol, fd);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -1467,7 +1467,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
|
|||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(FD_CLOEXEC) */
|
||||||
goto sockets_ok; /* So that sockets_ok will not be unused. */
|
goto sockets_ok; /* So that sockets_ok will not be unused. */
|
||||||
|
|
||||||
sockets_ok:
|
sockets_ok:
|
||||||
@ -1483,9 +1483,9 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
|
|||||||
socket_accounting_unlock();
|
socket_accounting_unlock();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else /* !(defined(HAVE_SOCKETPAIR) && !defined(_WIN32)) */
|
||||||
return tor_ersatz_socketpair(family, type, protocol, fd);
|
return tor_ersatz_socketpair(family, type, protocol, fd);
|
||||||
#endif
|
#endif /* defined(HAVE_SOCKETPAIR) && !defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NEED_ERSATZ_SOCKETPAIR
|
#ifdef NEED_ERSATZ_SOCKETPAIR
|
||||||
@ -1642,7 +1642,7 @@ tor_ersatz_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
|
|||||||
|
|
||||||
#undef SIZEOF_SOCKADDR
|
#undef SIZEOF_SOCKADDR
|
||||||
|
|
||||||
#endif
|
#endif /* defined(NEED_ERSATZ_SOCKETPAIR) */
|
||||||
|
|
||||||
/* Return the maximum number of allowed sockets. */
|
/* Return the maximum number of allowed sockets. */
|
||||||
int
|
int
|
||||||
@ -1696,7 +1696,7 @@ set_max_file_descriptors(rlim_t limit, int *max_out)
|
|||||||
#else
|
#else
|
||||||
const char *platform = "unknown platforms with no getrlimit()";
|
const char *platform = "unknown platforms with no getrlimit()";
|
||||||
const unsigned long MAX_CONNECTIONS = 15000;
|
const unsigned long MAX_CONNECTIONS = 15000;
|
||||||
#endif
|
#endif /* defined(CYGWIN) || defined(__CYGWIN__) || ... */
|
||||||
log_fn(LOG_INFO, LD_NET,
|
log_fn(LOG_INFO, LD_NET,
|
||||||
"This platform is missing getrlimit(). Proceeding.");
|
"This platform is missing getrlimit(). Proceeding.");
|
||||||
if (limit > MAX_CONNECTIONS) {
|
if (limit > MAX_CONNECTIONS) {
|
||||||
@ -1707,7 +1707,7 @@ set_max_file_descriptors(rlim_t limit, int *max_out)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
limit = MAX_CONNECTIONS;
|
limit = MAX_CONNECTIONS;
|
||||||
#else /* HAVE_GETRLIMIT */
|
#else /* !(!defined(HAVE_GETRLIMIT)) */
|
||||||
struct rlimit rlim;
|
struct rlimit rlim;
|
||||||
|
|
||||||
if (getrlimit(RLIMIT_NOFILE, &rlim) != 0) {
|
if (getrlimit(RLIMIT_NOFILE, &rlim) != 0) {
|
||||||
@ -1756,7 +1756,7 @@ set_max_file_descriptors(rlim_t limit, int *max_out)
|
|||||||
bad = 0;
|
bad = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPEN_MAX */
|
#endif /* defined(OPEN_MAX) */
|
||||||
if (bad) {
|
if (bad) {
|
||||||
log_warn(LD_CONFIG,"Couldn't set maximum number of file descriptors: %s",
|
log_warn(LD_CONFIG,"Couldn't set maximum number of file descriptors: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@ -1765,7 +1765,7 @@ set_max_file_descriptors(rlim_t limit, int *max_out)
|
|||||||
}
|
}
|
||||||
/* leave some overhead for logs, etc, */
|
/* leave some overhead for logs, etc, */
|
||||||
limit = rlim.rlim_cur;
|
limit = rlim.rlim_cur;
|
||||||
#endif /* HAVE_GETRLIMIT */
|
#endif /* !defined(HAVE_GETRLIMIT) */
|
||||||
|
|
||||||
if (limit > INT_MAX)
|
if (limit > INT_MAX)
|
||||||
limit = INT_MAX;
|
limit = INT_MAX;
|
||||||
@ -1803,7 +1803,7 @@ log_credential_status(void)
|
|||||||
"UID is %u (real), %u (effective), %u (saved)",
|
"UID is %u (real), %u (effective), %u (saved)",
|
||||||
(unsigned)ruid, (unsigned)euid, (unsigned)suid);
|
(unsigned)ruid, (unsigned)euid, (unsigned)suid);
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(HAVE_GETRESUID)) */
|
||||||
/* getresuid is not present on MacOS X, so we can't get the saved (E)UID */
|
/* getresuid is not present on MacOS X, so we can't get the saved (E)UID */
|
||||||
ruid = getuid();
|
ruid = getuid();
|
||||||
euid = geteuid();
|
euid = geteuid();
|
||||||
@ -1812,7 +1812,7 @@ log_credential_status(void)
|
|||||||
log_fn(CREDENTIAL_LOG_LEVEL, LD_GENERAL,
|
log_fn(CREDENTIAL_LOG_LEVEL, LD_GENERAL,
|
||||||
"UID is %u (real), %u (effective), unknown (saved)",
|
"UID is %u (real), %u (effective), unknown (saved)",
|
||||||
(unsigned)ruid, (unsigned)euid);
|
(unsigned)ruid, (unsigned)euid);
|
||||||
#endif
|
#endif /* defined(HAVE_GETRESUID) */
|
||||||
|
|
||||||
/* log GIDs */
|
/* log GIDs */
|
||||||
#ifdef HAVE_GETRESGID
|
#ifdef HAVE_GETRESGID
|
||||||
@ -1824,7 +1824,7 @@ log_credential_status(void)
|
|||||||
"GID is %u (real), %u (effective), %u (saved)",
|
"GID is %u (real), %u (effective), %u (saved)",
|
||||||
(unsigned)rgid, (unsigned)egid, (unsigned)sgid);
|
(unsigned)rgid, (unsigned)egid, (unsigned)sgid);
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(HAVE_GETRESGID)) */
|
||||||
/* getresgid is not present on MacOS X, so we can't get the saved (E)GID */
|
/* getresgid is not present on MacOS X, so we can't get the saved (E)GID */
|
||||||
rgid = getgid();
|
rgid = getgid();
|
||||||
egid = getegid();
|
egid = getegid();
|
||||||
@ -1832,7 +1832,7 @@ log_credential_status(void)
|
|||||||
log_fn(CREDENTIAL_LOG_LEVEL, LD_GENERAL,
|
log_fn(CREDENTIAL_LOG_LEVEL, LD_GENERAL,
|
||||||
"GID is %u (real), %u (effective), unknown (saved)",
|
"GID is %u (real), %u (effective), unknown (saved)",
|
||||||
(unsigned)rgid, (unsigned)egid);
|
(unsigned)rgid, (unsigned)egid);
|
||||||
#endif
|
#endif /* defined(HAVE_GETRESGID) */
|
||||||
|
|
||||||
/* log supplementary groups */
|
/* log supplementary groups */
|
||||||
sup_gids_size = 64;
|
sup_gids_size = 64;
|
||||||
@ -1872,7 +1872,7 @@ log_credential_status(void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
/** Cached struct from the last getpwname() call we did successfully. */
|
/** Cached struct from the last getpwname() call we did successfully. */
|
||||||
@ -1972,7 +1972,7 @@ tor_getpwuid(uid_t uid)
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
/** Return true iff we were compiled with capability support, and capabilities
|
/** Return true iff we were compiled with capability support, and capabilities
|
||||||
* seem to work. **/
|
* seem to work. **/
|
||||||
@ -1985,9 +1985,9 @@ have_capability_support(void)
|
|||||||
return 0;
|
return 0;
|
||||||
cap_free(caps);
|
cap_free(caps);
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else /* !(defined(HAVE_LINUX_CAPABILITIES)) */
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* defined(HAVE_LINUX_CAPABILITIES) */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_CAPABILITIES
|
#ifdef HAVE_LINUX_CAPABILITIES
|
||||||
@ -2046,7 +2046,7 @@ drop_capabilities(int pre_setuid)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_LINUX_CAPABILITIES) */
|
||||||
|
|
||||||
/** Call setuid and setgid to run as <b>user</b> and switch to their
|
/** Call setuid and setgid to run as <b>user</b> and switch to their
|
||||||
* primary group. Return 0 on success. On failure, log and return -1.
|
* primary group. Return 0 on success. On failure, log and return -1.
|
||||||
@ -2096,13 +2096,13 @@ switch_id(const char *user, const unsigned flags)
|
|||||||
if (drop_capabilities(1))
|
if (drop_capabilities(1))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(HAVE_LINUX_CAPABILITIES)) */
|
||||||
(void) keep_bindlow;
|
(void) keep_bindlow;
|
||||||
if (warn_if_no_caps) {
|
if (warn_if_no_caps) {
|
||||||
log_warn(LD_CONFIG, "KeepBindCapabilities set, but no capability support "
|
log_warn(LD_CONFIG, "KeepBindCapabilities set, but no capability support "
|
||||||
"on this system.");
|
"on this system.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_LINUX_CAPABILITIES) */
|
||||||
|
|
||||||
/* Properly switch egid,gid,euid,uid here or bail out */
|
/* Properly switch egid,gid,euid,uid here or bail out */
|
||||||
if (setgroups(1, &pw->pw_gid)) {
|
if (setgroups(1, &pw->pw_gid)) {
|
||||||
@ -2162,7 +2162,7 @@ switch_id(const char *user, const unsigned flags)
|
|||||||
if (drop_capabilities(0))
|
if (drop_capabilities(0))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_LINUX_CAPABILITIES) */
|
||||||
|
|
||||||
#if !defined(CYGWIN) && !defined(__CYGWIN__)
|
#if !defined(CYGWIN) && !defined(__CYGWIN__)
|
||||||
/* If we tried to drop privilege to a group/user other than root, attempt to
|
/* If we tried to drop privilege to a group/user other than root, attempt to
|
||||||
@ -2186,7 +2186,7 @@ switch_id(const char *user, const unsigned flags)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(CYGWIN) && !defined(__CYGWIN__) */
|
||||||
|
|
||||||
/* Check what really happened */
|
/* Check what really happened */
|
||||||
if (log_credential_status()) {
|
if (log_credential_status()) {
|
||||||
@ -2204,16 +2204,16 @@ switch_id(const char *user, const unsigned flags)
|
|||||||
log_warn(LD_CONFIG, "Unable to re-enable coredumps: %s",strerror(errno));
|
log_warn(LD_CONFIG, "Unable to re-enable coredumps: %s",strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(__linux__) && defined(HAVE_SYS_PRCTL_H) && ... */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#else
|
#else /* !(!defined(_WIN32)) */
|
||||||
(void)user;
|
(void)user;
|
||||||
(void)flags;
|
(void)flags;
|
||||||
|
|
||||||
log_warn(LD_CONFIG, "Switching users is unsupported on your OS.");
|
log_warn(LD_CONFIG, "Switching users is unsupported on your OS.");
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We only use the linux prctl for now. There is no Win32 support; this may
|
/* We only use the linux prctl for now. There is no Win32 support; this may
|
||||||
@ -2252,7 +2252,7 @@ tor_disable_debugger_attach(void)
|
|||||||
attempted = 1;
|
attempted = 1;
|
||||||
r = ptrace(PT_DENY_ATTACH, 0, 0, 0);
|
r = ptrace(PT_DENY_ATTACH, 0, 0, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(__APPLE__) && defined(PT_DENY_ATTACH) */
|
||||||
|
|
||||||
// XXX: TODO - Mac OS X has dtrace and this may be disabled.
|
// XXX: TODO - Mac OS X has dtrace and this may be disabled.
|
||||||
// XXX: TODO - Windows probably has something similar
|
// XXX: TODO - Windows probably has something similar
|
||||||
@ -2282,7 +2282,7 @@ get_user_homedir(const char *username)
|
|||||||
}
|
}
|
||||||
return tor_strdup(pw->pw_dir);
|
return tor_strdup(pw->pw_dir);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_PWD_H) */
|
||||||
|
|
||||||
/** Modify <b>fname</b> to contain the name of its parent directory. Doesn't
|
/** Modify <b>fname</b> to contain the name of its parent directory. Doesn't
|
||||||
* actually examine the filesystem; does a purely syntactic modification.
|
* actually examine the filesystem; does a purely syntactic modification.
|
||||||
@ -2310,7 +2310,7 @@ get_parent_directory(char *fname)
|
|||||||
if (fname[0] && fname[1] == ':') {
|
if (fname[0] && fname[1] == ':') {
|
||||||
fname += 2;
|
fname += 2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
/* Now we want to remove all path-separators at the end of the string,
|
/* Now we want to remove all path-separators at the end of the string,
|
||||||
* and to remove the end of the string starting with the path separator
|
* and to remove the end of the string starting with the path separator
|
||||||
* before the last non-path-separator. In perl, this would be
|
* before the last non-path-separator. In perl, this would be
|
||||||
@ -2359,7 +2359,7 @@ alloc_getcwd(void)
|
|||||||
raw_free(cwd); // alias for free to avoid tripping check-spaces.
|
raw_free(cwd); // alias for free to avoid tripping check-spaces.
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
#else
|
#else /* !(defined(HAVE_GET_CURRENT_DIR_NAME)) */
|
||||||
size_t size = 1024;
|
size_t size = 1024;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
@ -2376,9 +2376,9 @@ alloc_getcwd(void)
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
#endif
|
#endif /* defined(HAVE_GET_CURRENT_DIR_NAME) */
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
/** Expand possibly relative path <b>fname</b> to an absolute path.
|
/** Expand possibly relative path <b>fname</b> to an absolute path.
|
||||||
* Return a newly allocated string, possibly equal to <b>fname</b>. */
|
* Return a newly allocated string, possibly equal to <b>fname</b>. */
|
||||||
@ -2394,7 +2394,7 @@ make_path_absolute(char *fname)
|
|||||||
if (absfname_malloced) raw_free(absfname_malloced);
|
if (absfname_malloced) raw_free(absfname_malloced);
|
||||||
|
|
||||||
return absfname;
|
return absfname;
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
char *absfname = NULL, *path = NULL;
|
char *absfname = NULL, *path = NULL;
|
||||||
|
|
||||||
tor_assert(fname);
|
tor_assert(fname);
|
||||||
@ -2417,7 +2417,7 @@ make_path_absolute(char *fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return absfname;
|
return absfname;
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE__NSGETENVIRON
|
#ifndef HAVE__NSGETENVIRON
|
||||||
@ -2426,8 +2426,8 @@ make_path_absolute(char *fname)
|
|||||||
#ifndef RUNNING_DOXYGEN
|
#ifndef RUNNING_DOXYGEN
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* !defined(HAVE_EXTERN_ENVIRON_DECLARED) */
|
||||||
#endif
|
#endif /* !defined(HAVE__NSGETENVIRON) */
|
||||||
|
|
||||||
/** Return the current environment. This is a portable replacement for
|
/** Return the current environment. This is a portable replacement for
|
||||||
* 'environ'. */
|
* 'environ'. */
|
||||||
@ -2439,9 +2439,9 @@ get_environment(void)
|
|||||||
* when we do a mostly-static build on OSX 10.7, the resulting binary won't
|
* when we do a mostly-static build on OSX 10.7, the resulting binary won't
|
||||||
* work on OSX 10.6. */
|
* work on OSX 10.6. */
|
||||||
return *_NSGetEnviron();
|
return *_NSGetEnviron();
|
||||||
#else
|
#else /* !(defined(HAVE__NSGETENVIRON)) */
|
||||||
return environ;
|
return environ;
|
||||||
#endif
|
#endif /* defined(HAVE__NSGETENVIRON) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get name of current host and write it to <b>name</b> array, whose
|
/** Get name of current host and write it to <b>name</b> array, whose
|
||||||
@ -2718,7 +2718,7 @@ get_uname,(void))
|
|||||||
/* (Linux says 0 is success, Solaris says 1 is success) */
|
/* (Linux says 0 is success, Solaris says 1 is success) */
|
||||||
strlcpy(uname_result, u.sysname, sizeof(uname_result));
|
strlcpy(uname_result, u.sysname, sizeof(uname_result));
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif /* defined(HAVE_UNAME) */
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
OSVERSIONINFOEX info;
|
OSVERSIONINFOEX info;
|
||||||
@ -2780,12 +2780,12 @@ get_uname,(void))
|
|||||||
info.wProductType == VER_NT_DOMAIN_CONTROLLER) {
|
info.wProductType == VER_NT_DOMAIN_CONTROLLER) {
|
||||||
strlcat(uname_result, " [server]", sizeof(uname_result));
|
strlcat(uname_result, " [server]", sizeof(uname_result));
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(VER_NT_SERVER) */
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
/* LCOV_EXCL_START -- can't provoke uname failure */
|
/* LCOV_EXCL_START -- can't provoke uname failure */
|
||||||
strlcpy(uname_result, "Unknown platform", sizeof(uname_result));
|
strlcpy(uname_result, "Unknown platform", sizeof(uname_result));
|
||||||
/* LCOV_EXCL_STOP */
|
/* LCOV_EXCL_STOP */
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
uname_result_is_set = 1;
|
uname_result_is_set = 1;
|
||||||
}
|
}
|
||||||
@ -2841,7 +2841,7 @@ compute_num_cpus_impl(void)
|
|||||||
return -1;
|
return -1;
|
||||||
#else
|
#else
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif /* defined(_WIN32) || ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_DETECTABLE_CPUS 16
|
#define MAX_DETECTABLE_CPUS 16
|
||||||
@ -3004,7 +3004,7 @@ tor_localtime_r(const time_t *timep, struct tm *result)
|
|||||||
memcpy(result, r, sizeof(struct tm));
|
memcpy(result, r, sizeof(struct tm));
|
||||||
return correct_tm(1, timep, result, r);
|
return correct_tm(1, timep, result, r);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_LOCALTIME_R) || ... */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/** @{ */
|
/** @{ */
|
||||||
@ -3047,7 +3047,7 @@ tor_gmtime_r(const time_t *timep, struct tm *result)
|
|||||||
memcpy(result, r, sizeof(struct tm));
|
memcpy(result, r, sizeof(struct tm));
|
||||||
return correct_tm(0, timep, result, r);
|
return correct_tm(0, timep, result, r);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_GMTIME_R) || ... */
|
||||||
|
|
||||||
#if defined(HAVE_MLOCKALL) && HAVE_DECL_MLOCKALL && defined(RLIMIT_MEMLOCK)
|
#if defined(HAVE_MLOCKALL) && HAVE_DECL_MLOCKALL && defined(RLIMIT_MEMLOCK)
|
||||||
#define HAVE_UNIX_MLOCKALL
|
#define HAVE_UNIX_MLOCKALL
|
||||||
@ -3084,7 +3084,7 @@ tor_set_max_memlock(void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_UNIX_MLOCKALL) */
|
||||||
|
|
||||||
/** Attempt to lock all current and all future memory pages.
|
/** Attempt to lock all current and all future memory pages.
|
||||||
* This should only be called once and while we're privileged.
|
* This should only be called once and while we're privileged.
|
||||||
@ -3130,10 +3130,10 @@ tor_mlockall(void)
|
|||||||
"pages: %s", strerror(errno));
|
"pages: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(HAVE_UNIX_MLOCKALL)) */
|
||||||
log_warn(LD_GENERAL, "Unable to lock memory pages. mlockall() unsupported?");
|
log_warn(LD_GENERAL, "Unable to lock memory pages. mlockall() unsupported?");
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif /* defined(HAVE_UNIX_MLOCKALL) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3161,7 +3161,7 @@ tor_socket_errno(tor_socket_t sock)
|
|||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define E(code, s) { code, (s " [" #code " ]") }
|
#define E(code, s) { code, (s " [" #code " ]") }
|
||||||
@ -3237,7 +3237,7 @@ tor_socket_strerror(int e)
|
|||||||
}
|
}
|
||||||
return strerror(e);
|
return strerror(e);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/** Called before we make any calls to network-related functions.
|
/** Called before we make any calls to network-related functions.
|
||||||
* (Some operating systems require their network libraries to be
|
* (Some operating systems require their network libraries to be
|
||||||
@ -3263,7 +3263,7 @@ network_init(void)
|
|||||||
/* WSAData.iMaxSockets might show the max sockets we're allowed to use.
|
/* WSAData.iMaxSockets might show the max sockets we're allowed to use.
|
||||||
* We might use it to complain if we're trying to be a server but have
|
* We might use it to complain if we're trying to be a server but have
|
||||||
* too few sockets available. */
|
* too few sockets available. */
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3299,9 +3299,9 @@ format_win32_error(DWORD err)
|
|||||||
result = tor_malloc(len);
|
result = tor_malloc(len);
|
||||||
wcstombs(result,str,len);
|
wcstombs(result,str,len);
|
||||||
result[len-1] = '\0';
|
result[len-1] = '\0';
|
||||||
#else
|
#else /* !(defined(UNICODE)) */
|
||||||
result = tor_strdup(str);
|
result = tor_strdup(str);
|
||||||
#endif
|
#endif /* defined(UNICODE) */
|
||||||
} else {
|
} else {
|
||||||
result = tor_strdup("<unformattable error>");
|
result = tor_strdup("<unformattable error>");
|
||||||
}
|
}
|
||||||
@ -3310,7 +3310,7 @@ format_win32_error(DWORD err)
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
#if defined(HW_PHYSMEM64)
|
#if defined(HW_PHYSMEM64)
|
||||||
/* This appears to be an OpenBSD thing */
|
/* This appears to be an OpenBSD thing */
|
||||||
@ -3318,7 +3318,7 @@ format_win32_error(DWORD err)
|
|||||||
#elif defined(HW_MEMSIZE)
|
#elif defined(HW_MEMSIZE)
|
||||||
/* OSX defines this one */
|
/* OSX defines this one */
|
||||||
#define INT64_HW_MEM HW_MEMSIZE
|
#define INT64_HW_MEM HW_MEMSIZE
|
||||||
#endif
|
#endif /* defined(HW_PHYSMEM64) || ... */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper: try to detect the total system memory, and return it. On failure,
|
* Helper: try to detect the total system memory, and return it. On failure,
|
||||||
@ -3392,7 +3392,7 @@ get_total_system_memory_impl(void)
|
|||||||
#else
|
#else
|
||||||
/* I have no clue. */
|
/* I have no clue. */
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* defined(__linux__) || ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3425,7 +3425,7 @@ get_total_system_memory(size_t *mem_out)
|
|||||||
* size_t. */
|
* size_t. */
|
||||||
m = SIZE_MAX;
|
m = SIZE_MAX;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* SIZE_MAX != UINT64_MAX */
|
||||||
|
|
||||||
*mem_out = mem_cached = (size_t) m;
|
*mem_out = mem_cached = (size_t) m;
|
||||||
|
|
||||||
@ -3506,7 +3506,7 @@ tor_getpass(const char *prompt, char *output, size_t buflen)
|
|||||||
return r;
|
return r;
|
||||||
#else
|
#else
|
||||||
#error "No implementation for tor_getpass found!"
|
#error "No implementation for tor_getpass found!"
|
||||||
#endif
|
#endif /* defined(HAVE_READPASSPHRASE) || ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the amount of free disk space we have permission to use, in
|
/** Return the amount of free disk space we have permission to use, in
|
||||||
@ -3546,6 +3546,6 @@ tor_get_avail_disk_space(const char *path)
|
|||||||
(void)path;
|
(void)path;
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif /* defined(HAVE_STATVFS) || ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@
|
|||||||
* clang rejects because it is off the end of a less-than-3. Clang hates this,
|
* clang rejects because it is off the end of a less-than-3. Clang hates this,
|
||||||
* even though those references never actually happen. */
|
* even though those references never actually happen. */
|
||||||
# undef strcmp
|
# undef strcmp
|
||||||
# endif
|
#endif /* __has_feature(address_sanitizer) */
|
||||||
#endif
|
#endif /* defined(__has_feature) */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -76,13 +76,13 @@
|
|||||||
__attribute__ ((format(printf, formatIdx, firstArg)))
|
__attribute__ ((format(printf, formatIdx, firstArg)))
|
||||||
#else
|
#else
|
||||||
#define CHECK_PRINTF(formatIdx, firstArg)
|
#define CHECK_PRINTF(formatIdx, firstArg)
|
||||||
#endif
|
#endif /* defined(__GNUC__) */
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define CHECK_SCANF(formatIdx, firstArg) \
|
#define CHECK_SCANF(formatIdx, firstArg) \
|
||||||
__attribute__ ((format(scanf, formatIdx, firstArg)))
|
__attribute__ ((format(scanf, formatIdx, firstArg)))
|
||||||
#else
|
#else
|
||||||
#define CHECK_SCANF(formatIdx, firstArg)
|
#define CHECK_SCANF(formatIdx, firstArg)
|
||||||
#endif
|
#endif /* defined(__GNUC__) */
|
||||||
|
|
||||||
/* What GCC do we have? */
|
/* What GCC do we have? */
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
@ -109,18 +109,18 @@
|
|||||||
PRAGMA_DIAGNOSTIC_(ignored PRAGMA_JOIN_STRINGIFY_(-W,warningopt))
|
PRAGMA_DIAGNOSTIC_(ignored PRAGMA_JOIN_STRINGIFY_(-W,warningopt))
|
||||||
# define ENABLE_GCC_WARNING(warningopt) \
|
# define ENABLE_GCC_WARNING(warningopt) \
|
||||||
PRAGMA_DIAGNOSTIC_(pop)
|
PRAGMA_DIAGNOSTIC_(pop)
|
||||||
# else
|
#else /* !(defined(__clang__) || GCC_VERSION >= 406) */
|
||||||
/* older version of gcc: no push/pop support. */
|
/* older version of gcc: no push/pop support. */
|
||||||
# define DISABLE_GCC_WARNING(warningopt) \
|
# define DISABLE_GCC_WARNING(warningopt) \
|
||||||
PRAGMA_DIAGNOSTIC_(ignored PRAGMA_JOIN_STRINGIFY_(-W,warningopt))
|
PRAGMA_DIAGNOSTIC_(ignored PRAGMA_JOIN_STRINGIFY_(-W,warningopt))
|
||||||
# define ENABLE_GCC_WARNING(warningopt) \
|
# define ENABLE_GCC_WARNING(warningopt) \
|
||||||
PRAGMA_DIAGNOSTIC_(warning PRAGMA_JOIN_STRINGIFY_(-W,warningopt))
|
PRAGMA_DIAGNOSTIC_(warning PRAGMA_JOIN_STRINGIFY_(-W,warningopt))
|
||||||
# endif
|
#endif /* defined(__clang__) || GCC_VERSION >= 406 */
|
||||||
#else /* ifdef __GNUC__ */
|
#else /* !(defined(__GNUC__)) */
|
||||||
/* not gcc at all */
|
/* not gcc at all */
|
||||||
# define DISABLE_GCC_WARNING(warning)
|
# define DISABLE_GCC_WARNING(warning)
|
||||||
# define ENABLE_GCC_WARNING(warning)
|
# define ENABLE_GCC_WARNING(warning)
|
||||||
#endif
|
#endif /* defined(__GNUC__) */
|
||||||
|
|
||||||
/* inline is __inline on windows. */
|
/* inline is __inline on windows. */
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -142,9 +142,9 @@
|
|||||||
#define __func__ __FUNC__
|
#define __func__ __FUNC__
|
||||||
#else
|
#else
|
||||||
#define __func__ "???"
|
#define __func__ "???"
|
||||||
#endif
|
#endif /* defined(HAVE_MACRO__FUNCTION__) || ... */
|
||||||
#endif /* ifndef MAVE_MACRO__func__ */
|
#endif /* !defined(HAVE_MACRO__func__) */
|
||||||
#endif /* if not windows */
|
#endif /* defined(_MSC_VER) */
|
||||||
|
|
||||||
#define U64_TO_DBL(x) ((double) (x))
|
#define U64_TO_DBL(x) ((double) (x))
|
||||||
#define DBL_TO_U64(x) ((uint64_t) (x))
|
#define DBL_TO_U64(x) ((uint64_t) (x))
|
||||||
@ -157,7 +157,7 @@
|
|||||||
* problems), but if enumerated types are unsigned, we must use unsigned,
|
* problems), but if enumerated types are unsigned, we must use unsigned,
|
||||||
* so that the loss of precision doesn't make large values negative. */
|
* so that the loss of precision doesn't make large values negative. */
|
||||||
#define ENUM_BF(t) t
|
#define ENUM_BF(t) t
|
||||||
#endif
|
#endif /* defined(ENUM_VALS_ARE_SIGNED) */
|
||||||
|
|
||||||
/* GCC has several useful attributes. */
|
/* GCC has several useful attributes. */
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||||
@ -194,7 +194,7 @@
|
|||||||
* taken. This can generate slightly better code with some CPUs.
|
* taken. This can generate slightly better code with some CPUs.
|
||||||
*/
|
*/
|
||||||
#define PREDICT_UNLIKELY(exp) __builtin_expect(!!(exp), 0)
|
#define PREDICT_UNLIKELY(exp) __builtin_expect(!!(exp), 0)
|
||||||
#else
|
#else /* !(defined(__GNUC__) && __GNUC__ >= 3) */
|
||||||
#define ATTR_NORETURN
|
#define ATTR_NORETURN
|
||||||
#define ATTR_CONST
|
#define ATTR_CONST
|
||||||
#define ATTR_MALLOC
|
#define ATTR_MALLOC
|
||||||
@ -204,7 +204,7 @@
|
|||||||
#define ATTR_WUR
|
#define ATTR_WUR
|
||||||
#define PREDICT_LIKELY(exp) (exp)
|
#define PREDICT_LIKELY(exp) (exp)
|
||||||
#define PREDICT_UNLIKELY(exp) (exp)
|
#define PREDICT_UNLIKELY(exp) (exp)
|
||||||
#endif
|
#endif /* defined(__GNUC__) && __GNUC__ >= 3 */
|
||||||
|
|
||||||
/** Expands to a syntactically valid empty statement. */
|
/** Expands to a syntactically valid empty statement. */
|
||||||
#define STMT_NIL (void)0
|
#define STMT_NIL (void)0
|
||||||
@ -224,7 +224,7 @@
|
|||||||
#else
|
#else
|
||||||
#define STMT_BEGIN do {
|
#define STMT_BEGIN do {
|
||||||
#define STMT_END } while (0)
|
#define STMT_END } while (0)
|
||||||
#endif
|
#endif /* defined(__GNUC__) || ... */
|
||||||
|
|
||||||
/* Some tools (like coccinelle) don't like to see operators as macro
|
/* Some tools (like coccinelle) don't like to see operators as macro
|
||||||
* arguments. */
|
* arguments. */
|
||||||
@ -251,7 +251,7 @@
|
|||||||
*/
|
*/
|
||||||
#undef strlcat
|
#undef strlcat
|
||||||
#undef strlcpy
|
#undef strlcpy
|
||||||
#endif
|
#endif /* defined __APPLE__ */
|
||||||
|
|
||||||
#ifndef HAVE_STRLCAT
|
#ifndef HAVE_STRLCAT
|
||||||
size_t strlcat(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
|
size_t strlcat(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
|
||||||
@ -272,14 +272,14 @@ size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
|
|||||||
#define I64_PRINTF_ARG(a) (a)
|
#define I64_PRINTF_ARG(a) (a)
|
||||||
#define I64_SCANF_ARG(a) (a)
|
#define I64_SCANF_ARG(a) (a)
|
||||||
#define I64_LITERAL(n) (n ## i64)
|
#define I64_LITERAL(n) (n ## i64)
|
||||||
#else
|
#else /* !(defined(_MSC_VER)) */
|
||||||
#define U64_PRINTF_ARG(a) ((long long unsigned int)(a))
|
#define U64_PRINTF_ARG(a) ((long long unsigned int)(a))
|
||||||
#define U64_SCANF_ARG(a) ((long long unsigned int*)(a))
|
#define U64_SCANF_ARG(a) ((long long unsigned int*)(a))
|
||||||
#define U64_LITERAL(n) (n ## llu)
|
#define U64_LITERAL(n) (n ## llu)
|
||||||
#define I64_PRINTF_ARG(a) ((long long signed int)(a))
|
#define I64_PRINTF_ARG(a) ((long long signed int)(a))
|
||||||
#define I64_SCANF_ARG(a) ((long long signed int*)(a))
|
#define I64_SCANF_ARG(a) ((long long signed int*)(a))
|
||||||
#define I64_LITERAL(n) (n ## ll)
|
#define I64_LITERAL(n) (n ## ll)
|
||||||
#endif
|
#endif /* defined(_MSC_VER) */
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||||
#define MINGW_ANY
|
#define MINGW_ANY
|
||||||
@ -290,10 +290,10 @@ size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
|
|||||||
* scanf() function. See also U64_PRINTF_ARG and U64_SCANF_ARG. */
|
* scanf() function. See also U64_PRINTF_ARG and U64_SCANF_ARG. */
|
||||||
#define U64_FORMAT "%I64u"
|
#define U64_FORMAT "%I64u"
|
||||||
#define I64_FORMAT "%I64d"
|
#define I64_FORMAT "%I64d"
|
||||||
#else
|
#else /* !(defined(_MSC_VER) || defined(MINGW_ANY)) */
|
||||||
#define U64_FORMAT "%llu"
|
#define U64_FORMAT "%llu"
|
||||||
#define I64_FORMAT "%lld"
|
#define I64_FORMAT "%lld"
|
||||||
#endif
|
#endif /* defined(_MSC_VER) || defined(MINGW_ANY) */
|
||||||
|
|
||||||
#if (SIZEOF_INTPTR_T == SIZEOF_INT)
|
#if (SIZEOF_INTPTR_T == SIZEOF_INT)
|
||||||
#define INTPTR_T_FORMAT "%d"
|
#define INTPTR_T_FORMAT "%d"
|
||||||
@ -306,7 +306,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz) ATTR_NONNULL((1,2));
|
|||||||
#define INTPTR_PRINTF_ARG(x) I64_PRINTF_ARG(x)
|
#define INTPTR_PRINTF_ARG(x) I64_PRINTF_ARG(x)
|
||||||
#else
|
#else
|
||||||
#error Unknown: SIZEOF_INTPTR_T
|
#error Unknown: SIZEOF_INTPTR_T
|
||||||
#endif
|
#endif /* (SIZEOF_INTPTR_T == SIZEOF_INT) || ... */
|
||||||
|
|
||||||
/** Represents an mmaped file. Allocated via tor_mmap_file; freed with
|
/** Represents an mmaped file. Allocated via tor_mmap_file; freed with
|
||||||
* tor_munmap_file. */
|
* tor_munmap_file. */
|
||||||
@ -320,7 +320,7 @@ typedef struct tor_mmap_t {
|
|||||||
* size, rounded up to the nearest page.) */
|
* size, rounded up to the nearest page.) */
|
||||||
#elif defined _WIN32
|
#elif defined _WIN32
|
||||||
HANDLE mmap_handle;
|
HANDLE mmap_handle;
|
||||||
#endif
|
#endif /* defined(HAVE_SYS_MMAN_H) || ... */
|
||||||
|
|
||||||
} tor_mmap_t;
|
} tor_mmap_t;
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ const char *tor_fix_source_file(const char *fname);
|
|||||||
#else
|
#else
|
||||||
#define SHORT_FILE__ (__FILE__)
|
#define SHORT_FILE__ (__FILE__)
|
||||||
#define tor_fix_source_file(s) (s)
|
#define tor_fix_source_file(s) (s)
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/* ===== Time compatibility */
|
/* ===== Time compatibility */
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ struct tm *tor_gmtime_r(const time_t *timep, struct tm *result);
|
|||||||
(tvout)->tv_sec++; \
|
(tvout)->tv_sec++; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif /* !defined(timeradd) */
|
||||||
|
|
||||||
#ifndef timersub
|
#ifndef timersub
|
||||||
/** Replacement for timersub on platforms that do not have it: sets tvout to
|
/** Replacement for timersub on platforms that do not have it: sets tvout to
|
||||||
@ -415,7 +415,7 @@ struct tm *tor_gmtime_r(const time_t *timep, struct tm *result);
|
|||||||
(tvout)->tv_sec--; \
|
(tvout)->tv_sec--; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif /* !defined(timersub) */
|
||||||
|
|
||||||
#ifndef timercmp
|
#ifndef timercmp
|
||||||
/** Replacement for timercmp on platforms that do not have it: returns true
|
/** Replacement for timercmp on platforms that do not have it: returns true
|
||||||
@ -429,7 +429,7 @@ struct tm *tor_gmtime_r(const time_t *timep, struct tm *result);
|
|||||||
(((tv1)->tv_sec == (tv2)->tv_sec) ? \
|
(((tv1)->tv_sec == (tv2)->tv_sec) ? \
|
||||||
((tv1)->tv_usec op (tv2)->tv_usec) : \
|
((tv1)->tv_usec op (tv2)->tv_usec) : \
|
||||||
((tv1)->tv_sec op (tv2)->tv_sec))
|
((tv1)->tv_sec op (tv2)->tv_sec))
|
||||||
#endif
|
#endif /* !defined(timercmp) */
|
||||||
|
|
||||||
/* ===== File compatibility */
|
/* ===== File compatibility */
|
||||||
int tor_open_cloexec(const char *path, int flags, unsigned mode);
|
int tor_open_cloexec(const char *path, int flags, unsigned mode);
|
||||||
@ -471,7 +471,7 @@ typedef int socklen_t;
|
|||||||
#define TOR_SOCKET_T_FORMAT INTPTR_T_FORMAT
|
#define TOR_SOCKET_T_FORMAT INTPTR_T_FORMAT
|
||||||
#define SOCKET_OK(s) ((SOCKET)(s) != INVALID_SOCKET)
|
#define SOCKET_OK(s) ((SOCKET)(s) != INVALID_SOCKET)
|
||||||
#define TOR_INVALID_SOCKET INVALID_SOCKET
|
#define TOR_INVALID_SOCKET INVALID_SOCKET
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
/** Type used for a network socket. */
|
/** Type used for a network socket. */
|
||||||
#define tor_socket_t int
|
#define tor_socket_t int
|
||||||
#define TOR_SOCKET_T_FORMAT "%d"
|
#define TOR_SOCKET_T_FORMAT "%d"
|
||||||
@ -479,7 +479,7 @@ typedef int socklen_t;
|
|||||||
#define SOCKET_OK(s) ((s) >= 0)
|
#define SOCKET_OK(s) ((s) >= 0)
|
||||||
/** Error/uninitialized value for a tor_socket_t. */
|
/** Error/uninitialized value for a tor_socket_t. */
|
||||||
#define TOR_INVALID_SOCKET (-1)
|
#define TOR_INVALID_SOCKET (-1)
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
int tor_close_socket_simple(tor_socket_t s);
|
int tor_close_socket_simple(tor_socket_t s);
|
||||||
MOCK_DECL(int, tor_close_socket, (tor_socket_t s));
|
MOCK_DECL(int, tor_close_socket, (tor_socket_t s));
|
||||||
@ -526,7 +526,7 @@ struct in6_addr
|
|||||||
#define s6_addr16 in6_u.u6_addr16
|
#define s6_addr16 in6_u.u6_addr16
|
||||||
#define s6_addr32 in6_u.u6_addr32
|
#define s6_addr32 in6_u.u6_addr32
|
||||||
};
|
};
|
||||||
#endif
|
#endif /* !defined(HAVE_STRUCT_IN6_ADDR) */
|
||||||
|
|
||||||
/** @{ */
|
/** @{ */
|
||||||
/** Many BSD variants seem not to define these. */
|
/** Many BSD variants seem not to define these. */
|
||||||
@ -538,7 +538,7 @@ struct in6_addr
|
|||||||
#ifndef s6_addr32
|
#ifndef s6_addr32
|
||||||
#define s6_addr32 __u6_addr.__u6_addr32
|
#define s6_addr32 __u6_addr.__u6_addr32
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(__APPLE__) || defined(__darwin__) || ... */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifndef HAVE_SA_FAMILY_T
|
#ifndef HAVE_SA_FAMILY_T
|
||||||
@ -570,7 +570,7 @@ struct sockaddr_in6 {
|
|||||||
struct in6_addr sin6_addr;
|
struct in6_addr sin6_addr;
|
||||||
// uint32_t sin6_scope_id;
|
// uint32_t sin6_scope_id;
|
||||||
};
|
};
|
||||||
#endif
|
#endif /* !defined(HAVE_STRUCT_SOCKADDR_IN6) */
|
||||||
|
|
||||||
MOCK_DECL(int,tor_gethostname,(char *name, size_t namelen));
|
MOCK_DECL(int,tor_gethostname,(char *name, size_t namelen));
|
||||||
int tor_inet_aton(const char *cp, struct in_addr *addr) ATTR_NONNULL((1,2));
|
int tor_inet_aton(const char *cp, struct in_addr *addr) ATTR_NONNULL((1,2));
|
||||||
@ -611,14 +611,14 @@ int network_init(void);
|
|||||||
#define ERRNO_IS_EINTR(e) ((e) == WSAEINTR || 0)
|
#define ERRNO_IS_EINTR(e) ((e) == WSAEINTR || 0)
|
||||||
int tor_socket_errno(tor_socket_t sock);
|
int tor_socket_errno(tor_socket_t sock);
|
||||||
const char *tor_socket_strerror(int e);
|
const char *tor_socket_strerror(int e);
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
#define SOCK_ERRNO(e) e
|
#define SOCK_ERRNO(e) e
|
||||||
#if EAGAIN == EWOULDBLOCK
|
#if EAGAIN == EWOULDBLOCK
|
||||||
/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
|
/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
|
||||||
#define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN || 0)
|
#define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN || 0)
|
||||||
#else
|
#else
|
||||||
#define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN || (e) == EWOULDBLOCK)
|
#define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN || (e) == EWOULDBLOCK)
|
||||||
#endif
|
#endif /* EAGAIN == EWOULDBLOCK */
|
||||||
#define ERRNO_IS_EINTR(e) ((e) == EINTR || 0)
|
#define ERRNO_IS_EINTR(e) ((e) == EINTR || 0)
|
||||||
#define ERRNO_IS_EINPROGRESS(e) ((e) == EINPROGRESS || 0)
|
#define ERRNO_IS_EINPROGRESS(e) ((e) == EINPROGRESS || 0)
|
||||||
#define ERRNO_IS_CONN_EINPROGRESS(e) ((e) == EINPROGRESS || 0)
|
#define ERRNO_IS_CONN_EINPROGRESS(e) ((e) == EINPROGRESS || 0)
|
||||||
@ -629,7 +629,7 @@ const char *tor_socket_strerror(int e);
|
|||||||
#define ERRNO_IS_EADDRINUSE(e) (((e) == EADDRINUSE) || 0)
|
#define ERRNO_IS_EADDRINUSE(e) (((e) == EADDRINUSE) || 0)
|
||||||
#define tor_socket_errno(sock) (errno)
|
#define tor_socket_errno(sock) (errno)
|
||||||
#define tor_socket_strerror(e) strerror(e)
|
#define tor_socket_strerror(e) strerror(e)
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/** Specified SOCKS5 status codes. */
|
/** Specified SOCKS5 status codes. */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -732,7 +732,7 @@ char *format_win32_error(DWORD err);
|
|||||||
#define VER_SUITE_SINGLEUSERTS 0x00000100
|
#define VER_SUITE_SINGLEUSERTS 0x00000100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
#ifdef COMPAT_PRIVATE
|
#ifdef COMPAT_PRIVATE
|
||||||
#if !defined(HAVE_SOCKETPAIR) || defined(_WIN32) || defined(TOR_UNIT_TESTS)
|
#if !defined(HAVE_SOCKETPAIR) || defined(_WIN32) || defined(TOR_UNIT_TESTS)
|
||||||
@ -740,12 +740,12 @@ char *format_win32_error(DWORD err);
|
|||||||
STATIC int tor_ersatz_socketpair(int family, int type, int protocol,
|
STATIC int tor_ersatz_socketpair(int family, int type, int protocol,
|
||||||
tor_socket_t fd[2]);
|
tor_socket_t fd[2]);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(COMPAT_PRIVATE) */
|
||||||
|
|
||||||
ssize_t tor_getpass(const char *prompt, char *output, size_t buflen);
|
ssize_t tor_getpass(const char *prompt, char *output, size_t buflen);
|
||||||
|
|
||||||
/* This needs some of the declarations above so we include it here. */
|
/* This needs some of the declarations above so we include it here. */
|
||||||
#include "compat_threads.h"
|
#include "compat_threads.h"
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_COMPAT_H) */
|
||||||
|
|
||||||
|
@ -88,8 +88,8 @@ static struct event_base *the_event_base = NULL;
|
|||||||
(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1040)
|
(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1040)
|
||||||
#else
|
#else
|
||||||
#define MACOSX_KQUEUE_IS_BROKEN 0
|
#define MACOSX_KQUEUE_IS_BROKEN 0
|
||||||
#endif
|
#endif /* defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) */
|
||||||
#endif
|
#endif /* defined(__APPLE__) */
|
||||||
|
|
||||||
/** Initialize the Libevent library and set up the event base. */
|
/** Initialize the Libevent library and set up the event base. */
|
||||||
void
|
void
|
||||||
@ -250,7 +250,7 @@ tor_gettimeofday_cache_clear(void)
|
|||||||
{
|
{
|
||||||
event_base_update_cache_time(the_event_base);
|
event_base_update_cache_time(the_event_base);
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(LIBEVENT_VERSION_NUMBER) && ...) */
|
||||||
/** Cache the current hi-res time; the cache gets reset when libevent
|
/** Cache the current hi-res time; the cache gets reset when libevent
|
||||||
* calls us. */
|
* calls us. */
|
||||||
static struct timeval cached_time_hires = {0, 0};
|
static struct timeval cached_time_hires = {0, 0};
|
||||||
@ -290,6 +290,6 @@ tor_libevent_postfork(void)
|
|||||||
int r = event_reinit(tor_libevent_get_base());
|
int r = event_reinit(tor_libevent_get_base());
|
||||||
tor_assert(r == 0);
|
tor_assert(r == 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
#endif
|
#endif /* defined(LIBEVENT_VERSION_NUMBER) && ... */
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ void tor_libevent_postfork(void);
|
|||||||
|
|
||||||
STATIC void
|
STATIC void
|
||||||
libevent_logging_callback(int severity, const char *msg);
|
libevent_logging_callback(int severity, const char *msg);
|
||||||
#endif
|
#endif /* defined(COMPAT_LIBEVENT_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_COMPAT_LIBEVENT_H) */
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
/* We define this macro if we're trying to build with the majorly refactored
|
/* We define this macro if we're trying to build with the majorly refactored
|
||||||
* API in OpenSSL 1.1 */
|
* API in OpenSSL 1.1 */
|
||||||
#define OPENSSL_1_1_API
|
#define OPENSSL_1_1_API
|
||||||
#endif
|
#endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0) && ... */
|
||||||
|
|
||||||
#ifndef OPENSSL_1_1_API
|
#ifndef OPENSSL_1_1_API
|
||||||
#define OPENSSL_VERSION SSLEAY_VERSION
|
#define OPENSSL_VERSION SSLEAY_VERSION
|
||||||
@ -37,11 +37,11 @@
|
|||||||
((st) == SSL3_ST_SW_SRVR_HELLO_B))
|
((st) == SSL3_ST_SW_SRVR_HELLO_B))
|
||||||
#define OSSL_HANDSHAKE_STATE int
|
#define OSSL_HANDSHAKE_STATE int
|
||||||
#define CONST_IF_OPENSSL_1_1_API
|
#define CONST_IF_OPENSSL_1_1_API
|
||||||
#else
|
#else /* !(!defined(OPENSSL_1_1_API)) */
|
||||||
#define STATE_IS_SW_SERVER_HELLO(st) \
|
#define STATE_IS_SW_SERVER_HELLO(st) \
|
||||||
((st) == TLS_ST_SW_SRVR_HELLO)
|
((st) == TLS_ST_SW_SRVR_HELLO)
|
||||||
#define CONST_IF_OPENSSL_1_1_API const
|
#define CONST_IF_OPENSSL_1_1_API const
|
||||||
#endif
|
#endif /* !defined(OPENSSL_1_1_API) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_COMPAT_OPENSSL_H) */
|
||||||
|
|
||||||
|
@ -209,13 +209,13 @@ tor_cond_init(tor_cond_t *cond)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#define USE_COND_CLOCK CLOCK_MONOTONIC
|
#define USE_COND_CLOCK CLOCK_MONOTONIC
|
||||||
#else /* !defined HAVE_PTHREAD_CONDATTR_SETCLOCK */
|
#else /* !(defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && ...) */
|
||||||
/* On OSX Sierra, there is no pthread_condattr_setclock, so we are stuck
|
/* On OSX Sierra, there is no pthread_condattr_setclock, so we are stuck
|
||||||
* with the realtime clock.
|
* with the realtime clock.
|
||||||
*/
|
*/
|
||||||
#define USE_COND_CLOCK CLOCK_REALTIME
|
#define USE_COND_CLOCK CLOCK_REALTIME
|
||||||
#endif /* which clock to use */
|
#endif /* defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && ... */
|
||||||
#endif /* HAVE_CLOCK_GETTIME */
|
#endif /* defined(HAVE_CLOCK_GETTIME) */
|
||||||
if (pthread_cond_init(&cond->cond, &condattr)) {
|
if (pthread_cond_init(&cond->cond, &condattr)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -267,11 +267,11 @@ tor_cond_wait(tor_cond_t *cond, tor_mutex_t *mutex, const struct timeval *tv)
|
|||||||
tvnow.tv_sec = ts.tv_sec;
|
tvnow.tv_sec = ts.tv_sec;
|
||||||
tvnow.tv_usec = (int)(ts.tv_nsec / 1000);
|
tvnow.tv_usec = (int)(ts.tv_nsec / 1000);
|
||||||
timeradd(tv, &tvnow, &tvsum);
|
timeradd(tv, &tvnow, &tvsum);
|
||||||
#else
|
#else /* !(defined(HAVE_CLOCK_GETTIME) && defined(USE_COND_CLOCK)) */
|
||||||
if (gettimeofday(&tvnow, NULL) < 0)
|
if (gettimeofday(&tvnow, NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
timeradd(tv, &tvnow, &tvsum);
|
timeradd(tv, &tvnow, &tvsum);
|
||||||
#endif /* HAVE_CLOCK_GETTIME, CLOCK_MONOTONIC */
|
#endif /* defined(HAVE_CLOCK_GETTIME) && defined(USE_COND_CLOCK) */
|
||||||
|
|
||||||
ts.tv_sec = tvsum.tv_sec;
|
ts.tv_sec = tvsum.tv_sec;
|
||||||
ts.tv_nsec = tvsum.tv_usec * 1000;
|
ts.tv_nsec = tvsum.tv_usec * 1000;
|
||||||
|
@ -24,5 +24,5 @@ const char *rust_str_get(const rust_str_t);
|
|||||||
|
|
||||||
rust_str_t rust_welcome_string(void);
|
rust_str_t rust_welcome_string(void);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_RUST_COMPAT_H) */
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ read_ni(int fd, void *buf, size_t n)
|
|||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_EVENTFD) || defined(HAVE_PIPE) */
|
||||||
|
|
||||||
/** As send(), but retry on EINTR, and return the negative error code on
|
/** As send(), but retry on EINTR, and return the negative error code on
|
||||||
* error. */
|
* error. */
|
||||||
@ -186,7 +186,7 @@ eventfd_drain(int fd)
|
|||||||
return r;
|
return r;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_EVENTFD) */
|
||||||
|
|
||||||
#ifdef HAVE_PIPE
|
#ifdef HAVE_PIPE
|
||||||
/** Send a byte over a pipe. Return 0 on success or EAGAIN; -1 on error */
|
/** Send a byte over a pipe. Return 0 on success or EAGAIN; -1 on error */
|
||||||
@ -214,7 +214,7 @@ pipe_drain(int fd)
|
|||||||
/* A value of r = 0 means EOF on the fd so successfully drained. */
|
/* A value of r = 0 means EOF on the fd so successfully drained. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_PIPE) */
|
||||||
|
|
||||||
/** Send a byte on socket <b>fd</b>t. Return 0 on success or EAGAIN,
|
/** Send a byte on socket <b>fd</b>t. Return 0 on success or EAGAIN,
|
||||||
* -1 on error. */
|
* -1 on error. */
|
||||||
@ -276,7 +276,7 @@ alert_sockets_create(alert_sockets_t *socks_out, uint32_t flags)
|
|||||||
socks_out->drain_fn = eventfd_drain;
|
socks_out->drain_fn = eventfd_drain;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_EVENTFD) */
|
||||||
|
|
||||||
#ifdef HAVE_PIPE2
|
#ifdef HAVE_PIPE2
|
||||||
/* Now we're going to try pipes. First type the pipe2() syscall, if we
|
/* Now we're going to try pipes. First type the pipe2() syscall, if we
|
||||||
@ -289,7 +289,7 @@ alert_sockets_create(alert_sockets_t *socks_out, uint32_t flags)
|
|||||||
socks_out->drain_fn = pipe_drain;
|
socks_out->drain_fn = pipe_drain;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_PIPE2) */
|
||||||
|
|
||||||
#ifdef HAVE_PIPE
|
#ifdef HAVE_PIPE
|
||||||
/* Now try the regular pipe() syscall. Pipes have a bit lower overhead than
|
/* Now try the regular pipe() syscall. Pipes have a bit lower overhead than
|
||||||
@ -313,7 +313,7 @@ alert_sockets_create(alert_sockets_t *socks_out, uint32_t flags)
|
|||||||
socks_out->drain_fn = pipe_drain;
|
socks_out->drain_fn = pipe_drain;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_PIPE) */
|
||||||
|
|
||||||
/* If nothing else worked, fall back on socketpair(). */
|
/* If nothing else worked, fall back on socketpair(). */
|
||||||
if (!(flags & ASOCKS_NOSOCKETPAIR) &&
|
if (!(flags & ASOCKS_NOSOCKETPAIR) &&
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define USE_PTHREADS
|
#define USE_PTHREADS
|
||||||
#else
|
#else
|
||||||
#error "No threading system was found"
|
#error "No threading system was found"
|
||||||
#endif
|
#endif /* defined(_WIN32) || ... */
|
||||||
|
|
||||||
int spawn_func(void (*func)(void *), void *data);
|
int spawn_func(void (*func)(void *), void *data);
|
||||||
void spawn_exit(void) ATTR_NORETURN;
|
void spawn_exit(void) ATTR_NORETURN;
|
||||||
@ -41,7 +41,7 @@ typedef struct tor_mutex_t {
|
|||||||
#else
|
#else
|
||||||
/** No-threads only: Dummy variable so that tor_mutex_t takes up space. */
|
/** No-threads only: Dummy variable so that tor_mutex_t takes up space. */
|
||||||
int _unused;
|
int _unused;
|
||||||
#endif
|
#endif /* defined(USE_WIN32_THREADS) || ... */
|
||||||
} tor_mutex_t;
|
} tor_mutex_t;
|
||||||
|
|
||||||
tor_mutex_t *tor_mutex_new(void);
|
tor_mutex_t *tor_mutex_new(void);
|
||||||
@ -73,7 +73,7 @@ typedef struct tor_cond_t {
|
|||||||
int generation;
|
int generation;
|
||||||
#else
|
#else
|
||||||
#error no known condition implementation.
|
#error no known condition implementation.
|
||||||
#endif
|
#endif /* defined(USE_PTHREADS) || ... */
|
||||||
} tor_cond_t;
|
} tor_cond_t;
|
||||||
|
|
||||||
tor_cond_t *tor_cond_new(void);
|
tor_cond_t *tor_cond_new(void);
|
||||||
@ -161,5 +161,5 @@ void atomic_counter_add(atomic_counter_t *counter, size_t add);
|
|||||||
void atomic_counter_sub(atomic_counter_t *counter, size_t sub);
|
void atomic_counter_sub(atomic_counter_t *counter, size_t sub);
|
||||||
size_t atomic_counter_get(atomic_counter_t *counter);
|
size_t atomic_counter_get(atomic_counter_t *counter);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_COMPAT_THREADS_H) */
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
/* as fallback implementation for tor_sleep_msec */
|
/* as fallback implementation for tor_sleep_msec */
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <mach/mach_time.h>
|
#include <mach/mach_time.h>
|
||||||
@ -64,9 +64,9 @@ tor_sleep_msec(int msec)
|
|||||||
select(0, NULL, NULL, NULL, &tv);
|
select(0, NULL, NULL, NULL, &tv);
|
||||||
#else
|
#else
|
||||||
sleep(CEIL_DIV(msec, 1000));
|
sleep(CEIL_DIV(msec, 1000));
|
||||||
#endif
|
#endif /* defined(_WIN32) || ... */
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/** Set *timeval to the current time of day. On error, log and terminate.
|
/** Set *timeval to the current time of day. On error, log and terminate.
|
||||||
* (Same as gettimeofday(timeval,NULL), but never returns -1.)
|
* (Same as gettimeofday(timeval,NULL), but never returns -1.)
|
||||||
@ -112,7 +112,7 @@ tor_gettimeofday(struct timeval *timeval)
|
|||||||
timeval->tv_usec = tb.millitm * 1000;
|
timeval->tv_usec = tb.millitm * 1000;
|
||||||
#else
|
#else
|
||||||
#error "No way to get time."
|
#error "No way to get time."
|
||||||
#endif
|
#endif /* defined(_WIN32) || ... */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,8 +187,8 @@ monotime_coarse_set_mock_time_nsec(int64_t nsec)
|
|||||||
tor_assert_nonfatal(monotime_mocking_enabled == 1);
|
tor_assert_nonfatal(monotime_mocking_enabled == 1);
|
||||||
mock_time_nsec_coarse = nsec;
|
mock_time_nsec_coarse = nsec;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(MONOTIME_COARSE_FN_IS_DIFFERENT) */
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/* "ratchet" functions for monotonic time. */
|
/* "ratchet" functions for monotonic time. */
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ ratchet_coarse_performance_counter(const int64_t count_raw)
|
|||||||
last_tick_count = count;
|
last_tick_count = count;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) || defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#if defined(MONOTIME_USING_GETTIMEOFDAY) || defined(TOR_UNIT_TESTS)
|
#if defined(MONOTIME_USING_GETTIMEOFDAY) || defined(TOR_UNIT_TESTS)
|
||||||
static struct timeval last_timeofday = { 0, 0 };
|
static struct timeval last_timeofday = { 0, 0 };
|
||||||
@ -259,7 +259,7 @@ ratchet_timeval(const struct timeval *timeval_raw, struct timeval *out)
|
|||||||
memcpy(&last_timeofday, out, sizeof(struct timeval));
|
memcpy(&last_timeofday, out, sizeof(struct timeval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(MONOTIME_USING_GETTIMEOFDAY) || defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#ifdef TOR_UNIT_TESTS
|
#ifdef TOR_UNIT_TESTS
|
||||||
/** For testing: reset all the ratchets */
|
/** For testing: reset all the ratchets */
|
||||||
@ -271,7 +271,7 @@ monotime_reset_ratchets_for_testing(void)
|
|||||||
memset(&last_timeofday, 0, sizeof(struct timeval));
|
memset(&last_timeofday, 0, sizeof(struct timeval));
|
||||||
memset(&timeofday_offset, 0, sizeof(struct timeval));
|
memset(&timeofday_offset, 0, sizeof(struct timeval));
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ monotime_get(monotime_t *out)
|
|||||||
/ mach_time_info.numer;
|
/ mach_time_info.numer;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
out->abstime_ = mach_absolute_time();
|
out->abstime_ = mach_absolute_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ monotime_diff_nsec(const monotime_t *start,
|
|||||||
* an old Linux kernel. In that case, we will fall back to CLOCK_MONOTONIC.
|
* an old Linux kernel. In that case, we will fall back to CLOCK_MONOTONIC.
|
||||||
*/
|
*/
|
||||||
static int clock_monotonic_coarse = CLOCK_MONOTONIC_COARSE;
|
static int clock_monotonic_coarse = CLOCK_MONOTONIC_COARSE;
|
||||||
#endif
|
#endif /* defined(CLOCK_MONOTONIC_COARSE) */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
monotime_init_internal(void)
|
monotime_init_internal(void)
|
||||||
@ -344,7 +344,7 @@ monotime_init_internal(void)
|
|||||||
"falling back to CLOCK_MONOTONIC.", strerror(errno));
|
"falling back to CLOCK_MONOTONIC.", strerror(errno));
|
||||||
clock_monotonic_coarse = CLOCK_MONOTONIC;
|
clock_monotonic_coarse = CLOCK_MONOTONIC;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(CLOCK_MONOTONIC_COARSE) */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -356,7 +356,7 @@ monotime_get(monotime_t *out)
|
|||||||
out->ts_.tv_nsec = (int) (mock_time_nsec % ONE_BILLION);
|
out->ts_.tv_nsec = (int) (mock_time_nsec % ONE_BILLION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
int r = clock_gettime(CLOCK_MONOTONIC, &out->ts_);
|
int r = clock_gettime(CLOCK_MONOTONIC, &out->ts_);
|
||||||
tor_assert(r == 0);
|
tor_assert(r == 0);
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ monotime_coarse_get(monotime_coarse_t *out)
|
|||||||
out->ts_.tv_nsec = (int) (mock_time_nsec_coarse % ONE_BILLION);
|
out->ts_.tv_nsec = (int) (mock_time_nsec_coarse % ONE_BILLION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
int r = clock_gettime(clock_monotonic_coarse, &out->ts_);
|
int r = clock_gettime(clock_monotonic_coarse, &out->ts_);
|
||||||
if (PREDICT_UNLIKELY(r < 0) &&
|
if (PREDICT_UNLIKELY(r < 0) &&
|
||||||
errno == EINVAL &&
|
errno == EINVAL &&
|
||||||
@ -386,7 +386,7 @@ monotime_coarse_get(monotime_coarse_t *out)
|
|||||||
|
|
||||||
tor_assert(r == 0);
|
tor_assert(r == 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(CLOCK_MONOTONIC_COARSE) */
|
||||||
|
|
||||||
int64_t
|
int64_t
|
||||||
monotime_diff_nsec(const monotime_t *start,
|
monotime_diff_nsec(const monotime_t *start,
|
||||||
@ -462,7 +462,7 @@ monotime_get(monotime_t *out)
|
|||||||
/ nsec_per_tick_numer;
|
/ nsec_per_tick_numer;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/* Alas, QueryPerformanceCounter is not always monotonic: see bug list at
|
/* Alas, QueryPerformanceCounter is not always monotonic: see bug list at
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ monotime_coarse_get(monotime_coarse_t *out)
|
|||||||
out->tick_count_ = mock_time_nsec_coarse / ONE_MILLION;
|
out->tick_count_ = mock_time_nsec_coarse / ONE_MILLION;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
if (GetTickCount64_fn) {
|
if (GetTickCount64_fn) {
|
||||||
out->tick_count_ = (int64_t)GetTickCount64_fn();
|
out->tick_count_ = (int64_t)GetTickCount64_fn();
|
||||||
@ -570,7 +570,7 @@ monotime_diff_nsec(const monotime_t *start,
|
|||||||
/* end of "MONOTIME_USING_GETTIMEOFDAY" */
|
/* end of "MONOTIME_USING_GETTIMEOFDAY" */
|
||||||
#else
|
#else
|
||||||
#error "No way to implement monotonic timers."
|
#error "No way to implement monotonic timers."
|
||||||
#endif
|
#endif /* defined(__APPLE__) || ... */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the monotonic timer subsystem. Must be called before any
|
* Initialize the monotonic timer subsystem. Must be called before any
|
||||||
@ -653,5 +653,5 @@ monotime_coarse_absolute_msec(void)
|
|||||||
{
|
{
|
||||||
return monotime_coarse_absolute_nsec() / ONE_MILLION;
|
return monotime_coarse_absolute_nsec() / ONE_MILLION;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(MONOTIME_COARSE_FN_IS_DIFFERENT) */
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ struct timeval {
|
|||||||
time_t tv_sec;
|
time_t tv_sec;
|
||||||
unsigned int tv_usec;
|
unsigned int tv_usec;
|
||||||
};
|
};
|
||||||
#endif
|
#endif /* !defined(HAVE_STRUCT_TIMEVAL_TV_SEC) */
|
||||||
|
|
||||||
/** Represents a monotonic timer in a platform-dependent way. */
|
/** Represents a monotonic timer in a platform-dependent way. */
|
||||||
typedef struct monotime_t {
|
typedef struct monotime_t {
|
||||||
@ -51,7 +51,7 @@ typedef struct monotime_t {
|
|||||||
#define MONOTIME_USING_GETTIMEOFDAY
|
#define MONOTIME_USING_GETTIMEOFDAY
|
||||||
/* Otherwise, we will be stuck using gettimeofday. */
|
/* Otherwise, we will be stuck using gettimeofday. */
|
||||||
struct timeval tv_;
|
struct timeval tv_;
|
||||||
#endif
|
#endif /* defined(__APPLE__) || ... */
|
||||||
} monotime_t;
|
} monotime_t;
|
||||||
|
|
||||||
#if defined(CLOCK_MONOTONIC_COARSE) && \
|
#if defined(CLOCK_MONOTONIC_COARSE) && \
|
||||||
@ -67,7 +67,7 @@ typedef struct monotime_coarse_t {
|
|||||||
} monotime_coarse_t;
|
} monotime_coarse_t;
|
||||||
#else
|
#else
|
||||||
#define monotime_coarse_t monotime_t
|
#define monotime_coarse_t monotime_t
|
||||||
#endif
|
#endif /* defined(CLOCK_MONOTONIC_COARSE) && ... || ... */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the timing subsystem. This function is idempotent.
|
* Initialize the timing subsystem. This function is idempotent.
|
||||||
@ -110,12 +110,12 @@ void monotime_coarse_get(monotime_coarse_t *out);
|
|||||||
uint64_t monotime_coarse_absolute_nsec(void);
|
uint64_t monotime_coarse_absolute_nsec(void);
|
||||||
uint64_t monotime_coarse_absolute_usec(void);
|
uint64_t monotime_coarse_absolute_usec(void);
|
||||||
uint64_t monotime_coarse_absolute_msec(void);
|
uint64_t monotime_coarse_absolute_msec(void);
|
||||||
#else
|
#else /* !(defined(MONOTIME_COARSE_FN_IS_DIFFERENT)) */
|
||||||
#define monotime_coarse_get monotime_get
|
#define monotime_coarse_get monotime_get
|
||||||
#define monotime_coarse_absolute_nsec monotime_absolute_nsec
|
#define monotime_coarse_absolute_nsec monotime_absolute_nsec
|
||||||
#define monotime_coarse_absolute_usec monotime_absolute_usec
|
#define monotime_coarse_absolute_usec monotime_absolute_usec
|
||||||
#define monotime_coarse_absolute_msec monotime_absolute_msec
|
#define monotime_coarse_absolute_msec monotime_absolute_msec
|
||||||
#endif
|
#endif /* defined(MONOTIME_COARSE_FN_IS_DIFFERENT) */
|
||||||
|
|
||||||
#if defined(MONOTIME_COARSE_TYPE_IS_DIFFERENT)
|
#if defined(MONOTIME_COARSE_TYPE_IS_DIFFERENT)
|
||||||
int64_t monotime_coarse_diff_nsec(const monotime_coarse_t *start,
|
int64_t monotime_coarse_diff_nsec(const monotime_coarse_t *start,
|
||||||
@ -124,11 +124,11 @@ int64_t monotime_coarse_diff_usec(const monotime_coarse_t *start,
|
|||||||
const monotime_coarse_t *end);
|
const monotime_coarse_t *end);
|
||||||
int64_t monotime_coarse_diff_msec(const monotime_coarse_t *start,
|
int64_t monotime_coarse_diff_msec(const monotime_coarse_t *start,
|
||||||
const monotime_coarse_t *end);
|
const monotime_coarse_t *end);
|
||||||
#else
|
#else /* !(defined(MONOTIME_COARSE_TYPE_IS_DIFFERENT)) */
|
||||||
#define monotime_coarse_diff_nsec monotime_diff_nsec
|
#define monotime_coarse_diff_nsec monotime_diff_nsec
|
||||||
#define monotime_coarse_diff_usec monotime_diff_usec
|
#define monotime_coarse_diff_usec monotime_diff_usec
|
||||||
#define monotime_coarse_diff_msec monotime_diff_msec
|
#define monotime_coarse_diff_msec monotime_diff_msec
|
||||||
#endif
|
#endif /* defined(MONOTIME_COARSE_TYPE_IS_DIFFERENT) */
|
||||||
|
|
||||||
void tor_gettimeofday(struct timeval *timeval);
|
void tor_gettimeofday(struct timeval *timeval);
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ void monotime_coarse_set_mock_time_nsec(int64_t);
|
|||||||
#else
|
#else
|
||||||
#define monotime_coarse_set_mock_time_nsec monotime_set_mock_time_nsec
|
#define monotime_coarse_set_mock_time_nsec monotime_set_mock_time_nsec
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#ifdef COMPAT_TIME_PRIVATE
|
#ifdef COMPAT_TIME_PRIVATE
|
||||||
#if defined(_WIN32) || defined(TOR_UNIT_TESTS)
|
#if defined(_WIN32) || defined(TOR_UNIT_TESTS)
|
||||||
@ -157,7 +157,7 @@ STATIC void ratchet_timeval(const struct timeval *timeval_raw,
|
|||||||
#ifdef TOR_UNIT_TESTS
|
#ifdef TOR_UNIT_TESTS
|
||||||
void monotime_reset_ratchets_for_testing(void);
|
void monotime_reset_ratchets_for_testing(void);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(COMPAT_TIME_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_COMPAT_TIME_H) */
|
||||||
|
|
||||||
|
@ -246,5 +246,5 @@ tor_threads_init(void)
|
|||||||
set_main_thread();
|
set_main_thread();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
|
@ -85,5 +85,5 @@ size_t tor_compress_state_size(const tor_compress_state_t *state);
|
|||||||
|
|
||||||
void tor_compress_init(void);
|
void tor_compress_init(void);
|
||||||
|
|
||||||
#endif // TOR_COMPRESS_H.
|
#endif /* !defined(TOR_COMPRESS_H) */
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ lzma_error_str(lzma_ret error)
|
|||||||
return "Unknown LZMA error";
|
return "Unknown LZMA error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // HAVE_LZMA.
|
#endif /* defined(HAVE_LZMA) */
|
||||||
|
|
||||||
/** Return 1 if LZMA compression is supported; otherwise 0. */
|
/** Return 1 if LZMA compression is supported; otherwise 0. */
|
||||||
int
|
int
|
||||||
@ -161,7 +161,7 @@ tor_lzma_state_size_precalc(int compress, compression_level_t level)
|
|||||||
err:
|
err:
|
||||||
return 0; // LCOV_EXCL_LINE
|
return 0; // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
#endif // HAVE_LZMA.
|
#endif /* defined(HAVE_LZMA) */
|
||||||
|
|
||||||
/** Construct and return a tor_lzma_compress_state_t object using
|
/** Construct and return a tor_lzma_compress_state_t object using
|
||||||
* <b>method</b>. If <b>compress</b>, it's for compression; otherwise it's for
|
* <b>method</b>. If <b>compress</b>, it's for compression; otherwise it's for
|
||||||
@ -215,13 +215,13 @@ tor_lzma_compress_new(int compress,
|
|||||||
err:
|
err:
|
||||||
tor_free(result); // LCOV_EXCL_LINE
|
tor_free(result); // LCOV_EXCL_LINE
|
||||||
return NULL;
|
return NULL;
|
||||||
#else // HAVE_LZMA.
|
#else /* !(defined(HAVE_LZMA)) */
|
||||||
(void)compress;
|
(void)compress;
|
||||||
(void)method;
|
(void)method;
|
||||||
(void)level;
|
(void)level;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif // HAVE_LZMA.
|
#endif /* defined(HAVE_LZMA) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compress/decompress some bytes using <b>state</b>. Read up to
|
/** Compress/decompress some bytes using <b>state</b>. Read up to
|
||||||
@ -306,7 +306,7 @@ tor_lzma_compress_process(tor_lzma_compress_state_t *state,
|
|||||||
lzma_error_str(retval));
|
lzma_error_str(retval));
|
||||||
return TOR_COMPRESS_ERROR;
|
return TOR_COMPRESS_ERROR;
|
||||||
}
|
}
|
||||||
#else // HAVE_LZMA.
|
#else /* !(defined(HAVE_LZMA)) */
|
||||||
(void)state;
|
(void)state;
|
||||||
(void)out;
|
(void)out;
|
||||||
(void)out_len;
|
(void)out_len;
|
||||||
@ -314,7 +314,7 @@ tor_lzma_compress_process(tor_lzma_compress_state_t *state,
|
|||||||
(void)in_len;
|
(void)in_len;
|
||||||
(void)finish;
|
(void)finish;
|
||||||
return TOR_COMPRESS_ERROR;
|
return TOR_COMPRESS_ERROR;
|
||||||
#endif // HAVE_LZMA.
|
#endif /* defined(HAVE_LZMA) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Deallocate <b>state</b>. */
|
/** Deallocate <b>state</b>. */
|
||||||
|
@ -39,5 +39,5 @@ size_t tor_lzma_get_total_allocation(void);
|
|||||||
|
|
||||||
void tor_lzma_init(void);
|
void tor_lzma_init(void);
|
||||||
|
|
||||||
#endif // TOR_COMPRESS_LZMA_H.
|
#endif /* !defined(TOR_COMPRESS_LZMA_H) */
|
||||||
|
|
||||||
|
@ -16,5 +16,5 @@ tor_cnone_compress_process(char **out, size_t *out_len,
|
|||||||
const char **in, size_t *in_len,
|
const char **in, size_t *in_len,
|
||||||
int finish);
|
int finish);
|
||||||
|
|
||||||
#endif // TOR_COMPRESS_NONE_H.
|
#endif /* !defined(TOR_COMPRESS_NONE_H) */
|
||||||
|
|
||||||
|
@ -39,5 +39,5 @@ size_t tor_zlib_get_total_allocation(void);
|
|||||||
|
|
||||||
void tor_zlib_init(void);
|
void tor_zlib_init(void);
|
||||||
|
|
||||||
#endif // TOR_COMPRESS_ZLIB_H.
|
#endif /* !defined(TOR_COMPRESS_ZLIB_H) */
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ memory_level(compression_level_t level)
|
|||||||
case LOW_COMPRESSION: return 7;
|
case LOW_COMPRESSION: return 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // HAVE_ZSTD.
|
#endif /* defined(HAVE_ZSTD) */
|
||||||
|
|
||||||
/** Return 1 if Zstandard compression is supported; otherwise 0. */
|
/** Return 1 if Zstandard compression is supported; otherwise 0. */
|
||||||
int
|
int
|
||||||
@ -68,9 +68,9 @@ tor_zstd_get_version_str(void)
|
|||||||
version_number % 100);
|
version_number % 100);
|
||||||
|
|
||||||
return version_str;
|
return version_str;
|
||||||
#else
|
#else /* !(defined(HAVE_ZSTD)) */
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif /* defined(HAVE_ZSTD) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a string representation of the version of the version of libzstd
|
/** Return a string representation of the version of the version of libzstd
|
||||||
@ -95,7 +95,7 @@ struct tor_zstd_compress_state_t {
|
|||||||
/** Decompression stream. Used when <b>compress</b> is false. */
|
/** Decompression stream. Used when <b>compress</b> is false. */
|
||||||
ZSTD_DStream *decompress_stream;
|
ZSTD_DStream *decompress_stream;
|
||||||
} u; /**< Zstandard stream objects. */
|
} u; /**< Zstandard stream objects. */
|
||||||
#endif // HAVE_ZSTD.
|
#endif /* defined(HAVE_ZSTD) */
|
||||||
|
|
||||||
int compress; /**< True if we are compressing; false if we are inflating */
|
int compress; /**< True if we are compressing; false if we are inflating */
|
||||||
int have_called_end; /**< True if we are compressing and we've called
|
int have_called_end; /**< True if we are compressing and we've called
|
||||||
@ -171,7 +171,7 @@ tor_zstd_state_size_precalc(int compress, int preset)
|
|||||||
|
|
||||||
return memory_usage;
|
return memory_usage;
|
||||||
}
|
}
|
||||||
#endif // HAVE_ZSTD.
|
#endif /* defined(HAVE_ZSTD) */
|
||||||
|
|
||||||
/** Construct and return a tor_zstd_compress_state_t object using
|
/** Construct and return a tor_zstd_compress_state_t object using
|
||||||
* <b>method</b>. If <b>compress</b>, it's for compression; otherwise it's for
|
* <b>method</b>. If <b>compress</b>, it's for compression; otherwise it's for
|
||||||
@ -248,13 +248,13 @@ tor_zstd_compress_new(int compress,
|
|||||||
tor_free(result);
|
tor_free(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
#else // HAVE_ZSTD.
|
#else /* !(defined(HAVE_ZSTD)) */
|
||||||
(void)compress;
|
(void)compress;
|
||||||
(void)method;
|
(void)method;
|
||||||
(void)level;
|
(void)level;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif // HAVE_ZSTD.
|
#endif /* defined(HAVE_ZSTD) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compress/decompress some bytes using <b>state</b>. Read up to
|
/** Compress/decompress some bytes using <b>state</b>. Read up to
|
||||||
@ -385,7 +385,7 @@ tor_zstd_compress_process(tor_zstd_compress_state_t *state,
|
|||||||
return TOR_COMPRESS_OK;
|
return TOR_COMPRESS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // HAVE_ZSTD.
|
#else /* !(defined(HAVE_ZSTD)) */
|
||||||
(void)state;
|
(void)state;
|
||||||
(void)out;
|
(void)out;
|
||||||
(void)out_len;
|
(void)out_len;
|
||||||
@ -394,7 +394,7 @@ tor_zstd_compress_process(tor_zstd_compress_state_t *state,
|
|||||||
(void)finish;
|
(void)finish;
|
||||||
|
|
||||||
return TOR_COMPRESS_ERROR;
|
return TOR_COMPRESS_ERROR;
|
||||||
#endif // HAVE_ZSTD.
|
#endif /* defined(HAVE_ZSTD) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Deallocate <b>state</b>. */
|
/** Deallocate <b>state</b>. */
|
||||||
@ -412,7 +412,7 @@ tor_zstd_compress_free(tor_zstd_compress_state_t *state)
|
|||||||
} else {
|
} else {
|
||||||
ZSTD_freeDStream(state->u.decompress_stream);
|
ZSTD_freeDStream(state->u.decompress_stream);
|
||||||
}
|
}
|
||||||
#endif // HAVE_ZSTD.
|
#endif /* defined(HAVE_ZSTD) */
|
||||||
|
|
||||||
tor_free(state);
|
tor_free(state);
|
||||||
}
|
}
|
||||||
|
@ -39,5 +39,5 @@ size_t tor_zstd_get_total_allocation(void);
|
|||||||
|
|
||||||
void tor_zstd_init(void);
|
void tor_zstd_init(void);
|
||||||
|
|
||||||
#endif // TOR_COMPRESS_ZSTD_H.
|
#endif /* !defined(TOR_COMPRESS_ZSTD_H) */
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ config_process_include(const char *path, int recursion_level, int extended,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tor_free(unquoted_path);
|
tor_free(unquoted_path);
|
||||||
#endif
|
#endif /* 0 */
|
||||||
smartlist_t *config_files = config_get_file_list(path);
|
smartlist_t *config_files = config_get_file_list(path);
|
||||||
if (!config_files) {
|
if (!config_files) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -49,5 +49,5 @@ void config_free_lines(config_line_t *front);
|
|||||||
const char *parse_config_line_from_str_verbose(const char *line,
|
const char *parse_config_line_from_str_verbose(const char *line,
|
||||||
char **key_out, char **value_out,
|
char **key_out, char **value_out,
|
||||||
const char **err_out);
|
const char **err_out);
|
||||||
#endif
|
#endif /* !defined(TOR_CONFLINE_H) */
|
||||||
|
|
||||||
|
@ -74,11 +74,11 @@ static inline void smartlist_set(smartlist_t *sl, int idx, void *val) {
|
|||||||
tor_assert(sl->num_used > idx);
|
tor_assert(sl->num_used > idx);
|
||||||
sl->list[idx] = val;
|
sl->list[idx] = val;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(DEBUG_SMARTLIST)) */
|
||||||
#define smartlist_len(sl) ((sl)->num_used)
|
#define smartlist_len(sl) ((sl)->num_used)
|
||||||
#define smartlist_get(sl, idx) ((sl)->list[idx])
|
#define smartlist_get(sl, idx) ((sl)->list[idx])
|
||||||
#define smartlist_set(sl, idx, val) ((sl)->list[idx] = (val))
|
#define smartlist_set(sl, idx, val) ((sl)->list[idx] = (val))
|
||||||
#endif
|
#endif /* defined(DEBUG_SMARTLIST) */
|
||||||
|
|
||||||
/** Exchange the elements at indices <b>idx1</b> and <b>idx2</b> of the
|
/** Exchange the elements at indices <b>idx1</b> and <b>idx2</b> of the
|
||||||
* smartlist <b>sl</b>. */
|
* smartlist <b>sl</b>. */
|
||||||
@ -580,7 +580,7 @@ void* strmap_remove_lc(strmap_t *map, const char *key);
|
|||||||
#define BITARRAY_SHIFT 6
|
#define BITARRAY_SHIFT 6
|
||||||
#else
|
#else
|
||||||
#error "int is neither 4 nor 8 bytes. I can't deal with that."
|
#error "int is neither 4 nor 8 bytes. I can't deal with that."
|
||||||
#endif
|
#endif /* SIZEOF_INT == 4 || ... */
|
||||||
#define BITARRAY_MASK ((1u<<BITARRAY_SHIFT)-1)
|
#define BITARRAY_MASK ((1u<<BITARRAY_SHIFT)-1)
|
||||||
|
|
||||||
/** A random-access array of one-bit-wide elements. */
|
/** A random-access array of one-bit-wide elements. */
|
||||||
@ -723,5 +723,5 @@ third_quartile_uint32(uint32_t *array, int n_elements)
|
|||||||
return find_nth_uint32(array, n_elements, (n_elements*3)/4);
|
return find_nth_uint32(array, n_elements, (n_elements*3)/4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CONTAINER_H) */
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
/* Windows defines this; so does OpenSSL 0.9.8h and later. We don't actually
|
/* Windows defines this; so does OpenSSL 0.9.8h and later. We don't actually
|
||||||
* use either definition. */
|
* use either definition. */
|
||||||
#undef OCSP_RESPONSE
|
#undef OCSP_RESPONSE
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
#define CRYPTO_PRIVATE
|
#define CRYPTO_PRIVATE
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
@ -50,7 +50,7 @@ ENABLE_GCC_WARNING(redundant-decls)
|
|||||||
#else
|
#else
|
||||||
#pragma GCC diagnostic warning "-Wredundant-decls"
|
#pragma GCC diagnostic warning "-Wredundant-decls"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* __GNUC__ && GCC_VERSION >= 402 */
|
||||||
|
|
||||||
#ifdef HAVE_CTYPE_H
|
#ifdef HAVE_CTYPE_H
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -101,7 +101,7 @@ ENABLE_GCC_WARNING(redundant-decls)
|
|||||||
* pointless, so let's not.
|
* pointless, so let's not.
|
||||||
*/
|
*/
|
||||||
#define NEW_THREAD_API
|
#define NEW_THREAD_API
|
||||||
#endif
|
#endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5) && ... */
|
||||||
|
|
||||||
/** Longest recognized */
|
/** Longest recognized */
|
||||||
#define MAX_DNS_LABEL_SIZE 63
|
#define MAX_DNS_LABEL_SIZE 63
|
||||||
@ -114,7 +114,7 @@ ENABLE_GCC_WARNING(redundant-decls)
|
|||||||
static tor_mutex_t **openssl_mutexes_ = NULL;
|
static tor_mutex_t **openssl_mutexes_ = NULL;
|
||||||
/** How many mutexes have we allocated for use by OpenSSL? */
|
/** How many mutexes have we allocated for use by OpenSSL? */
|
||||||
static int n_openssl_mutexes_ = 0;
|
static int n_openssl_mutexes_ = 0;
|
||||||
#endif
|
#endif /* !defined(NEW_THREAD_API) */
|
||||||
|
|
||||||
/** A public key, or a public/private key-pair. */
|
/** A public key, or a public/private key-pair. */
|
||||||
struct crypto_pk_t
|
struct crypto_pk_t
|
||||||
@ -198,7 +198,7 @@ log_engine(const char *fn, ENGINE *e)
|
|||||||
log_info(LD_CRYPTO, "Using default implementation for %s", fn);
|
log_info(LD_CRYPTO, "Using default implementation for %s", fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(DISABLE_ENGINES) */
|
||||||
|
|
||||||
#ifndef DISABLE_ENGINES
|
#ifndef DISABLE_ENGINES
|
||||||
/** Try to load an engine in a shared library via fully qualified path.
|
/** Try to load an engine in a shared library via fully qualified path.
|
||||||
@ -218,7 +218,7 @@ try_load_engine(const char *path, const char *engine)
|
|||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(DISABLE_ENGINES) */
|
||||||
|
|
||||||
/* Returns a trimmed and human-readable version of an openssl version string
|
/* Returns a trimmed and human-readable version of an openssl version string
|
||||||
* <b>raw_version</b>. They are usually in the form of 'OpenSSL 1.0.0b 10
|
* <b>raw_version</b>. They are usually in the form of 'OpenSSL 1.0.0b 10
|
||||||
@ -394,7 +394,7 @@ crypto_global_init(int useAccel, const char *accelName, const char *accelDir)
|
|||||||
#else
|
#else
|
||||||
log_engine("ECDH", ENGINE_get_default_ECDH());
|
log_engine("ECDH", ENGINE_get_default_ECDH());
|
||||||
log_engine("ECDSA", ENGINE_get_default_ECDSA());
|
log_engine("ECDSA", ENGINE_get_default_ECDSA());
|
||||||
#endif
|
#endif /* defined(OPENSSL_1_1_API) */
|
||||||
log_engine("RAND", ENGINE_get_default_RAND());
|
log_engine("RAND", ENGINE_get_default_RAND());
|
||||||
log_engine("RAND (which we will not use)", ENGINE_get_default_RAND());
|
log_engine("RAND (which we will not use)", ENGINE_get_default_RAND());
|
||||||
log_engine("SHA1", ENGINE_get_digest_engine(NID_sha1));
|
log_engine("SHA1", ENGINE_get_digest_engine(NID_sha1));
|
||||||
@ -412,7 +412,7 @@ crypto_global_init(int useAccel, const char *accelName, const char *accelDir)
|
|||||||
log_engine("AES-256-GCM", ENGINE_get_cipher_engine(NID_aes_256_gcm));
|
log_engine("AES-256-GCM", ENGINE_get_cipher_engine(NID_aes_256_gcm));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* defined(DISABLE_ENGINES) */
|
||||||
} else {
|
} else {
|
||||||
log_info(LD_CRYPTO, "NOT using OpenSSL engine support.");
|
log_info(LD_CRYPTO, "NOT using OpenSSL engine support.");
|
||||||
}
|
}
|
||||||
@ -450,9 +450,9 @@ crypto_pk_private_ok(const crypto_pk_t *k)
|
|||||||
const BIGNUM *p, *q;
|
const BIGNUM *p, *q;
|
||||||
RSA_get0_factors(k->key, &p, &q);
|
RSA_get0_factors(k->key, &p, &q);
|
||||||
return p != NULL; /* XXX/yawning: Should we check q? */
|
return p != NULL; /* XXX/yawning: Should we check q? */
|
||||||
#else
|
#else /* !(defined(OPENSSL_1_1_API)) */
|
||||||
return k && k->key && k->key->p;
|
return k && k->key && k->key->p;
|
||||||
#endif
|
#endif /* defined(OPENSSL_1_1_API) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** used by tortls.c: wrap an RSA* in a crypto_pk_t. */
|
/** used by tortls.c: wrap an RSA* in a crypto_pk_t. */
|
||||||
@ -884,7 +884,7 @@ crypto_pk_public_exponent_ok(crypto_pk_t *env)
|
|||||||
RSA_get0_key(env->key, &n, &e, &d);
|
RSA_get0_key(env->key, &n, &e, &d);
|
||||||
#else
|
#else
|
||||||
e = env->key->e;
|
e = env->key->e;
|
||||||
#endif
|
#endif /* defined(OPENSSL_1_1_API) */
|
||||||
return BN_is_word(e, 65537);
|
return BN_is_word(e, 65537);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -918,7 +918,7 @@ crypto_pk_cmp_keys(const crypto_pk_t *a, const crypto_pk_t *b)
|
|||||||
a_e = a->key->e;
|
a_e = a->key->e;
|
||||||
b_n = b->key->n;
|
b_n = b->key->n;
|
||||||
b_e = b->key->e;
|
b_e = b->key->e;
|
||||||
#endif
|
#endif /* defined(OPENSSL_1_1_API) */
|
||||||
|
|
||||||
tor_assert(a_n != NULL && a_e != NULL);
|
tor_assert(a_n != NULL && a_e != NULL);
|
||||||
tor_assert(b_n != NULL && b_e != NULL);
|
tor_assert(b_n != NULL && b_e != NULL);
|
||||||
@ -967,10 +967,10 @@ crypto_pk_num_bits(crypto_pk_t *env)
|
|||||||
tor_assert(n != NULL);
|
tor_assert(n != NULL);
|
||||||
|
|
||||||
return RSA_bits(env->key);
|
return RSA_bits(env->key);
|
||||||
#else
|
#else /* !(defined(OPENSSL_1_1_API)) */
|
||||||
tor_assert(env->key->n);
|
tor_assert(env->key->n);
|
||||||
return BN_num_bits(env->key->n);
|
return BN_num_bits(env->key->n);
|
||||||
#endif
|
#endif /* defined(OPENSSL_1_1_API) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Increase the reference count of <b>env</b>, and return it.
|
/** Increase the reference count of <b>env</b>, and return it.
|
||||||
@ -997,7 +997,7 @@ crypto_pk_assign_(crypto_pk_t *dest, const crypto_pk_t *src)
|
|||||||
RSA_free(dest->key);
|
RSA_free(dest->key);
|
||||||
dest->key = RSAPrivateKey_dup(src->key);
|
dest->key = RSAPrivateKey_dup(src->key);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/** Make a real honest-to-goodness copy of <b>env</b>, and return it.
|
/** Make a real honest-to-goodness copy of <b>env</b>, and return it.
|
||||||
* Returns NULL on failure. */
|
* Returns NULL on failure. */
|
||||||
@ -1871,7 +1871,7 @@ crypto_digest_get_algorithm(crypto_digest_t *digest)
|
|||||||
return digest->algorithm;
|
return digest->algorithm;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of bytes we need to malloc in order to get a
|
* Return the number of bytes we need to malloc in order to get a
|
||||||
@ -2255,12 +2255,12 @@ crypto_validate_dh_params(const BIGNUM *p, const BIGNUM *g)
|
|||||||
goto out;
|
goto out;
|
||||||
if (!DH_set0_pqg(dh, dh_p, NULL, dh_g))
|
if (!DH_set0_pqg(dh, dh_p, NULL, dh_g))
|
||||||
goto out;
|
goto out;
|
||||||
#else
|
#else /* !(defined(OPENSSL_1_1_API)) */
|
||||||
if (!(dh->p = BN_dup(p)))
|
if (!(dh->p = BN_dup(p)))
|
||||||
goto out;
|
goto out;
|
||||||
if (!(dh->g = BN_dup(g)))
|
if (!(dh->g = BN_dup(g)))
|
||||||
goto out;
|
goto out;
|
||||||
#endif
|
#endif /* defined(OPENSSL_1_1_API) */
|
||||||
|
|
||||||
/* Perform the validation. */
|
/* Perform the validation. */
|
||||||
int codes = 0;
|
int codes = 0;
|
||||||
@ -2431,7 +2431,7 @@ crypto_dh_new(int dh_type)
|
|||||||
|
|
||||||
if (!DH_set_length(res->dh, DH_PRIVATE_KEY_BITS))
|
if (!DH_set_length(res->dh, DH_PRIVATE_KEY_BITS))
|
||||||
goto err;
|
goto err;
|
||||||
#else
|
#else /* !(defined(OPENSSL_1_1_API)) */
|
||||||
if (dh_type == DH_TYPE_TLS) {
|
if (dh_type == DH_TYPE_TLS) {
|
||||||
if (!(res->dh->p = BN_dup(dh_param_p_tls)))
|
if (!(res->dh->p = BN_dup(dh_param_p_tls)))
|
||||||
goto err;
|
goto err;
|
||||||
@ -2444,7 +2444,7 @@ crypto_dh_new(int dh_type)
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
res->dh->length = DH_PRIVATE_KEY_BITS;
|
res->dh->length = DH_PRIVATE_KEY_BITS;
|
||||||
#endif
|
#endif /* defined(OPENSSL_1_1_API) */
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
err:
|
err:
|
||||||
@ -2506,7 +2506,7 @@ crypto_dh_generate_public(crypto_dh_t *dh)
|
|||||||
"the-universe chances really do happen. Treating as a failure.");
|
"the-universe chances really do happen. Treating as a failure.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(OPENSSL_1_1_API)) */
|
||||||
if (tor_check_dh_key(LOG_WARN, dh->dh->pub_key)<0) {
|
if (tor_check_dh_key(LOG_WARN, dh->dh->pub_key)<0) {
|
||||||
/* LCOV_EXCL_START
|
/* LCOV_EXCL_START
|
||||||
* If this happens, then openssl's DH implementation is busted. */
|
* If this happens, then openssl's DH implementation is busted. */
|
||||||
@ -2519,7 +2519,7 @@ crypto_dh_generate_public(crypto_dh_t *dh)
|
|||||||
goto again;
|
goto again;
|
||||||
/* LCOV_EXCL_STOP */
|
/* LCOV_EXCL_STOP */
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(OPENSSL_1_1_API) */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2540,7 +2540,7 @@ crypto_dh_get_public(crypto_dh_t *dh, char *pubkey, size_t pubkey_len)
|
|||||||
DH_get0_key(dh->dh, &dh_pub, &dh_priv);
|
DH_get0_key(dh->dh, &dh_pub, &dh_priv);
|
||||||
#else
|
#else
|
||||||
dh_pub = dh->dh->pub_key;
|
dh_pub = dh->dh->pub_key;
|
||||||
#endif
|
#endif /* defined(OPENSSL_1_1_API) */
|
||||||
|
|
||||||
if (!dh_pub) {
|
if (!dh_pub) {
|
||||||
if (crypto_dh_generate_public(dh)<0)
|
if (crypto_dh_generate_public(dh)<0)
|
||||||
@ -2883,7 +2883,7 @@ crypto_strongest_rand_syscall(uint8_t *out, size_t out_len)
|
|||||||
return getentropy(out, out_len);
|
return getentropy(out, out_len);
|
||||||
#else
|
#else
|
||||||
(void) out;
|
(void) out;
|
||||||
#endif
|
#endif /* defined(_WIN32) || ... */
|
||||||
|
|
||||||
/* This platform doesn't have a supported syscall based random. */
|
/* This platform doesn't have a supported syscall based random. */
|
||||||
return -1;
|
return -1;
|
||||||
@ -2907,7 +2907,7 @@ crypto_strongest_rand_fallback(uint8_t *out, size_t out_len)
|
|||||||
(void)out;
|
(void)out;
|
||||||
(void)out_len;
|
(void)out_len;
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
static const char *filenames[] = {
|
static const char *filenames[] = {
|
||||||
"/dev/srandom", "/dev/urandom", "/dev/random", NULL
|
"/dev/srandom", "/dev/urandom", "/dev/random", NULL
|
||||||
};
|
};
|
||||||
@ -2935,7 +2935,7 @@ crypto_strongest_rand_fallback(uint8_t *out, size_t out_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Try to get <b>out_len</b> bytes of the strongest entropy we can generate,
|
/** Try to get <b>out_len</b> bytes of the strongest entropy we can generate,
|
||||||
@ -3184,7 +3184,7 @@ crypto_rand_double(void)
|
|||||||
#define UINT_MAX_AS_DOUBLE 1.8446744073709552e+19
|
#define UINT_MAX_AS_DOUBLE 1.8446744073709552e+19
|
||||||
#else
|
#else
|
||||||
#error SIZEOF_INT is neither 4 nor 8
|
#error SIZEOF_INT is neither 4 nor 8
|
||||||
#endif
|
#endif /* SIZEOF_INT == 4 || ... */
|
||||||
return ((double)u) / UINT_MAX_AS_DOUBLE;
|
return ((double)u) / UINT_MAX_AS_DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3313,7 +3313,7 @@ memwipe(void *mem, uint8_t byte, size_t sz)
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
OPENSSL_cleanse(mem, sz);
|
OPENSSL_cleanse(mem, sz);
|
||||||
#endif
|
#endif /* defined(SecureZeroMemory) || defined(HAVE_SECUREZEROMEMORY) || ... */
|
||||||
|
|
||||||
/* Just in case some caller of memwipe() is relying on getting a buffer
|
/* Just in case some caller of memwipe() is relying on getting a buffer
|
||||||
* filled with a particular value, fill the buffer.
|
* filled with a particular value, fill the buffer.
|
||||||
@ -3355,7 +3355,7 @@ tor_set_openssl_thread_id(CRYPTO_THREADID *threadid)
|
|||||||
{
|
{
|
||||||
CRYPTO_THREADID_set_numeric(threadid, tor_get_thread_id());
|
CRYPTO_THREADID_set_numeric(threadid, tor_get_thread_id());
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(NEW_THREAD_API) */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* This code is disabled, because OpenSSL never actually uses these callbacks.
|
/* This code is disabled, because OpenSSL never actually uses these callbacks.
|
||||||
@ -3405,7 +3405,7 @@ openssl_dynlock_destroy_cb_(struct CRYPTO_dynlock_value *v,
|
|||||||
tor_mutex_free(v->lock);
|
tor_mutex_free(v->lock);
|
||||||
tor_free(v);
|
tor_free(v);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
/** @{ */
|
/** @{ */
|
||||||
/** Helper: Construct mutexes, and set callbacks to help OpenSSL handle being
|
/** Helper: Construct mutexes, and set callbacks to help OpenSSL handle being
|
||||||
@ -3422,7 +3422,7 @@ setup_openssl_threading(void)
|
|||||||
openssl_mutexes_[i] = tor_mutex_new();
|
openssl_mutexes_[i] = tor_mutex_new();
|
||||||
CRYPTO_set_locking_callback(openssl_locking_cb_);
|
CRYPTO_set_locking_callback(openssl_locking_cb_);
|
||||||
CRYPTO_THREADID_set_callback(tor_set_openssl_thread_id);
|
CRYPTO_THREADID_set_callback(tor_set_openssl_thread_id);
|
||||||
#endif
|
#endif /* !defined(NEW_THREAD_API) */
|
||||||
#if 0
|
#if 0
|
||||||
CRYPTO_set_dynlock_create_callback(openssl_dynlock_create_cb_);
|
CRYPTO_set_dynlock_create_callback(openssl_dynlock_create_cb_);
|
||||||
CRYPTO_set_dynlock_lock_callback(openssl_dynlock_lock_cb_);
|
CRYPTO_set_dynlock_lock_callback(openssl_dynlock_lock_cb_);
|
||||||
@ -3469,7 +3469,7 @@ crypto_global_cleanup(void)
|
|||||||
}
|
}
|
||||||
tor_free(ms);
|
tor_free(ms);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(NEW_THREAD_API) */
|
||||||
|
|
||||||
tor_free(crypto_openssl_version_str);
|
tor_free(crypto_openssl_version_str);
|
||||||
tor_free(crypto_openssl_header_version_str);
|
tor_free(crypto_openssl_header_version_str);
|
||||||
@ -3488,5 +3488,5 @@ crypto_use_tor_alloc_functions(void)
|
|||||||
int r = CRYPTO_set_mem_ex_functions(tor_malloc_, tor_realloc_, tor_free_);
|
int r = CRYPTO_set_mem_ex_functions(tor_malloc_, tor_realloc_, tor_free_);
|
||||||
return r ? 0 : -1;
|
return r ? 0 : -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(USE_DMALLOC) */
|
||||||
|
|
||||||
|
@ -346,12 +346,12 @@ STATIC int crypto_strongest_rand_raw(uint8_t *out, size_t out_len);
|
|||||||
extern int break_strongest_rng_syscall;
|
extern int break_strongest_rng_syscall;
|
||||||
extern int break_strongest_rng_fallback;
|
extern int break_strongest_rng_fallback;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(CRYPTO_PRIVATE) */
|
||||||
|
|
||||||
#ifdef TOR_UNIT_TESTS
|
#ifdef TOR_UNIT_TESTS
|
||||||
void crypto_pk_assign_(crypto_pk_t *dest, const crypto_pk_t *src);
|
void crypto_pk_assign_(crypto_pk_t *dest, const crypto_pk_t *src);
|
||||||
digest_algorithm_t crypto_digest_get_algorithm(crypto_digest_t *digest);
|
digest_algorithm_t crypto_digest_get_algorithm(crypto_digest_t *digest);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CRYPTO_H) */
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ int curve25519_donna(uint8_t *mypublic,
|
|||||||
#elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
|
#elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
|
||||||
#include <nacl/crypto_scalarmult_curve25519.h>
|
#include <nacl/crypto_scalarmult_curve25519.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(USE_CURVE25519_NACL) */
|
||||||
|
|
||||||
static void pick_curve25519_basepoint_impl(void);
|
static void pick_curve25519_basepoint_impl(void);
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ curve25519_impl(uint8_t *output, const uint8_t *secret,
|
|||||||
r = crypto_scalarmult_curve25519(output, secret, bp);
|
r = crypto_scalarmult_curve25519(output, secret, bp);
|
||||||
#else
|
#else
|
||||||
#error "No implementation of curve25519 is available."
|
#error "No implementation of curve25519 is available."
|
||||||
#endif
|
#endif /* defined(USE_CURVE25519_DONNA) || ... */
|
||||||
memwipe(bp, 0, sizeof(bp));
|
memwipe(bp, 0, sizeof(bp));
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ STATIC int curve25519_impl(uint8_t *output, const uint8_t *secret,
|
|||||||
const uint8_t *basepoint);
|
const uint8_t *basepoint);
|
||||||
|
|
||||||
STATIC int curve25519_basepoint_impl(uint8_t *output, const uint8_t *secret);
|
STATIC int curve25519_basepoint_impl(uint8_t *output, const uint8_t *secret);
|
||||||
#endif
|
#endif /* defined(CRYPTO_CURVE25519_PRIVATE) */
|
||||||
|
|
||||||
#define CURVE25519_BASE64_PADDED_LEN 44
|
#define CURVE25519_BASE64_PADDED_LEN 44
|
||||||
|
|
||||||
@ -83,5 +83,5 @@ int curve25519_public_to_base64(char *output,
|
|||||||
void curve25519_set_impl_params(int use_ed);
|
void curve25519_set_impl_params(int use_ed);
|
||||||
void curve25519_init(void);
|
void curve25519_init(void);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CRYPTO_CURVE25519_H) */
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ crypto_ed25519_testing_restore_impl(void)
|
|||||||
ed25519_impl = saved_ed25519_impl;
|
ed25519_impl = saved_ed25519_impl;
|
||||||
saved_ed25519_impl = NULL;
|
saved_ed25519_impl = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a new ed25519 secret key in <b>seckey_out</b>. If
|
* Initialize a new ed25519 secret key in <b>seckey_out</b>. If
|
||||||
|
@ -138,5 +138,5 @@ void crypto_ed25519_testing_restore_impl(void);
|
|||||||
MOCK_DECL(STATIC int, ed25519_impl_spot_check, (void));
|
MOCK_DECL(STATIC int, ed25519_impl_spot_check, (void));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CRYPTO_ED25519_H) */
|
||||||
|
|
||||||
|
@ -43,5 +43,5 @@ int digest_from_base64(char *digest, const char *d64);
|
|||||||
int digest256_to_base64(char *d64, const char *digest);
|
int digest256_to_base64(char *d64, const char *digest);
|
||||||
int digest256_from_base64(char *digest, const char *d64);
|
int digest256_from_base64(char *digest, const char *d64);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CRYPTO_FORMAT_H) */
|
||||||
|
|
||||||
|
@ -16,5 +16,5 @@ int crypto_unpwbox(uint8_t **out, size_t *outlen_out,
|
|||||||
const uint8_t *inp, size_t input_len,
|
const uint8_t *inp, size_t input_len,
|
||||||
const char *secret, size_t secret_len);
|
const char *secret, size_t secret_len);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(CRYPTO_PWBOX_H_INCLUDED_) */
|
||||||
|
|
||||||
|
@ -290,9 +290,9 @@ secret_to_key_compute_key(uint8_t *key_out, size_t key_out_len,
|
|||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
return S2K_FAILED;
|
return S2K_FAILED;
|
||||||
return (int)key_out_len;
|
return (int)key_out_len;
|
||||||
#else
|
#else /* !(defined(HAVE_SCRYPT)) */
|
||||||
return S2K_NO_SCRYPT_SUPPORT;
|
return S2K_NO_SCRYPT_SUPPORT;
|
||||||
#endif
|
#endif /* defined(HAVE_SCRYPT) */
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return S2K_BAD_ALGORITHM;
|
return S2K_BAD_ALGORITHM;
|
||||||
|
@ -67,7 +67,7 @@ STATIC int secret_to_key_compute_key(uint8_t *key_out, size_t key_out_len,
|
|||||||
const uint8_t *spec, size_t spec_len,
|
const uint8_t *spec, size_t spec_len,
|
||||||
const char *secret, size_t secret_len,
|
const char *secret, size_t secret_len,
|
||||||
int type);
|
int type);
|
||||||
#endif
|
#endif /* defined(CRYPTO_S2K_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CRYPTO_S2K_H_INCLUDED) */
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ tor_memcmp(const void *a, const void *b, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
#endif /* timingsafe_memcmp */
|
#endif /* defined(HAVE_TIMINGSAFE_MEMCMP) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -238,7 +238,7 @@ gt_i64_timei(uint64_t a, uint64_t b)
|
|||||||
int res = diff >> 63;
|
int res = diff >> 63;
|
||||||
return res & 1;
|
return res & 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* SIZEOF_VOID_P == 8 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given an array of list of <b>n_entries</b> uint64_t values, whose sum is
|
* Given an array of list of <b>n_entries</b> uint64_t values, whose sum is
|
||||||
|
@ -46,5 +46,5 @@ int select_array_member_cumulative_timei(const uint64_t *entries,
|
|||||||
int n_entries,
|
int n_entries,
|
||||||
uint64_t total, uint64_t rand_val);
|
uint64_t total, uint64_t rand_val);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_DI_OPS_H) */
|
||||||
|
|
||||||
|
@ -149,5 +149,5 @@
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* TOR_HANDLE_H */
|
#endif /* !defined(TOR_HANDLE_H) */
|
||||||
|
|
||||||
|
@ -444,11 +444,11 @@ logfile_deliver(logfile_t *lf, const char *buf, size_t msg_len,
|
|||||||
if (m != msg_after_prefix) {
|
if (m != msg_after_prefix) {
|
||||||
tor_free(m);
|
tor_free(m);
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(MAXLINE)) */
|
||||||
/* We have syslog but not MAXLINE. That's promising! */
|
/* We have syslog but not MAXLINE. That's promising! */
|
||||||
syslog(severity, "%s", msg_after_prefix);
|
syslog(severity, "%s", msg_after_prefix);
|
||||||
#endif
|
#endif /* defined(MAXLINE) */
|
||||||
#endif
|
#endif /* defined(HAVE_SYSLOG_H) */
|
||||||
} else if (lf->callback) {
|
} else if (lf->callback) {
|
||||||
if (domain & LD_NOCB) {
|
if (domain & LD_NOCB) {
|
||||||
if (!*callbacks_deferred && pending_cb_messages) {
|
if (!*callbacks_deferred && pending_cb_messages) {
|
||||||
@ -807,7 +807,7 @@ close_log(logfile_t *victim)
|
|||||||
/* There are no other syslogs; close the logging facility. */
|
/* There are no other syslogs; close the logging facility. */
|
||||||
closelog();
|
closelog();
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_SYSLOG_H) */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1144,7 +1144,7 @@ add_syslog_log(const log_severity_list_t *severity,
|
|||||||
UNLOCK_LOGS();
|
UNLOCK_LOGS();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_SYSLOG_H) */
|
||||||
|
|
||||||
/** If <b>level</b> is a valid log severity, return the corresponding
|
/** If <b>level</b> is a valid log severity, return the corresponding
|
||||||
* numeric value. Otherwise, return -1. */
|
* numeric value. Otherwise, return -1. */
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#define MEMAREA_ALIGN_MASK ((uintptr_t)7)
|
#define MEMAREA_ALIGN_MASK ((uintptr_t)7)
|
||||||
#else
|
#else
|
||||||
#error "void* is neither 4 nor 8 bytes long. I don't know how to align stuff."
|
#error "void* is neither 4 nor 8 bytes long. I don't know how to align stuff."
|
||||||
#endif
|
#endif /* MEMAREA_ALIGN == 4 || ... */
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(FLEXIBLE_ARRAY_MEMBER)
|
#if defined(__GNUC__) && defined(FLEXIBLE_ARRAY_MEMBER)
|
||||||
#define USE_ALIGNED_ATTRIBUTE
|
#define USE_ALIGNED_ATTRIBUTE
|
||||||
@ -41,7 +41,7 @@
|
|||||||
#define U_MEM mem
|
#define U_MEM mem
|
||||||
#else
|
#else
|
||||||
#define U_MEM u.mem
|
#define U_MEM u.mem
|
||||||
#endif
|
#endif /* defined(__GNUC__) && defined(FLEXIBLE_ARRAY_MEMBER) */
|
||||||
|
|
||||||
#ifdef USE_SENTINELS
|
#ifdef USE_SENTINELS
|
||||||
/** Magic value that we stick at the end of a memarea so we can make sure
|
/** Magic value that we stick at the end of a memarea so we can make sure
|
||||||
@ -61,11 +61,11 @@
|
|||||||
uint32_t sent_val = get_uint32(&(chunk)->U_MEM[chunk->mem_size]); \
|
uint32_t sent_val = get_uint32(&(chunk)->U_MEM[chunk->mem_size]); \
|
||||||
tor_assert(sent_val == SENTINEL_VAL); \
|
tor_assert(sent_val == SENTINEL_VAL); \
|
||||||
STMT_END
|
STMT_END
|
||||||
#else
|
#else /* !(defined(USE_SENTINELS)) */
|
||||||
#define SENTINEL_LEN 0
|
#define SENTINEL_LEN 0
|
||||||
#define SET_SENTINEL(chunk) STMT_NIL
|
#define SET_SENTINEL(chunk) STMT_NIL
|
||||||
#define CHECK_SENTINEL(chunk) STMT_NIL
|
#define CHECK_SENTINEL(chunk) STMT_NIL
|
||||||
#endif
|
#endif /* defined(USE_SENTINELS) */
|
||||||
|
|
||||||
/** Increment <b>ptr</b> until it is aligned to MEMAREA_ALIGN. */
|
/** Increment <b>ptr</b> until it is aligned to MEMAREA_ALIGN. */
|
||||||
static inline void *
|
static inline void *
|
||||||
@ -97,7 +97,7 @@ typedef struct memarea_chunk_t {
|
|||||||
void *void_for_alignment_; /**< Dummy; used to make sure mem is aligned. */
|
void *void_for_alignment_; /**< Dummy; used to make sure mem is aligned. */
|
||||||
} u; /**< Union used to enforce alignment when we don't have support for
|
} u; /**< Union used to enforce alignment when we don't have support for
|
||||||
* doing it right. */
|
* doing it right. */
|
||||||
#endif
|
#endif /* defined(USE_ALIGNED_ATTRIBUTE) */
|
||||||
} memarea_chunk_t;
|
} memarea_chunk_t;
|
||||||
|
|
||||||
/** How many bytes are needed for overhead before we get to the memory part
|
/** How many bytes are needed for overhead before we get to the memory part
|
||||||
@ -308,7 +308,7 @@ memarea_assert_ok(memarea_t *area)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else /* !(!defined(DISABLE_MEMORY_SENTINELS)) */
|
||||||
|
|
||||||
struct memarea_t {
|
struct memarea_t {
|
||||||
smartlist_t *pieces;
|
smartlist_t *pieces;
|
||||||
@ -394,5 +394,5 @@ memarea_assert_ok(memarea_t *area)
|
|||||||
(void)area;
|
(void)area;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(DISABLE_MEMORY_SENTINELS) */
|
||||||
|
|
||||||
|
@ -20,5 +20,5 @@ void memarea_get_stats(memarea_t *area,
|
|||||||
size_t *allocated_out, size_t *used_out);
|
size_t *allocated_out, size_t *used_out);
|
||||||
void memarea_assert_ok(memarea_t *area);
|
void memarea_assert_ok(memarea_t *area);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_MEMAREA_H) */
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ typedef int pid_t;
|
|||||||
#define PID_T_FORMAT I64_FORMAT
|
#define PID_T_FORMAT I64_FORMAT
|
||||||
#else
|
#else
|
||||||
#error Unknown: SIZEOF_PID_T
|
#error Unknown: SIZEOF_PID_T
|
||||||
#endif
|
#endif /* (0 == SIZEOF_PID_T) && defined(_WIN32) || ... */
|
||||||
|
|
||||||
/* Define to 1 if process-termination monitors on this OS and Libevent
|
/* Define to 1 if process-termination monitors on this OS and Libevent
|
||||||
version must poll for process termination themselves. */
|
version must poll for process termination themselves. */
|
||||||
@ -114,7 +114,7 @@ struct tor_process_monitor_t {
|
|||||||
HANDLE hproc;
|
HANDLE hproc;
|
||||||
/* XXXX We should have Libevent watch hproc for us,
|
/* XXXX We should have Libevent watch hproc for us,
|
||||||
* if/when some version of Libevent can be told to do so. */
|
* if/when some version of Libevent can be told to do so. */
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/* XXXX On Linux, we can and should receive the 22nd
|
/* XXXX On Linux, we can and should receive the 22nd
|
||||||
* (space-delimited) field (‘starttime’) of /proc/$PID/stat from the
|
* (space-delimited) field (‘starttime’) of /proc/$PID/stat from the
|
||||||
@ -219,7 +219,7 @@ tor_process_monitor_new(struct event_base *base,
|
|||||||
"try again later.",
|
"try again later.",
|
||||||
procmon->pid);
|
procmon->pid);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
procmon->cb = cb;
|
procmon->cb = cb;
|
||||||
procmon->cb_arg = cb_arg;
|
procmon->cb_arg = cb_arg;
|
||||||
@ -232,9 +232,9 @@ tor_process_monitor_new(struct event_base *base,
|
|||||||
* tor_evtimer_new never returns NULL. */
|
* tor_evtimer_new never returns NULL. */
|
||||||
|
|
||||||
evtimer_add(procmon->e, &poll_interval_tv);
|
evtimer_add(procmon->e, &poll_interval_tv);
|
||||||
#else
|
#else /* !(defined(PROCMON_POLLS)) */
|
||||||
#error OOPS?
|
#error OOPS?
|
||||||
#endif
|
#endif /* defined(PROCMON_POLLS) */
|
||||||
|
|
||||||
return procmon;
|
return procmon;
|
||||||
err:
|
err:
|
||||||
@ -306,11 +306,11 @@ tor_process_monitor_poll_cb(evutil_socket_t unused1, short unused2,
|
|||||||
tor_free(errmsg);
|
tor_free(errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
/* Unix makes this part easy, if a bit racy. */
|
/* Unix makes this part easy, if a bit racy. */
|
||||||
its_dead_jim = kill(procmon->pid, 0);
|
its_dead_jim = kill(procmon->pid, 0);
|
||||||
its_dead_jim = its_dead_jim && (errno == ESRCH);
|
its_dead_jim = its_dead_jim && (errno == ESRCH);
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
tor_log(its_dead_jim ? LOG_NOTICE : LOG_INFO,
|
tor_log(its_dead_jim ? LOG_NOTICE : LOG_INFO,
|
||||||
procmon->log_domain, "Monitored process "PID_T_FORMAT" is %s.",
|
procmon->log_domain, "Monitored process "PID_T_FORMAT" is %s.",
|
||||||
@ -321,7 +321,7 @@ tor_process_monitor_poll_cb(evutil_socket_t unused1, short unused2,
|
|||||||
procmon->cb(procmon->cb_arg);
|
procmon->cb(procmon->cb_arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(PROCMON_POLLS) */
|
||||||
|
|
||||||
/** Free the process-termination monitor <b>procmon</b>. */
|
/** Free the process-termination monitor <b>procmon</b>. */
|
||||||
void
|
void
|
||||||
|
@ -29,5 +29,5 @@ tor_process_monitor_t *tor_process_monitor_new(struct event_base *base,
|
|||||||
const char **msg);
|
const char **msg);
|
||||||
void tor_process_monitor_free(tor_process_monitor_t *procmon);
|
void tor_process_monitor_free(tor_process_monitor_t *procmon);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_PROCMON_H) */
|
||||||
|
|
||||||
|
@ -175,5 +175,5 @@ int pubsub_notify_(pubsub_topic_t *topic, pubsub_notify_fn_t notify_fn,
|
|||||||
pubsub_clear_(&name##_topic_); \
|
pubsub_clear_(&name##_topic_); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* TOR_PUBSUB_H */
|
#endif /* !defined(TOR_PUBSUB_H) */
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* with the libevent fix.
|
* with the libevent fix.
|
||||||
*/
|
*/
|
||||||
#define _LARGEFILE64_SOURCE
|
#define _LARGEFILE64_SOURCE
|
||||||
#endif
|
#endif /* !defined(_LARGEFILE64_SOURCE) */
|
||||||
|
|
||||||
/** Malloc mprotect limit in bytes.
|
/** Malloc mprotect limit in bytes.
|
||||||
*
|
*
|
||||||
@ -77,7 +77,7 @@
|
|||||||
#define USE_BACKTRACE
|
#define USE_BACKTRACE
|
||||||
#define EXPOSE_CLEAN_BACKTRACE
|
#define EXPOSE_CLEAN_BACKTRACE
|
||||||
#include "backtrace.h"
|
#include "backtrace.h"
|
||||||
#endif
|
#endif /* defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && ... */
|
||||||
|
|
||||||
#ifdef USE_BACKTRACE
|
#ifdef USE_BACKTRACE
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
@ -103,7 +103,7 @@
|
|||||||
|
|
||||||
#define M_SYSCALL arm_r7
|
#define M_SYSCALL arm_r7
|
||||||
|
|
||||||
#endif
|
#endif /* defined(__i386__) || ... */
|
||||||
|
|
||||||
/**Determines if at least one sandbox is active.*/
|
/**Determines if at least one sandbox is active.*/
|
||||||
static int sandbox_active = 0;
|
static int sandbox_active = 0;
|
||||||
@ -302,7 +302,7 @@ sb_time(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
SCMP_CMP(0, SCMP_CMP_EQ, 0));
|
SCMP_CMP(0, SCMP_CMP_EQ, 0));
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* defined(__NR_time) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -321,7 +321,7 @@ sb_accept4(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
if (rc) {
|
if (rc) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(__i386__) */
|
||||||
|
|
||||||
rc = seccomp_rule_add_1(ctx, SCMP_ACT_ALLOW, SCMP_SYS(accept4),
|
rc = seccomp_rule_add_1(ctx, SCMP_ACT_ALLOW, SCMP_SYS(accept4),
|
||||||
SCMP_CMP_MASKED(3, SOCK_CLOEXEC|SOCK_NONBLOCK, 0));
|
SCMP_CMP_MASKED(3, SOCK_CLOEXEC|SOCK_NONBLOCK, 0));
|
||||||
@ -394,7 +394,7 @@ sb_mmap2(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(__NR_mmap2) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function responsible for setting up the open syscall for
|
* Function responsible for setting up the open syscall for
|
||||||
@ -670,7 +670,7 @@ sb_ioctl(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_KIST_SUPPORT */
|
#endif /* defined(HAVE_KIST_SUPPORT) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function responsible for setting up the setsockopt syscall for
|
* Function responsible for setting up the setsockopt syscall for
|
||||||
@ -712,7 +712,7 @@ sb_setsockopt(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
SCMP_CMP(2, SCMP_CMP_EQ, SO_SNDBUFFORCE));
|
SCMP_CMP(2, SCMP_CMP_EQ, SO_SNDBUFFORCE));
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
#endif
|
#endif /* defined(HAVE_SYSTEMD) */
|
||||||
|
|
||||||
#ifdef IP_TRANSPARENT
|
#ifdef IP_TRANSPARENT
|
||||||
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(setsockopt),
|
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(setsockopt),
|
||||||
@ -720,7 +720,7 @@ sb_setsockopt(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
SCMP_CMP(2, SCMP_CMP_EQ, IP_TRANSPARENT));
|
SCMP_CMP(2, SCMP_CMP_EQ, IP_TRANSPARENT));
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
#endif
|
#endif /* defined(IP_TRANSPARENT) */
|
||||||
|
|
||||||
#ifdef IPV6_V6ONLY
|
#ifdef IPV6_V6ONLY
|
||||||
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(setsockopt),
|
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(setsockopt),
|
||||||
@ -728,7 +728,7 @@ sb_setsockopt(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
SCMP_CMP(2, SCMP_CMP_EQ, IPV6_V6ONLY));
|
SCMP_CMP(2, SCMP_CMP_EQ, IPV6_V6ONLY));
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
#endif
|
#endif /* defined(IPV6_V6ONLY) */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -761,7 +761,7 @@ sb_getsockopt(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
SCMP_CMP(2, SCMP_CMP_EQ, SO_SNDBUF));
|
SCMP_CMP(2, SCMP_CMP_EQ, SO_SNDBUF));
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
#endif
|
#endif /* defined(HAVE_SYSTEMD) */
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETFILTER_IPV4_H
|
#ifdef HAVE_LINUX_NETFILTER_IPV4_H
|
||||||
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(getsockopt),
|
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(getsockopt),
|
||||||
@ -769,7 +769,7 @@ sb_getsockopt(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
SCMP_CMP(2, SCMP_CMP_EQ, SO_ORIGINAL_DST));
|
SCMP_CMP(2, SCMP_CMP_EQ, SO_ORIGINAL_DST));
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
#endif
|
#endif /* defined(HAVE_LINUX_NETFILTER_IPV4_H) */
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H
|
#ifdef HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H
|
||||||
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(getsockopt),
|
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(getsockopt),
|
||||||
@ -777,7 +777,7 @@ sb_getsockopt(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
SCMP_CMP(2, SCMP_CMP_EQ, IP6T_SO_ORIGINAL_DST));
|
SCMP_CMP(2, SCMP_CMP_EQ, IP6T_SO_ORIGINAL_DST));
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
#endif
|
#endif /* defined(HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H) */
|
||||||
|
|
||||||
#ifdef HAVE_KIST_SUPPORT
|
#ifdef HAVE_KIST_SUPPORT
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
@ -786,7 +786,7 @@ sb_getsockopt(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
SCMP_CMP(2, SCMP_CMP_EQ, TCP_INFO));
|
SCMP_CMP(2, SCMP_CMP_EQ, TCP_INFO));
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
#endif
|
#endif /* defined(HAVE_KIST_SUPPORT) */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -826,7 +826,7 @@ sb_fcntl64(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(__NR_fcntl64) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function responsible for setting up the epoll_ctl syscall for
|
* Function responsible for setting up the epoll_ctl syscall for
|
||||||
@ -1051,7 +1051,7 @@ sb_stat64(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(__NR_stat64) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of function pointers responsible for filtering different syscalls at
|
* Array of function pointers responsible for filtering different syscalls at
|
||||||
@ -1740,7 +1740,7 @@ sigsys_debugging(int nr, siginfo_t *info, void *void_context)
|
|||||||
/* Clean up the top stack frame so we get the real function
|
/* Clean up the top stack frame so we get the real function
|
||||||
* name for the most recently failing function. */
|
* name for the most recently failing function. */
|
||||||
clean_backtrace(syscall_cb_buf, depth, ctx);
|
clean_backtrace(syscall_cb_buf, depth, ctx);
|
||||||
#endif
|
#endif /* defined(USE_BACKTRACE) */
|
||||||
|
|
||||||
syscall_name = get_syscall_name(syscall);
|
syscall_name = get_syscall_name(syscall);
|
||||||
|
|
||||||
@ -1814,7 +1814,7 @@ register_cfg(sandbox_cfg_t* cfg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_LIBSECCOMP
|
#endif /* defined(USE_LIBSECCOMP) */
|
||||||
|
|
||||||
#ifdef USE_LIBSECCOMP
|
#ifdef USE_LIBSECCOMP
|
||||||
/**
|
/**
|
||||||
@ -1844,7 +1844,7 @@ sandbox_is_active(void)
|
|||||||
{
|
{
|
||||||
return sandbox_active != 0;
|
return sandbox_active != 0;
|
||||||
}
|
}
|
||||||
#endif // USE_LIBSECCOMP
|
#endif /* defined(USE_LIBSECCOMP) */
|
||||||
|
|
||||||
sandbox_cfg_t*
|
sandbox_cfg_t*
|
||||||
sandbox_cfg_new(void)
|
sandbox_cfg_new(void)
|
||||||
@ -1872,7 +1872,7 @@ sandbox_init(sandbox_cfg_t *cfg)
|
|||||||
"Currently, sandboxing is only implemented on Linux. The feature "
|
"Currently, sandboxing is only implemented on Linux. The feature "
|
||||||
"is disabled on your platform.");
|
"is disabled on your platform.");
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* defined(USE_LIBSECCOMP) || ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_LIBSECCOMP
|
#ifndef USE_LIBSECCOMP
|
||||||
@ -1928,5 +1928,5 @@ void
|
|||||||
sandbox_disable_getaddrinfo_cache(void)
|
sandbox_disable_getaddrinfo_cache(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(USE_LIBSECCOMP) */
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
#define SYS_SECCOMP 1
|
#define SYS_SECCOMP 1
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(SYS_SECCOMP) */
|
||||||
|
|
||||||
#if defined(HAVE_SECCOMP_H) && defined(__linux__)
|
#if defined(HAVE_SECCOMP_H) && defined(__linux__)
|
||||||
#define USE_LIBSECCOMP
|
#define USE_LIBSECCOMP
|
||||||
@ -101,7 +101,7 @@ typedef struct {
|
|||||||
sandbox_cfg_t *filter_dynamic;
|
sandbox_cfg_t *filter_dynamic;
|
||||||
} sandbox_t;
|
} sandbox_t;
|
||||||
|
|
||||||
#endif // USE_LIBSECCOMP
|
#endif /* defined(USE_LIBSECCOMP) */
|
||||||
|
|
||||||
#ifdef USE_LIBSECCOMP
|
#ifdef USE_LIBSECCOMP
|
||||||
/** Pre-calls getaddrinfo in order to pre-record result. */
|
/** Pre-calls getaddrinfo in order to pre-record result. */
|
||||||
@ -114,7 +114,7 @@ int sandbox_getaddrinfo(const char *name, const char *servname,
|
|||||||
struct addrinfo **res);
|
struct addrinfo **res);
|
||||||
void sandbox_freeaddrinfo(struct addrinfo *addrinfo);
|
void sandbox_freeaddrinfo(struct addrinfo *addrinfo);
|
||||||
void sandbox_free_getaddrinfo_cache(void);
|
void sandbox_free_getaddrinfo_cache(void);
|
||||||
#else
|
#else /* !(defined(USE_LIBSECCOMP)) */
|
||||||
#define sandbox_getaddrinfo(name, servname, hints, res) \
|
#define sandbox_getaddrinfo(name, servname, hints, res) \
|
||||||
getaddrinfo((name),(servname), (hints),(res))
|
getaddrinfo((name),(servname), (hints),(res))
|
||||||
#define sandbox_add_addrinfo(name) \
|
#define sandbox_add_addrinfo(name) \
|
||||||
@ -122,16 +122,16 @@ void sandbox_free_getaddrinfo_cache(void);
|
|||||||
#define sandbox_freeaddrinfo(addrinfo) \
|
#define sandbox_freeaddrinfo(addrinfo) \
|
||||||
freeaddrinfo((addrinfo))
|
freeaddrinfo((addrinfo))
|
||||||
#define sandbox_free_getaddrinfo_cache()
|
#define sandbox_free_getaddrinfo_cache()
|
||||||
#endif
|
#endif /* defined(USE_LIBSECCOMP) */
|
||||||
|
|
||||||
#ifdef USE_LIBSECCOMP
|
#ifdef USE_LIBSECCOMP
|
||||||
/** Returns a registered protected string used with the sandbox, given that
|
/** Returns a registered protected string used with the sandbox, given that
|
||||||
* it matches the parameter.
|
* it matches the parameter.
|
||||||
*/
|
*/
|
||||||
const char* sandbox_intern_string(const char *param);
|
const char* sandbox_intern_string(const char *param);
|
||||||
#else
|
#else /* !(defined(USE_LIBSECCOMP)) */
|
||||||
#define sandbox_intern_string(s) (s)
|
#define sandbox_intern_string(s) (s)
|
||||||
#endif
|
#endif /* defined(USE_LIBSECCOMP) */
|
||||||
|
|
||||||
/** Creates an empty sandbox configuration file.*/
|
/** Creates an empty sandbox configuration file.*/
|
||||||
sandbox_cfg_t * sandbox_cfg_new(void);
|
sandbox_cfg_t * sandbox_cfg_new(void);
|
||||||
@ -170,5 +170,5 @@ int sandbox_is_active(void);
|
|||||||
|
|
||||||
void sandbox_disable_getaddrinfo_cache(void);
|
void sandbox_disable_getaddrinfo_cache(void);
|
||||||
|
|
||||||
#endif /* SANDBOX_H_ */
|
#endif /* !defined(SANDBOX_H_) */
|
||||||
|
|
||||||
|
@ -47,5 +47,5 @@ int storage_dir_shrink(storage_dir_t *d,
|
|||||||
int storage_dir_remove_all(storage_dir_t *d);
|
int storage_dir_remove_all(storage_dir_t *d);
|
||||||
int storage_dir_get_max_files(storage_dir_t *d);
|
int storage_dir_get_max_files(storage_dir_t *d);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_STORAGEDIR_H) */
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#else
|
#else
|
||||||
#define STATIC static
|
#define STATIC static
|
||||||
#define EXTERN(type, name)
|
#define EXTERN(type, name)
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/** Quick and dirty macros to implement test mocking.
|
/** Quick and dirty macros to implement test mocking.
|
||||||
*
|
*
|
||||||
@ -76,15 +76,15 @@
|
|||||||
do { \
|
do { \
|
||||||
func = func ##__real; \
|
func = func ##__real; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else /* !(defined(TOR_UNIT_TESTS)) */
|
||||||
#define MOCK_DECL(rv, funcname, arglist) \
|
#define MOCK_DECL(rv, funcname, arglist) \
|
||||||
rv funcname arglist
|
rv funcname arglist
|
||||||
#define MOCK_DECL_ATTR(rv, funcname, arglist, attr) \
|
#define MOCK_DECL_ATTR(rv, funcname, arglist, attr) \
|
||||||
rv funcname arglist attr
|
rv funcname arglist attr
|
||||||
#define MOCK_IMPL(rv, funcname, arglist) \
|
#define MOCK_IMPL(rv, funcname, arglist) \
|
||||||
rv funcname arglist
|
rv funcname arglist
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_TESTSUPPORT_H) */
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ struct timeout_cb {
|
|||||||
#else
|
#else
|
||||||
/* We're not exposing any of the functions outside this file. */
|
/* We're not exposing any of the functions outside this file. */
|
||||||
#define TIMEOUT_PUBLIC static
|
#define TIMEOUT_PUBLIC static
|
||||||
#endif
|
#endif /* defined(__GNUC__) */
|
||||||
/* We're not using periodic events. */
|
/* We're not using periodic events. */
|
||||||
#define TIMEOUT_DISABLE_INTERVALS
|
#define TIMEOUT_DISABLE_INTERVALS
|
||||||
/* We always know the global_timeouts object, so we don't need each timeout
|
/* We always know the global_timeouts object, so we don't need each timeout
|
||||||
|
@ -26,5 +26,5 @@ void timers_shutdown(void);
|
|||||||
STATIC void timers_run_pending(void);
|
STATIC void timers_run_pending(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_TIMERS_H) */
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
does the same thing (but doesn't defined __FreeBSD__).
|
does the same thing (but doesn't defined __FreeBSD__).
|
||||||
*/
|
*/
|
||||||
#include <machine/limits.h>
|
#include <machine/limits.h>
|
||||||
#endif
|
#endif /* !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) */
|
||||||
#endif
|
#endif /* defined(HAVE_MACHINE_LIMITS_H) */
|
||||||
#ifdef HAVE_INTTYPES_H
|
#ifdef HAVE_INTTYPES_H
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#endif
|
#endif
|
||||||
@ -80,7 +80,7 @@ typedef signed char int8_t;
|
|||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
#define HAVE_UINT8_T
|
#define HAVE_UINT8_T
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* (SIZEOF_CHAR == 1) */
|
||||||
|
|
||||||
#if (SIZEOF_SHORT == 2)
|
#if (SIZEOF_SHORT == 2)
|
||||||
#ifndef HAVE_INT16_T
|
#ifndef HAVE_INT16_T
|
||||||
@ -91,7 +91,7 @@ typedef signed short int16_t;
|
|||||||
typedef unsigned short uint16_t;
|
typedef unsigned short uint16_t;
|
||||||
#define HAVE_UINT16_T
|
#define HAVE_UINT16_T
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* (SIZEOF_SHORT == 2) */
|
||||||
|
|
||||||
#if (SIZEOF_INT == 2)
|
#if (SIZEOF_INT == 2)
|
||||||
#ifndef HAVE_INT16_T
|
#ifndef HAVE_INT16_T
|
||||||
@ -129,7 +129,7 @@ typedef unsigned int uint32_t;
|
|||||||
#ifndef INT32_MIN
|
#ifndef INT32_MIN
|
||||||
#define INT32_MIN (-2147483647-1)
|
#define INT32_MIN (-2147483647-1)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* (SIZEOF_INT == 2) || ... */
|
||||||
|
|
||||||
#if (SIZEOF_LONG == 4)
|
#if (SIZEOF_LONG == 4)
|
||||||
#ifndef HAVE_INT32_T
|
#ifndef HAVE_INT32_T
|
||||||
@ -142,7 +142,7 @@ typedef unsigned long uint32_t;
|
|||||||
#ifndef UINT32_MAX
|
#ifndef UINT32_MAX
|
||||||
#define UINT32_MAX 0xfffffffful
|
#define UINT32_MAX 0xfffffffful
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* !defined(HAVE_UINT32_T) */
|
||||||
#elif (SIZEOF_LONG == 8)
|
#elif (SIZEOF_LONG == 8)
|
||||||
#ifndef HAVE_INT64_T
|
#ifndef HAVE_INT64_T
|
||||||
typedef signed long int64_t;
|
typedef signed long int64_t;
|
||||||
@ -155,7 +155,7 @@ typedef unsigned long uint64_t;
|
|||||||
#ifndef UINT64_MAX
|
#ifndef UINT64_MAX
|
||||||
#define UINT64_MAX 0xfffffffffffffffful
|
#define UINT64_MAX 0xfffffffffffffffful
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* (SIZEOF_LONG == 4) || ... */
|
||||||
|
|
||||||
#if (SIZEOF_LONG_LONG == 8)
|
#if (SIZEOF_LONG_LONG == 8)
|
||||||
#ifndef HAVE_INT64_T
|
#ifndef HAVE_INT64_T
|
||||||
@ -172,7 +172,7 @@ typedef unsigned long long uint64_t;
|
|||||||
#ifndef INT64_MAX
|
#ifndef INT64_MAX
|
||||||
#define INT64_MAX 0x7fffffffffffffffll
|
#define INT64_MAX 0x7fffffffffffffffll
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* (SIZEOF_LONG_LONG == 8) */
|
||||||
|
|
||||||
#if (SIZEOF___INT64 == 8)
|
#if (SIZEOF___INT64 == 8)
|
||||||
#ifndef HAVE_INT64_T
|
#ifndef HAVE_INT64_T
|
||||||
@ -189,7 +189,7 @@ typedef unsigned __int64 uint64_t;
|
|||||||
#ifndef INT64_MAX
|
#ifndef INT64_MAX
|
||||||
#define INT64_MAX 0x7fffffffffffffffi64
|
#define INT64_MAX 0x7fffffffffffffffi64
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* (SIZEOF___INT64 == 8) */
|
||||||
|
|
||||||
#ifndef INT64_MIN
|
#ifndef INT64_MIN
|
||||||
#define INT64_MIN ((- INT64_MAX) - 1)
|
#define INT64_MIN ((- INT64_MAX) - 1)
|
||||||
@ -202,8 +202,8 @@ typedef unsigned __int64 uint64_t;
|
|||||||
#define SIZE_MAX UINT32_MAX
|
#define SIZE_MAX UINT32_MAX
|
||||||
#else
|
#else
|
||||||
#error "Can't define SIZE_MAX"
|
#error "Can't define SIZE_MAX"
|
||||||
#endif
|
#endif /* SIZEOF_SIZE_T == 8 || ... */
|
||||||
#endif
|
#endif /* !defined(SIZE_MAX) */
|
||||||
|
|
||||||
#ifndef HAVE_SSIZE_T
|
#ifndef HAVE_SSIZE_T
|
||||||
#if SIZEOF_SIZE_T == 8
|
#if SIZEOF_SIZE_T == 8
|
||||||
@ -212,8 +212,8 @@ typedef int64_t ssize_t;
|
|||||||
typedef int32_t ssize_t;
|
typedef int32_t ssize_t;
|
||||||
#else
|
#else
|
||||||
#error "Can't define ssize_t."
|
#error "Can't define ssize_t."
|
||||||
#endif
|
#endif /* SIZEOF_SIZE_T == 8 || ... */
|
||||||
#endif
|
#endif /* !defined(HAVE_SSIZE_T) */
|
||||||
|
|
||||||
#if (SIZEOF_VOID_P > 4 && SIZEOF_VOID_P <= 8)
|
#if (SIZEOF_VOID_P > 4 && SIZEOF_VOID_P <= 8)
|
||||||
#ifndef HAVE_INTPTR_T
|
#ifndef HAVE_INTPTR_T
|
||||||
@ -235,7 +235,7 @@ typedef uint32_t uintptr_t;
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#error "void * is either >8 bytes or <= 2. In either case, I am confused."
|
#error "void * is either >8 bytes or <= 2. In either case, I am confused."
|
||||||
#endif
|
#endif /* (SIZEOF_VOID_P > 4 && SIZEOF_VOID_P <= 8) || ... */
|
||||||
|
|
||||||
#ifndef HAVE_INT8_T
|
#ifndef HAVE_INT8_T
|
||||||
#error "Missing type int8_t"
|
#error "Missing type int8_t"
|
||||||
@ -275,8 +275,8 @@ typedef uint32_t uintptr_t;
|
|||||||
#define LONG_MAX 0x7fffffffffffffffL
|
#define LONG_MAX 0x7fffffffffffffffL
|
||||||
#else
|
#else
|
||||||
#error "Can't define LONG_MAX"
|
#error "Can't define LONG_MAX"
|
||||||
#endif
|
#endif /* (SIZEOF_LONG == 4) || ... */
|
||||||
#endif
|
#endif /* !defined(LONG_MAX) */
|
||||||
|
|
||||||
#ifndef INT_MAX
|
#ifndef INT_MAX
|
||||||
#if (SIZEOF_INT == 4)
|
#if (SIZEOF_INT == 4)
|
||||||
@ -285,8 +285,8 @@ typedef uint32_t uintptr_t;
|
|||||||
#define INT_MAX 0x7fffffffffffffffL
|
#define INT_MAX 0x7fffffffffffffffL
|
||||||
#else
|
#else
|
||||||
#error "Can't define INT_MAX"
|
#error "Can't define INT_MAX"
|
||||||
#endif
|
#endif /* (SIZEOF_INT == 4) || ... */
|
||||||
#endif
|
#endif /* !defined(INT_MAX) */
|
||||||
|
|
||||||
#ifndef UINT_MAX
|
#ifndef UINT_MAX
|
||||||
#if (SIZEOF_INT == 2)
|
#if (SIZEOF_INT == 2)
|
||||||
@ -297,8 +297,8 @@ typedef uint32_t uintptr_t;
|
|||||||
#define UINT_MAX 0xffffffffffffffffu
|
#define UINT_MAX 0xffffffffffffffffu
|
||||||
#else
|
#else
|
||||||
#error "Can't define UINT_MAX"
|
#error "Can't define UINT_MAX"
|
||||||
#endif
|
#endif /* (SIZEOF_INT == 2) || ... */
|
||||||
#endif
|
#endif /* !defined(UINT_MAX) */
|
||||||
|
|
||||||
#ifndef SHORT_MAX
|
#ifndef SHORT_MAX
|
||||||
#if (SIZEOF_SHORT == 2)
|
#if (SIZEOF_SHORT == 2)
|
||||||
@ -307,8 +307,8 @@ typedef uint32_t uintptr_t;
|
|||||||
#define SHORT_MAX 0x7fffffff
|
#define SHORT_MAX 0x7fffffff
|
||||||
#else
|
#else
|
||||||
#error "Can't define SHORT_MAX"
|
#error "Can't define SHORT_MAX"
|
||||||
#endif
|
#endif /* (SIZEOF_SHORT == 2) || ... */
|
||||||
#endif
|
#endif /* !defined(SHORT_MAX) */
|
||||||
|
|
||||||
#ifndef TIME_MAX
|
#ifndef TIME_MAX
|
||||||
|
|
||||||
@ -320,9 +320,9 @@ typedef uint32_t uintptr_t;
|
|||||||
#define TIME_MAX ((time_t)INT64_MAX)
|
#define TIME_MAX ((time_t)INT64_MAX)
|
||||||
#else
|
#else
|
||||||
#error "Can't define TIME_MAX"
|
#error "Can't define TIME_MAX"
|
||||||
#endif
|
#endif /* (SIZEOF_TIME_T == SIZEOF_INT) || ... */
|
||||||
|
|
||||||
#endif /* ifndef(TIME_MAX) */
|
#endif /* !defined(TIME_MAX) */
|
||||||
|
|
||||||
#ifndef TIME_MIN
|
#ifndef TIME_MIN
|
||||||
|
|
||||||
@ -334,9 +334,9 @@ typedef uint32_t uintptr_t;
|
|||||||
#define TIME_MIN ((time_t)INT64_MIN)
|
#define TIME_MIN ((time_t)INT64_MIN)
|
||||||
#else
|
#else
|
||||||
#error "Can't define TIME_MIN"
|
#error "Can't define TIME_MIN"
|
||||||
#endif
|
#endif /* (SIZEOF_TIME_T == SIZEOF_INT) || ... */
|
||||||
|
|
||||||
#endif /* ifndef(TIME_MIN) */
|
#endif /* !defined(TIME_MIN) */
|
||||||
|
|
||||||
#ifndef SIZE_MAX
|
#ifndef SIZE_MAX
|
||||||
#if (SIZEOF_SIZE_T == 4)
|
#if (SIZEOF_SIZE_T == 4)
|
||||||
@ -345,8 +345,8 @@ typedef uint32_t uintptr_t;
|
|||||||
#define SIZE_MAX UINT64_MAX
|
#define SIZE_MAX UINT64_MAX
|
||||||
#else
|
#else
|
||||||
#error "Can't define SIZE_MAX"
|
#error "Can't define SIZE_MAX"
|
||||||
#endif
|
#endif /* (SIZEOF_SIZE_T == 4) || ... */
|
||||||
#endif
|
#endif /* !defined(SIZE_MAX) */
|
||||||
|
|
||||||
#ifndef SSIZE_MAX
|
#ifndef SSIZE_MAX
|
||||||
#if (SIZEOF_SIZE_T == 4)
|
#if (SIZEOF_SIZE_T == 4)
|
||||||
@ -355,13 +355,13 @@ typedef uint32_t uintptr_t;
|
|||||||
#define SSIZE_MAX INT64_MAX
|
#define SSIZE_MAX INT64_MAX
|
||||||
#else
|
#else
|
||||||
#error "Can't define SSIZE_MAX"
|
#error "Can't define SSIZE_MAX"
|
||||||
#endif
|
#endif /* (SIZEOF_SIZE_T == 4) || ... */
|
||||||
#endif
|
#endif /* !defined(SSIZE_MAX) */
|
||||||
|
|
||||||
/** Any ssize_t larger than this amount is likely to be an underflow. */
|
/** Any ssize_t larger than this amount is likely to be an underflow. */
|
||||||
#define SSIZE_T_CEILING ((ssize_t)(SSIZE_MAX-16))
|
#define SSIZE_T_CEILING ((ssize_t)(SSIZE_MAX-16))
|
||||||
/** Any size_t larger than this amount is likely to be an underflow. */
|
/** Any size_t larger than this amount is likely to be an underflow. */
|
||||||
#define SIZE_T_CEILING ((size_t)(SSIZE_MAX-16))
|
#define SIZE_T_CEILING ((size_t)(SSIZE_MAX-16))
|
||||||
|
|
||||||
#endif /* __TORINT_H */
|
#endif /* !defined(TOR_TORINT_H) */
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#error "Your syslog.h thinks high numbers are more important. " \
|
#error "Your syslog.h thinks high numbers are more important. " \
|
||||||
"We aren't prepared to deal with that."
|
"We aren't prepared to deal with that."
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else /* !(defined(HAVE_SYSLOG_H)) */
|
||||||
/* Note: Syslog's logging code refers to priorities, with 0 being the most
|
/* Note: Syslog's logging code refers to priorities, with 0 being the most
|
||||||
* important. Thus, all our comparisons needed to be reversed when we added
|
* important. Thus, all our comparisons needed to be reversed when we added
|
||||||
* syslog support.
|
* syslog support.
|
||||||
@ -48,7 +48,7 @@
|
|||||||
/** Error-level severity: for messages that only appear when something has gone
|
/** Error-level severity: for messages that only appear when something has gone
|
||||||
* very wrong, and the Tor process can no longer proceed. */
|
* very wrong, and the Tor process can no longer proceed. */
|
||||||
#define LOG_ERR 3
|
#define LOG_ERR 3
|
||||||
#endif
|
#endif /* defined(HAVE_SYSLOG_H) */
|
||||||
|
|
||||||
/* Logging domains */
|
/* Logging domains */
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ void log_fn_ratelim_(struct ratelim_t *ratelim, int severity,
|
|||||||
#define log_err(domain, args...) \
|
#define log_err(domain, args...) \
|
||||||
log_fn_(LOG_ERR, domain, __FUNCTION__, args)
|
log_fn_(LOG_ERR, domain, __FUNCTION__, args)
|
||||||
|
|
||||||
#else /* ! defined(__GNUC__) */
|
#else /* !(defined(__GNUC__) && __GNUC__ <= 3) */
|
||||||
|
|
||||||
/* Here are the c99 variadic macros, to work with non-GCC compilers */
|
/* Here are the c99 variadic macros, to work with non-GCC compilers */
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ void log_fn_ratelim_(struct ratelim_t *ratelim, int severity,
|
|||||||
#define log_fn_ratelim(ratelim, severity, domain, args,...) \
|
#define log_fn_ratelim(ratelim, severity, domain, args,...) \
|
||||||
log_fn_ratelim_(ratelim, severity, domain, __FUNCTION__, \
|
log_fn_ratelim_(ratelim, severity, domain, __FUNCTION__, \
|
||||||
args, ##__VA_ARGS__)
|
args, ##__VA_ARGS__)
|
||||||
#endif
|
#endif /* defined(__GNUC__) && __GNUC__ <= 3 */
|
||||||
|
|
||||||
#ifdef LOG_PRIVATE
|
#ifdef LOG_PRIVATE
|
||||||
MOCK_DECL(STATIC void, logv, (int severity, log_domain_mask_t domain,
|
MOCK_DECL(STATIC void, logv, (int severity, log_domain_mask_t domain,
|
||||||
@ -249,5 +249,5 @@ MOCK_DECL(STATIC void, logv, (int severity, log_domain_mask_t domain,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
# define TOR_TORLOG_H
|
# define TOR_TORLOG_H
|
||||||
#endif
|
#endif /* !defined(TOR_TORLOG_H) */
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ ENABLE_GCC_WARNING(redundant-decls)
|
|||||||
* SSL3 safely at the same time.
|
* SSL3 safely at the same time.
|
||||||
*/
|
*/
|
||||||
#define DISABLE_SSL3_HANDSHAKE
|
#define DISABLE_SSL3_HANDSHAKE
|
||||||
#endif
|
#endif /* OPENSSL_VERSION_NUMBER < OPENSSL_V(1,0,0,'f') */
|
||||||
|
|
||||||
/* We redefine these so that we can run correctly even if the vendor gives us
|
/* We redefine these so that we can run correctly even if the vendor gives us
|
||||||
* a version of OpenSSL that does not match its header files. (Apple: I am
|
* a version of OpenSSL that does not match its header files. (Apple: I am
|
||||||
@ -390,7 +390,7 @@ tor_tls_init(void)
|
|||||||
"when configuring it) would make ECDH much faster.");
|
"when configuring it) would make ECDH much faster.");
|
||||||
}
|
}
|
||||||
/* LCOV_EXCL_STOP */
|
/* LCOV_EXCL_STOP */
|
||||||
#endif
|
#endif /* (SIZEOF_VOID_P >= 8 && ... */
|
||||||
|
|
||||||
tor_tls_allocate_tor_tls_object_ex_data_index();
|
tor_tls_allocate_tor_tls_object_ex_data_index();
|
||||||
|
|
||||||
@ -1134,7 +1134,7 @@ tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime,
|
|||||||
* with existing Tors. */
|
* with existing Tors. */
|
||||||
if (!(result->ctx = SSL_CTX_new(TLSv1_method())))
|
if (!(result->ctx = SSL_CTX_new(TLSv1_method())))
|
||||||
goto error;
|
goto error;
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
/* Tell OpenSSL to use TLS 1.0 or later but not SSL2 or SSL3. */
|
/* Tell OpenSSL to use TLS 1.0 or later but not SSL2 or SSL3. */
|
||||||
#ifdef HAVE_TLS_METHOD
|
#ifdef HAVE_TLS_METHOD
|
||||||
@ -1143,7 +1143,7 @@ tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime,
|
|||||||
#else
|
#else
|
||||||
if (!(result->ctx = SSL_CTX_new(SSLv23_method())))
|
if (!(result->ctx = SSL_CTX_new(SSLv23_method())))
|
||||||
goto error;
|
goto error;
|
||||||
#endif
|
#endif /* defined(HAVE_TLS_METHOD) */
|
||||||
SSL_CTX_set_options(result->ctx, SSL_OP_NO_SSLv2);
|
SSL_CTX_set_options(result->ctx, SSL_OP_NO_SSLv2);
|
||||||
SSL_CTX_set_options(result->ctx, SSL_OP_NO_SSLv3);
|
SSL_CTX_set_options(result->ctx, SSL_OP_NO_SSLv3);
|
||||||
|
|
||||||
@ -1193,7 +1193,7 @@ tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime,
|
|||||||
if (result->ctx->comp_methods)
|
if (result->ctx->comp_methods)
|
||||||
result->ctx->comp_methods = NULL;
|
result->ctx->comp_methods = NULL;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(1,1,0) */
|
||||||
|
|
||||||
#ifdef SSL_MODE_RELEASE_BUFFERS
|
#ifdef SSL_MODE_RELEASE_BUFFERS
|
||||||
SSL_CTX_set_mode(result->ctx, SSL_MODE_RELEASE_BUFFERS);
|
SSL_CTX_set_mode(result->ctx, SSL_MODE_RELEASE_BUFFERS);
|
||||||
@ -1354,7 +1354,7 @@ find_cipher_by_id(const SSL *ssl, const SSL_METHOD *m, uint16_t cipher)
|
|||||||
tor_assert((SSL_CIPHER_get_id(c) & 0xffff) == cipher);
|
tor_assert((SSL_CIPHER_get_id(c) & 0xffff) == cipher);
|
||||||
return c != NULL;
|
return c != NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(HAVE_SSL_CIPHER_FIND)) */
|
||||||
|
|
||||||
# if defined(HAVE_STRUCT_SSL_METHOD_ST_GET_CIPHER_BY_CHAR)
|
# if defined(HAVE_STRUCT_SSL_METHOD_ST_GET_CIPHER_BY_CHAR)
|
||||||
if (m && m->get_cipher_by_char) {
|
if (m && m->get_cipher_by_char) {
|
||||||
@ -1368,7 +1368,7 @@ find_cipher_by_id(const SSL *ssl, const SSL_METHOD *m, uint16_t cipher)
|
|||||||
tor_assert((c->id & 0xffff) == cipher);
|
tor_assert((c->id & 0xffff) == cipher);
|
||||||
return c != NULL;
|
return c != NULL;
|
||||||
}
|
}
|
||||||
# endif
|
#endif /* defined(HAVE_STRUCT_SSL_METHOD_ST_GET_CIPHER_BY_CHAR) */
|
||||||
# ifndef OPENSSL_1_1_API
|
# ifndef OPENSSL_1_1_API
|
||||||
if (m && m->get_cipher && m->num_ciphers) {
|
if (m && m->get_cipher && m->num_ciphers) {
|
||||||
/* It would seem that some of the "let's-clean-up-openssl" forks have
|
/* It would seem that some of the "let's-clean-up-openssl" forks have
|
||||||
@ -1384,12 +1384,12 @@ find_cipher_by_id(const SSL *ssl, const SSL_METHOD *m, uint16_t cipher)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
# endif
|
#endif /* !defined(OPENSSL_1_1_API) */
|
||||||
(void) ssl;
|
(void) ssl;
|
||||||
(void) m;
|
(void) m;
|
||||||
(void) cipher;
|
(void) cipher;
|
||||||
return 1; /* No way to search */
|
return 1; /* No way to search */
|
||||||
#endif
|
#endif /* defined(HAVE_SSL_CIPHER_FIND) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove from v2_cipher_list every cipher that we don't support, so that
|
/** Remove from v2_cipher_list every cipher that we don't support, so that
|
||||||
@ -1517,7 +1517,7 @@ tor_tls_client_is_using_v2_ciphers(const SSL *ssl)
|
|||||||
return CIPHERS_ERR;
|
return CIPHERS_ERR;
|
||||||
}
|
}
|
||||||
ciphers = session->ciphers;
|
ciphers = session->ciphers;
|
||||||
#endif
|
#endif /* defined(HAVE_SSL_GET_CLIENT_CIPHERS) */
|
||||||
|
|
||||||
return tor_tls_classify_client_ciphers(ssl, ciphers) >= CIPHERS_V2;
|
return tor_tls_classify_client_ciphers(ssl, ciphers) >= CIPHERS_V2;
|
||||||
}
|
}
|
||||||
@ -1648,7 +1648,7 @@ tor_tls_new(int sock, int isServer)
|
|||||||
SSL_set_tlsext_host_name(result->ssl, fake_hostname);
|
SSL_set_tlsext_host_name(result->ssl, fake_hostname);
|
||||||
tor_free(fake_hostname);
|
tor_free(fake_hostname);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(SSL_set_tlsext_host_name) */
|
||||||
|
|
||||||
if (!SSL_set_cipher_list(result->ssl,
|
if (!SSL_set_cipher_list(result->ssl,
|
||||||
isServer ? SERVER_CIPHER_LIST : CLIENT_CIPHER_LIST)) {
|
isServer ? SERVER_CIPHER_LIST : CLIENT_CIPHER_LIST)) {
|
||||||
@ -1775,7 +1775,7 @@ tor_tls_assert_renegotiation_unblocked(tor_tls_t *tls)
|
|||||||
tor_assert(0 != (options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION));
|
tor_assert(0 != (options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION));
|
||||||
#else
|
#else
|
||||||
(void) tls;
|
(void) tls;
|
||||||
#endif
|
#endif /* defined(SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION) && ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return whether this tls initiated the connect (client) or
|
/** Return whether this tls initiated the connect (client) or
|
||||||
@ -2311,7 +2311,7 @@ tor_x509_cert_replace_expiration(const tor_x509_cert_t *inp,
|
|||||||
EVP_PKEY_free(pk);
|
EVP_PKEY_free(pk);
|
||||||
return tor_x509_cert_new(newc);
|
return tor_x509_cert_new(newc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/** Return the number of bytes available for reading from <b>tls</b>.
|
/** Return the number of bytes available for reading from <b>tls</b>.
|
||||||
*/
|
*/
|
||||||
@ -2355,10 +2355,10 @@ tor_tls_get_n_raw_bytes(tor_tls_t *tls, size_t *n_read, size_t *n_written)
|
|||||||
if (BIO_method_type(wbio) == BIO_TYPE_BUFFER &&
|
if (BIO_method_type(wbio) == BIO_TYPE_BUFFER &&
|
||||||
(tmpbio = BIO_next(wbio)) != NULL)
|
(tmpbio = BIO_next(wbio)) != NULL)
|
||||||
wbio = tmpbio;
|
wbio = tmpbio;
|
||||||
#else
|
#else /* !(OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5)) */
|
||||||
if (wbio->method == BIO_f_buffer() && (tmpbio = BIO_next(wbio)) != NULL)
|
if (wbio->method == BIO_f_buffer() && (tmpbio = BIO_next(wbio)) != NULL)
|
||||||
wbio = tmpbio;
|
wbio = tmpbio;
|
||||||
#endif
|
#endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_VER(1,1,0,0,5) */
|
||||||
w = (unsigned long) BIO_number_written(wbio);
|
w = (unsigned long) BIO_number_written(wbio);
|
||||||
|
|
||||||
/* We are ok with letting these unsigned ints go "negative" here:
|
/* We are ok with letting these unsigned ints go "negative" here:
|
||||||
@ -2437,7 +2437,7 @@ SSL_get_client_random(SSL *s, uint8_t *out, size_t len)
|
|||||||
memcpy(out, s->s3->client_random, len);
|
memcpy(out, s->s3->client_random, len);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(HAVE_SSL_GET_CLIENT_RANDOM) */
|
||||||
|
|
||||||
#ifndef HAVE_SSL_GET_SERVER_RANDOM
|
#ifndef HAVE_SSL_GET_SERVER_RANDOM
|
||||||
static size_t
|
static size_t
|
||||||
@ -2450,7 +2450,7 @@ SSL_get_server_random(SSL *s, uint8_t *out, size_t len)
|
|||||||
memcpy(out, s->s3->server_random, len);
|
memcpy(out, s->s3->server_random, len);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(HAVE_SSL_GET_SERVER_RANDOM) */
|
||||||
|
|
||||||
#ifndef HAVE_SSL_SESSION_GET_MASTER_KEY
|
#ifndef HAVE_SSL_SESSION_GET_MASTER_KEY
|
||||||
STATIC size_t
|
STATIC size_t
|
||||||
@ -2464,7 +2464,7 @@ SSL_SESSION_get_master_key(SSL_SESSION *s, uint8_t *out, size_t len)
|
|||||||
memcpy(out, s->master_key, len);
|
memcpy(out, s->master_key, len);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(HAVE_SSL_SESSION_GET_MASTER_KEY) */
|
||||||
|
|
||||||
/** Set the DIGEST256_LEN buffer at <b>secrets_out</b> to the value used in
|
/** Set the DIGEST256_LEN buffer at <b>secrets_out</b> to the value used in
|
||||||
* the v3 handshake to prove that the client knows the TLS secrets for the
|
* the v3 handshake to prove that the client knows the TLS secrets for the
|
||||||
@ -2573,7 +2573,7 @@ tor_tls_get_buffer_sizes(tor_tls_t *tls,
|
|||||||
(void)wbuf_bytes;
|
(void)wbuf_bytes;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
#else /* !(OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0)) */
|
||||||
if (tls->ssl->s3->rbuf.buf)
|
if (tls->ssl->s3->rbuf.buf)
|
||||||
*rbuf_capacity = tls->ssl->s3->rbuf.len;
|
*rbuf_capacity = tls->ssl->s3->rbuf.len;
|
||||||
else
|
else
|
||||||
@ -2585,7 +2585,7 @@ tor_tls_get_buffer_sizes(tor_tls_t *tls,
|
|||||||
*rbuf_bytes = tls->ssl->s3->rbuf.left;
|
*rbuf_bytes = tls->ssl->s3->rbuf.left;
|
||||||
*wbuf_bytes = tls->ssl->s3->wbuf.left;
|
*wbuf_bytes = tls->ssl->s3->wbuf.left;
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the ECC group requested is supported by the current OpenSSL
|
/** Check whether the ECC group requested is supported by the current OpenSSL
|
||||||
|
@ -161,7 +161,7 @@ STATIC int tor_tls_session_secret_cb(struct ssl_st *ssl, void *secret,
|
|||||||
void *arg);
|
void *arg);
|
||||||
STATIC int find_cipher_by_id(const SSL *ssl, const SSL_METHOD *m,
|
STATIC int find_cipher_by_id(const SSL *ssl, const SSL_METHOD *m,
|
||||||
uint16_t cipher);
|
uint16_t cipher);
|
||||||
#endif
|
#endif /* defined(TORTLS_OPENSSL_PRIVATE) */
|
||||||
MOCK_DECL(STATIC struct x509_st *, tor_tls_create_certificate,
|
MOCK_DECL(STATIC struct x509_st *, tor_tls_create_certificate,
|
||||||
(crypto_pk_t *rsa,
|
(crypto_pk_t *rsa,
|
||||||
crypto_pk_t *rsa_sign,
|
crypto_pk_t *rsa_sign,
|
||||||
@ -192,9 +192,9 @@ STATIC tor_x509_cert_t *tor_x509_cert_replace_expiration(
|
|||||||
const tor_x509_cert_t *inp,
|
const tor_x509_cert_t *inp,
|
||||||
time_t new_expiration_time,
|
time_t new_expiration_time,
|
||||||
crypto_pk_t *signing_key);
|
crypto_pk_t *signing_key);
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#endif /* endif TORTLS_PRIVATE */
|
#endif /* defined(TORTLS_PRIVATE) */
|
||||||
|
|
||||||
tor_x509_cert_t *tor_x509_cert_dup(const tor_x509_cert_t *cert);
|
tor_x509_cert_t *tor_x509_cert_dup(const tor_x509_cert_t *cert);
|
||||||
const char *tor_tls_err_to_string(int err);
|
const char *tor_tls_err_to_string(int err);
|
||||||
@ -288,5 +288,5 @@ const char *tor_tls_get_ciphersuite_name(tor_tls_t *tls);
|
|||||||
|
|
||||||
int evaluate_ecgroup_for_tls(const char *ecgroup);
|
int evaluate_ecgroup_for_tls(const char *ecgroup);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_TORTLS_H) */
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@
|
|||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/* math.h needs this on Linux */
|
/* math.h needs this on Linux */
|
||||||
#ifndef _USE_ISOC99_
|
#ifndef _USE_ISOC99_
|
||||||
@ -84,8 +84,8 @@
|
|||||||
* scold us for being so stupid as to autodetect its presence. To be fair,
|
* scold us for being so stupid as to autodetect its presence. To be fair,
|
||||||
* they've done this since 1996, when autoconf was only 5 years old. */
|
* they've done this since 1996, when autoconf was only 5 years old. */
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif /* !defined(OpenBSD) && !defined(__FreeBSD__) */
|
||||||
#endif
|
#endif /* defined(HAVE_MALLOC_H) */
|
||||||
#ifdef HAVE_MALLOC_NP_H
|
#ifdef HAVE_MALLOC_NP_H
|
||||||
#include <malloc_np.h>
|
#include <malloc_np.h>
|
||||||
#endif
|
#endif
|
||||||
@ -116,12 +116,12 @@
|
|||||||
dmalloc_strndup(file, line, (string), -1, xalloc_b)
|
dmalloc_strndup(file, line, (string), -1, xalloc_b)
|
||||||
#else
|
#else
|
||||||
#error "No dmalloc_strdup or equivalent"
|
#error "No dmalloc_strdup or equivalent"
|
||||||
#endif
|
#endif /* defined(HAVE_DMALLOC_STRDUP) || ... */
|
||||||
|
|
||||||
#else /* not using dmalloc */
|
#else /* !(defined(USE_DMALLOC)) */
|
||||||
|
|
||||||
#define DMALLOC_FN_ARGS
|
#define DMALLOC_FN_ARGS
|
||||||
#endif
|
#endif /* defined(USE_DMALLOC) */
|
||||||
|
|
||||||
/** Allocate a chunk of <b>size</b> bytes of memory, and return a pointer to
|
/** Allocate a chunk of <b>size</b> bytes of memory, and return a pointer to
|
||||||
* result. On error, log and terminate the process. (Same as malloc(size),
|
* result. On error, log and terminate the process. (Same as malloc(size),
|
||||||
@ -142,7 +142,7 @@ tor_malloc_(size_t size DMALLOC_PARAMS)
|
|||||||
if (size==0) {
|
if (size==0) {
|
||||||
size=1;
|
size=1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(MALLOC_ZERO_WORKS) */
|
||||||
|
|
||||||
#ifdef USE_DMALLOC
|
#ifdef USE_DMALLOC
|
||||||
result = dmalloc_malloc(file, line, size, DMALLOC_FUNC_MALLOC, 0, 0);
|
result = dmalloc_malloc(file, line, size, DMALLOC_FUNC_MALLOC, 0, 0);
|
||||||
@ -233,7 +233,7 @@ tor_realloc_(void *ptr, size_t size DMALLOC_PARAMS)
|
|||||||
if (size==0) {
|
if (size==0) {
|
||||||
size=1;
|
size=1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(MALLOC_ZERO_WORKS) */
|
||||||
|
|
||||||
#ifdef USE_DMALLOC
|
#ifdef USE_DMALLOC
|
||||||
result = dmalloc_realloc(file, line, ptr, size, DMALLOC_FUNC_REALLOC, 0);
|
result = dmalloc_realloc(file, line, ptr, size, DMALLOC_FUNC_REALLOC, 0);
|
||||||
@ -362,16 +362,16 @@ tor_log_mallinfo(int severity)
|
|||||||
mi.arena, mi.ordblks, mi.smblks, mi.hblks,
|
mi.arena, mi.ordblks, mi.smblks, mi.hblks,
|
||||||
mi.hblkhd, mi.usmblks, mi.fsmblks, mi.uordblks, mi.fordblks,
|
mi.hblkhd, mi.usmblks, mi.fsmblks, mi.uordblks, mi.fordblks,
|
||||||
mi.keepcost);
|
mi.keepcost);
|
||||||
#else
|
#else /* !(defined(HAVE_MALLINFO)) */
|
||||||
(void)severity;
|
(void)severity;
|
||||||
#endif
|
#endif /* defined(HAVE_MALLINFO) */
|
||||||
#ifdef USE_DMALLOC
|
#ifdef USE_DMALLOC
|
||||||
dmalloc_log_changed(0, /* Since the program started. */
|
dmalloc_log_changed(0, /* Since the program started. */
|
||||||
1, /* Log info about non-freed pointers. */
|
1, /* Log info about non-freed pointers. */
|
||||||
0, /* Do not log info about freed pointers. */
|
0, /* Do not log info about freed pointers. */
|
||||||
0 /* Do not log individual pointers. */
|
0 /* Do not log individual pointers. */
|
||||||
);
|
);
|
||||||
#endif
|
#endif /* defined(USE_DMALLOC) */
|
||||||
}
|
}
|
||||||
ENABLE_GCC_WARNING(aggregate-return)
|
ENABLE_GCC_WARNING(aggregate-return)
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ tor_lround(double d)
|
|||||||
return (long)rint(d);
|
return (long)rint(d);
|
||||||
#else
|
#else
|
||||||
return (long)(d > 0 ? d + 0.5 : ceil(d - 0.5));
|
return (long)(d > 0 ? d + 0.5 : ceil(d - 0.5));
|
||||||
#endif
|
#endif /* defined(HAVE_LROUND) || ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the 64-bit integer closest to d. We define this wrapper here so
|
/** Return the 64-bit integer closest to d. We define this wrapper here so
|
||||||
@ -416,7 +416,7 @@ tor_llround(double d)
|
|||||||
return (int64_t)rint(d);
|
return (int64_t)rint(d);
|
||||||
#else
|
#else
|
||||||
return (int64_t)(d > 0 ? d + 0.5 : ceil(d - 0.5));
|
return (int64_t)(d > 0 ? d + 0.5 : ceil(d - 0.5));
|
||||||
#endif
|
#endif /* defined(HAVE_LLROUND) || ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns floor(log2(u64)). If u64 is 0, (incorrectly) returns 0. */
|
/** Returns floor(log2(u64)). If u64 is 0, (incorrectly) returns 0. */
|
||||||
@ -1238,7 +1238,7 @@ tor_parse_uint64(const char *s, int base, uint64_t min,
|
|||||||
r = (uint64_t)strtoul(s, &endptr, base);
|
r = (uint64_t)strtoul(s, &endptr, base);
|
||||||
#else
|
#else
|
||||||
#error "I don't know how to parse 64-bit numbers."
|
#error "I don't know how to parse 64-bit numbers."
|
||||||
#endif
|
#endif /* defined(HAVE_STRTOULL) || ... */
|
||||||
|
|
||||||
CHECK_STRTOX_RESULT();
|
CHECK_STRTOX_RESULT();
|
||||||
}
|
}
|
||||||
@ -1636,7 +1636,7 @@ tor_timegm(const struct tm *tm, time_t *time_out)
|
|||||||
log_warn(LD_BUG, "Result does not fit in tor_timegm");
|
log_warn(LD_BUG, "Result does not fit in tor_timegm");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* SIZEOF_TIME_T < 8 */
|
||||||
*time_out = (time_t)seconds;
|
*time_out = (time_t)seconds;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2014,7 +2014,7 @@ update_approx_time(time_t now)
|
|||||||
{
|
{
|
||||||
cached_approx_time = now;
|
cached_approx_time = now;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(TIME_IS_FAST) */
|
||||||
|
|
||||||
/* =====
|
/* =====
|
||||||
* Rate limiting
|
* Rate limiting
|
||||||
@ -2143,9 +2143,9 @@ clean_name_for_stat(char *name)
|
|||||||
return;
|
return;
|
||||||
name[len-1]='\0';
|
name[len-1]='\0';
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
(void)name;
|
(void)name;
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wrapper for unlink() to make it mockable for the test suite; returns 0
|
/** Wrapper for unlink() to make it mockable for the test suite; returns 0
|
||||||
@ -2419,7 +2419,7 @@ check_private_dir,(const char *dirname, cpd_check_t check,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
#else
|
#else /* !(!defined(_WIN32)) */
|
||||||
/* Win32 case: we can't open() a directory. */
|
/* Win32 case: we can't open() a directory. */
|
||||||
(void)effective_user;
|
(void)effective_user;
|
||||||
|
|
||||||
@ -2453,7 +2453,7 @@ check_private_dir,(const char *dirname, cpd_check_t check,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2473,7 +2473,7 @@ write_str_to_file,(const char *fname, const char *str, int bin))
|
|||||||
"We're writing a text string that already contains a CR to %s",
|
"We're writing a text string that already contains a CR to %s",
|
||||||
escaped(fname));
|
escaped(fname));
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
return write_bytes_to_file(fname, str, strlen(str), bin);
|
return write_bytes_to_file(fname, str, strlen(str), bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2873,7 +2873,7 @@ read_file_to_str, (const char *filename, int flags, struct stat *stat_out))
|
|||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
if ((uint64_t)(statbuf.st_size)+1 >= SIZE_T_CEILING) {
|
if ((uint64_t)(statbuf.st_size)+1 >= SIZE_T_CEILING) {
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -2906,7 +2906,7 @@ read_file_to_str, (const char *filename, int flags, struct stat *stat_out))
|
|||||||
if (!bin) {
|
if (!bin) {
|
||||||
statbuf.st_size = (size_t) r;
|
statbuf.st_size = (size_t) r;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif /* defined(_WIN32) || defined(__CYGWIN__) */
|
||||||
if (r != statbuf.st_size) {
|
if (r != statbuf.st_size) {
|
||||||
/* Unless we're using text mode on win32, we'd better have an exact
|
/* Unless we're using text mode on win32, we'd better have an exact
|
||||||
* match for size. */
|
* match for size. */
|
||||||
@ -3090,7 +3090,7 @@ expand_filename(const char *filename)
|
|||||||
* Chapter+3.+Input+Validation/3.7+Validating+Filenames+and+Paths/
|
* Chapter+3.+Input+Validation/3.7+Validating+Filenames+and+Paths/
|
||||||
*/
|
*/
|
||||||
return tor_strdup(filename);
|
return tor_strdup(filename);
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
if (*filename == '~') {
|
if (*filename == '~') {
|
||||||
char *home, *result=NULL;
|
char *home, *result=NULL;
|
||||||
const char *rest;
|
const char *rest;
|
||||||
@ -3120,10 +3120,10 @@ expand_filename(const char *filename)
|
|||||||
}
|
}
|
||||||
tor_free(username);
|
tor_free(username);
|
||||||
rest = slash ? (slash+1) : "";
|
rest = slash ? (slash+1) : "";
|
||||||
#else
|
#else /* !(defined(HAVE_PWD_H)) */
|
||||||
log_warn(LD_CONFIG, "Couldn't expand homedir on system without pwd.h");
|
log_warn(LD_CONFIG, "Couldn't expand homedir on system without pwd.h");
|
||||||
return tor_strdup(filename);
|
return tor_strdup(filename);
|
||||||
#endif
|
#endif /* defined(HAVE_PWD_H) */
|
||||||
}
|
}
|
||||||
tor_assert(home);
|
tor_assert(home);
|
||||||
/* Remove trailing slash. */
|
/* Remove trailing slash. */
|
||||||
@ -3136,7 +3136,7 @@ expand_filename(const char *filename)
|
|||||||
} else {
|
} else {
|
||||||
return tor_strdup(filename);
|
return tor_strdup(filename);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_SCANF_WIDTH 9999
|
#define MAX_SCANF_WIDTH 9999
|
||||||
@ -3505,7 +3505,7 @@ tor_listdir, (const char *dirname))
|
|||||||
name[sizeof(name)-1] = '\0';
|
name[sizeof(name)-1] = '\0';
|
||||||
#else
|
#else
|
||||||
strlcpy(name,findData.cFileName,sizeof(name));
|
strlcpy(name,findData.cFileName,sizeof(name));
|
||||||
#endif
|
#endif /* defined(UNICODE) */
|
||||||
if (strcmp(name, ".") &&
|
if (strcmp(name, ".") &&
|
||||||
strcmp(name, "..")) {
|
strcmp(name, "..")) {
|
||||||
smartlist_add_strdup(result, name);
|
smartlist_add_strdup(result, name);
|
||||||
@ -3522,7 +3522,7 @@ tor_listdir, (const char *dirname))
|
|||||||
}
|
}
|
||||||
FindClose(handle);
|
FindClose(handle);
|
||||||
tor_free(pattern);
|
tor_free(pattern);
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
const char *prot_dname = sandbox_intern_string(dirname);
|
const char *prot_dname = sandbox_intern_string(dirname);
|
||||||
DIR *d;
|
DIR *d;
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
@ -3537,7 +3537,7 @@ tor_listdir, (const char *dirname))
|
|||||||
smartlist_add_strdup(result, de->d_name);
|
smartlist_add_strdup(result, de->d_name);
|
||||||
}
|
}
|
||||||
closedir(d);
|
closedir(d);
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3553,7 +3553,7 @@ path_is_relative(const char *filename)
|
|||||||
else if (filename && strlen(filename)>3 && TOR_ISALPHA(filename[0]) &&
|
else if (filename && strlen(filename)>3 && TOR_ISALPHA(filename[0]) &&
|
||||||
filename[1] == ':' && filename[2] == '\\')
|
filename[1] == ':' && filename[2] == '\\')
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -3683,7 +3683,7 @@ finish_daemon(const char *desired_cwd)
|
|||||||
}
|
}
|
||||||
close(daemon_filedes[1]);
|
close(daemon_filedes[1]);
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(!defined(_WIN32)) */
|
||||||
/* defined(_WIN32) */
|
/* defined(_WIN32) */
|
||||||
void
|
void
|
||||||
start_daemon(void)
|
start_daemon(void)
|
||||||
@ -3694,7 +3694,7 @@ finish_daemon(const char *cp)
|
|||||||
{
|
{
|
||||||
(void)cp;
|
(void)cp;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
/** Write the current process ID, followed by NL, into <b>filename</b>.
|
/** Write the current process ID, followed by NL, into <b>filename</b>.
|
||||||
* Return 0 on success, -1 on failure.
|
* Return 0 on success, -1 on failure.
|
||||||
@ -3736,7 +3736,7 @@ load_windows_system_library(const TCHAR *library_name)
|
|||||||
_tcscat(path, library_name);
|
_tcscat(path, library_name);
|
||||||
return LoadLibrary(path);
|
return LoadLibrary(path);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/** Format a single argument for being put on a Windows command line.
|
/** Format a single argument for being put on a Windows command line.
|
||||||
* Returns a newly allocated string */
|
* Returns a newly allocated string */
|
||||||
@ -4031,7 +4031,7 @@ format_helper_exit_status(unsigned char child_state, int saved_errno,
|
|||||||
done:
|
done:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
/* Maximum number of file descriptors, if we cannot get it via sysconf() */
|
/* Maximum number of file descriptors, if we cannot get it via sysconf() */
|
||||||
#define DEFAULT_MAX_FD 256
|
#define DEFAULT_MAX_FD 256
|
||||||
@ -4055,12 +4055,12 @@ tor_terminate_process(process_handle_t *process_handle)
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else /* Unix */
|
#else /* !(defined(_WIN32)) */
|
||||||
if (process_handle->waitpid_cb) {
|
if (process_handle->waitpid_cb) {
|
||||||
/* We haven't got a waitpid yet, so we can just kill off the process. */
|
/* We haven't got a waitpid yet, so we can just kill off the process. */
|
||||||
return kill(process_handle->pid, SIGTERM);
|
return kill(process_handle->pid, SIGTERM);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
return 0; /* We didn't need to kill the process, so report success */
|
return 0; /* We didn't need to kill the process, so report success */
|
||||||
}
|
}
|
||||||
@ -4082,14 +4082,14 @@ tor_process_get_stdout_pipe(process_handle_t *process_handle)
|
|||||||
{
|
{
|
||||||
return process_handle->stdout_pipe;
|
return process_handle->stdout_pipe;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
/* DOCDOC tor_process_get_stdout_pipe */
|
/* DOCDOC tor_process_get_stdout_pipe */
|
||||||
int
|
int
|
||||||
tor_process_get_stdout_pipe(process_handle_t *process_handle)
|
tor_process_get_stdout_pipe(process_handle_t *process_handle)
|
||||||
{
|
{
|
||||||
return process_handle->stdout_pipe;
|
return process_handle->stdout_pipe;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/* DOCDOC process_handle_new */
|
/* DOCDOC process_handle_new */
|
||||||
static process_handle_t *
|
static process_handle_t *
|
||||||
@ -4105,7 +4105,7 @@ process_handle_new(void)
|
|||||||
out->stdin_pipe = -1;
|
out->stdin_pipe = -1;
|
||||||
out->stdout_pipe = -1;
|
out->stdout_pipe = -1;
|
||||||
out->stderr_pipe = -1;
|
out->stderr_pipe = -1;
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -4125,7 +4125,7 @@ process_handle_waitpid_cb(int status, void *arg)
|
|||||||
process_handle->status = PROCESS_STATUS_NOTRUNNING;
|
process_handle->status = PROCESS_STATUS_NOTRUNNING;
|
||||||
process_handle->waitpid_cb = 0;
|
process_handle->waitpid_cb = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name child-process states
|
* @name child-process states
|
||||||
@ -4308,7 +4308,7 @@ tor_spawn_background(const char *const filename, const char **argv,
|
|||||||
/* TODO: Close pipes on exit */
|
/* TODO: Close pipes on exit */
|
||||||
*process_handle_out = process_handle;
|
*process_handle_out = process_handle;
|
||||||
return status;
|
return status;
|
||||||
#else // _WIN32
|
#else /* !(defined(_WIN32)) */
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int stdout_pipe[2];
|
int stdout_pipe[2];
|
||||||
int stderr_pipe[2];
|
int stderr_pipe[2];
|
||||||
@ -4383,9 +4383,9 @@ tor_spawn_background(const char *const filename, const char **argv,
|
|||||||
"Cannot find maximum file descriptor, assuming %d", max_fd);
|
"Cannot find maximum file descriptor, assuming %d", max_fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(_SC_OPEN_MAX)) */
|
||||||
max_fd = DEFAULT_MAX_FD;
|
max_fd = DEFAULT_MAX_FD;
|
||||||
#endif
|
#endif /* defined(_SC_OPEN_MAX) */
|
||||||
|
|
||||||
child_state = CHILD_STATE_FORK;
|
child_state = CHILD_STATE_FORK;
|
||||||
|
|
||||||
@ -4400,7 +4400,7 @@ tor_spawn_background(const char *const filename, const char **argv,
|
|||||||
* than nothing.
|
* than nothing.
|
||||||
*/
|
*/
|
||||||
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
||||||
#endif
|
#endif /* defined(HAVE_SYS_PRCTL_H) && defined(__linux__) */
|
||||||
|
|
||||||
child_state = CHILD_STATE_DUPOUT;
|
child_state = CHILD_STATE_DUPOUT;
|
||||||
|
|
||||||
@ -4541,7 +4541,7 @@ tor_spawn_background(const char *const filename, const char **argv,
|
|||||||
|
|
||||||
*process_handle_out = process_handle;
|
*process_handle_out = process_handle;
|
||||||
return process_handle->status;
|
return process_handle->status;
|
||||||
#endif // _WIN32
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destroy all resources allocated by the process handle in
|
/** Destroy all resources allocated by the process handle in
|
||||||
@ -4583,13 +4583,13 @@ tor_process_handle_destroy,(process_handle_t *process_handle,
|
|||||||
|
|
||||||
if (process_handle->stdin_pipe)
|
if (process_handle->stdin_pipe)
|
||||||
CloseHandle(process_handle->stdin_pipe);
|
CloseHandle(process_handle->stdin_pipe);
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
close(process_handle->stdout_pipe);
|
close(process_handle->stdout_pipe);
|
||||||
close(process_handle->stderr_pipe);
|
close(process_handle->stderr_pipe);
|
||||||
close(process_handle->stdin_pipe);
|
close(process_handle->stdin_pipe);
|
||||||
|
|
||||||
clear_waitpid_callback(process_handle->waitpid_cb);
|
clear_waitpid_callback(process_handle->waitpid_cb);
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
memset(process_handle, 0x0f, sizeof(process_handle_t));
|
memset(process_handle, 0x0f, sizeof(process_handle_t));
|
||||||
tor_free(process_handle);
|
tor_free(process_handle);
|
||||||
@ -4642,7 +4642,7 @@ tor_get_exit_code(process_handle_t *process_handle,
|
|||||||
return PROCESS_EXIT_ERROR;
|
return PROCESS_EXIT_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
int stat_loc;
|
int stat_loc;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
@ -4677,7 +4677,7 @@ tor_get_exit_code(process_handle_t *process_handle,
|
|||||||
|
|
||||||
if (exit_code != NULL)
|
if (exit_code != NULL)
|
||||||
*exit_code = WEXITSTATUS(stat_loc);
|
*exit_code = WEXITSTATUS(stat_loc);
|
||||||
#endif // _WIN32
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
return PROCESS_EXIT_EXITED;
|
return PROCESS_EXIT_EXITED;
|
||||||
}
|
}
|
||||||
@ -4917,7 +4917,7 @@ tor_read_all_handle(HANDLE h, char *buf, size_t count,
|
|||||||
}
|
}
|
||||||
return (ssize_t)numread;
|
return (ssize_t)numread;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
/** Read from a handle <b>fd</b> into <b>buf</b>, up to <b>count</b> bytes. If
|
/** Read from a handle <b>fd</b> into <b>buf</b>, up to <b>count</b> bytes. If
|
||||||
* <b>process</b> is NULL, the function will return immediately if there is
|
* <b>process</b> is NULL, the function will return immediately if there is
|
||||||
* nothing more to read. Otherwise data will be read until end of file, or
|
* nothing more to read. Otherwise data will be read until end of file, or
|
||||||
@ -4962,7 +4962,7 @@ tor_read_all_handle(int fd, char *buf, size_t count,
|
|||||||
log_debug(LD_GENERAL, "read() read %d bytes from handle", (int)numread);
|
log_debug(LD_GENERAL, "read() read %d bytes from handle", (int)numread);
|
||||||
return (ssize_t)numread;
|
return (ssize_t)numread;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/** Read from stdout of a process until the process exits. */
|
/** Read from stdout of a process until the process exits. */
|
||||||
ssize_t
|
ssize_t
|
||||||
@ -4975,7 +4975,7 @@ tor_read_all_from_process_stdout(const process_handle_t *process_handle,
|
|||||||
#else
|
#else
|
||||||
return tor_read_all_handle(process_handle->stdout_pipe, buf, count,
|
return tor_read_all_handle(process_handle->stdout_pipe, buf, count,
|
||||||
process_handle, NULL);
|
process_handle, NULL);
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Read from stdout of a process until the process exits. */
|
/** Read from stdout of a process until the process exits. */
|
||||||
@ -4989,7 +4989,7 @@ tor_read_all_from_process_stderr(const process_handle_t *process_handle,
|
|||||||
#else
|
#else
|
||||||
return tor_read_all_handle(process_handle->stderr_pipe, buf, count,
|
return tor_read_all_handle(process_handle->stderr_pipe, buf, count,
|
||||||
process_handle, NULL);
|
process_handle, NULL);
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Split buf into lines, and add to smartlist. The buffer <b>buf</b> will be
|
/** Split buf into lines, and add to smartlist. The buffer <b>buf</b> will be
|
||||||
@ -5178,7 +5178,7 @@ log_from_handle(HANDLE *pipe, int severity)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
|
|
||||||
/** Return a smartlist containing lines outputted from
|
/** Return a smartlist containing lines outputted from
|
||||||
* <b>fd</b>. Return NULL on error, and set
|
* <b>fd</b>. Return NULL on error, and set
|
||||||
@ -5243,7 +5243,7 @@ log_from_pipe(int fd, int severity, const char *executable,
|
|||||||
/* We should never get here */
|
/* We should never get here */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/** Reads from <b>fd</b> and stores input in <b>buf_out</b> making
|
/** Reads from <b>fd</b> and stores input in <b>buf_out</b> making
|
||||||
* sure it's below <b>count</b> bytes.
|
* sure it's below <b>count</b> bytes.
|
||||||
@ -5495,7 +5495,7 @@ tor_check_port_forwarding(const char *filename,
|
|||||||
status = tor_spawn_background(NULL, argv, NULL, &child_handle);
|
status = tor_spawn_background(NULL, argv, NULL, &child_handle);
|
||||||
#else
|
#else
|
||||||
status = tor_spawn_background(filename, argv, NULL, &child_handle);
|
status = tor_spawn_background(filename, argv, NULL, &child_handle);
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
tor_free_((void*)argv);
|
tor_free_((void*)argv);
|
||||||
argv=NULL;
|
argv=NULL;
|
||||||
@ -5521,7 +5521,7 @@ tor_check_port_forwarding(const char *filename,
|
|||||||
#else
|
#else
|
||||||
stderr_status = log_from_pipe(child_handle->stderr_pipe,
|
stderr_status = log_from_pipe(child_handle->stderr_pipe,
|
||||||
LOG_INFO, filename, &retval);
|
LOG_INFO, filename, &retval);
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
if (handle_fw_helper_output(filename, child_handle) < 0) {
|
if (handle_fw_helper_output(filename, child_handle) < 0) {
|
||||||
log_warn(LD_GENERAL, "Failed to handle fw helper output.");
|
log_warn(LD_GENERAL, "Failed to handle fw helper output.");
|
||||||
stdout_status = -1;
|
stdout_status = -1;
|
||||||
@ -5546,13 +5546,13 @@ tor_check_port_forwarding(const char *filename,
|
|||||||
* between log_from_handle and tor_get_exit_code? */
|
* between log_from_handle and tor_get_exit_code? */
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
else if (1 == stdout_status || 1 == stderr_status)
|
else if (1 == stdout_status || 1 == stderr_status)
|
||||||
/* stdout or stderr was closed, the process probably
|
/* stdout or stderr was closed, the process probably
|
||||||
* exited. It will be reaped by waitpid() in main.c */
|
* exited. It will be reaped by waitpid() in main.c */
|
||||||
/* TODO: Do something with the process return value */
|
/* TODO: Do something with the process return value */
|
||||||
retval = 1;
|
retval = 1;
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
else
|
else
|
||||||
/* Both are fine */
|
/* Both are fine */
|
||||||
retval = 0;
|
retval = 0;
|
||||||
@ -5632,7 +5632,7 @@ clamp_double_to_int64(double number)
|
|||||||
*/
|
*/
|
||||||
#define PROBLEMATIC_FLOAT_CONVERSION_WARNING
|
#define PROBLEMATIC_FLOAT_CONVERSION_WARNING
|
||||||
DISABLE_GCC_WARNING(float-conversion)
|
DISABLE_GCC_WARNING(float-conversion)
|
||||||
#endif
|
#endif /* defined(MINGW_ANY) && GCC_VERSION >= 409 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
With clang 4.0 we apparently run into "double promotion" warnings here,
|
With clang 4.0 we apparently run into "double promotion" warnings here,
|
||||||
@ -5643,7 +5643,7 @@ DISABLE_GCC_WARNING(float-conversion)
|
|||||||
#define PROBLEMATIC_DOUBLE_PROMOTION_WARNING
|
#define PROBLEMATIC_DOUBLE_PROMOTION_WARNING
|
||||||
DISABLE_GCC_WARNING(double-promotion)
|
DISABLE_GCC_WARNING(double-promotion)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(__clang__) */
|
||||||
|
|
||||||
/* NaN is a special case that can't be used with the logic below. */
|
/* NaN is a special case that can't be used with the logic below. */
|
||||||
if (isnan(number)) {
|
if (isnan(number)) {
|
||||||
@ -5690,7 +5690,7 @@ tor_htonll(uint64_t a)
|
|||||||
/* Little endian. The worst... */
|
/* Little endian. The worst... */
|
||||||
return htonl((uint32_t)(a>>32)) |
|
return htonl((uint32_t)(a>>32)) |
|
||||||
(((uint64_t)htonl((uint32_t)a))<<32);
|
(((uint64_t)htonl((uint32_t)a))<<32);
|
||||||
#endif /* WORDS_BIGENDIAN */
|
#endif /* defined(WORDS_BIGENDIAN) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a uint64_t value from <b>a</b> in host byte order. */
|
/** Return a uint64_t value from <b>a</b> in host byte order. */
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#else
|
#else
|
||||||
#define DMALLOC_PARAMS
|
#define DMALLOC_PARAMS
|
||||||
#define DMALLOC_ARGS
|
#define DMALLOC_ARGS
|
||||||
#endif
|
#endif /* defined(USE_DMALLOC) */
|
||||||
|
|
||||||
/* Memory management */
|
/* Memory management */
|
||||||
void *tor_malloc_(size_t size DMALLOC_PARAMS) ATTR_MALLOC;
|
void *tor_malloc_(size_t size DMALLOC_PARAMS) ATTR_MALLOC;
|
||||||
@ -72,7 +72,7 @@ extern int dmalloc_free(const char *file, const int line, void *pnt,
|
|||||||
(p)=NULL; \
|
(p)=NULL; \
|
||||||
} \
|
} \
|
||||||
STMT_END
|
STMT_END
|
||||||
#else
|
#else /* !(defined(USE_DMALLOC)) */
|
||||||
/** Release memory allocated by tor_malloc, tor_realloc, tor_strdup, etc.
|
/** Release memory allocated by tor_malloc, tor_realloc, tor_strdup, etc.
|
||||||
* Unlike the free() function, tor_free() will still work on NULL pointers,
|
* Unlike the free() function, tor_free() will still work on NULL pointers,
|
||||||
* and it sets the pointer value to NULL after freeing it.
|
* and it sets the pointer value to NULL after freeing it.
|
||||||
@ -86,7 +86,7 @@ extern int dmalloc_free(const char *file, const int line, void *pnt,
|
|||||||
(p)=NULL; \
|
(p)=NULL; \
|
||||||
} \
|
} \
|
||||||
STMT_END
|
STMT_END
|
||||||
#endif
|
#endif /* defined(USE_DMALLOC) */
|
||||||
|
|
||||||
#define tor_malloc(size) tor_malloc_(size DMALLOC_ARGS)
|
#define tor_malloc(size) tor_malloc_(size DMALLOC_ARGS)
|
||||||
#define tor_malloc_zero(size) tor_malloc_zero_(size DMALLOC_ARGS)
|
#define tor_malloc_zero(size) tor_malloc_zero_(size DMALLOC_ARGS)
|
||||||
@ -261,7 +261,7 @@ int format_time_interval(char *out, size_t out_len, long interval);
|
|||||||
#else
|
#else
|
||||||
time_t approx_time(void);
|
time_t approx_time(void);
|
||||||
void update_approx_time(time_t now);
|
void update_approx_time(time_t now);
|
||||||
#endif
|
#endif /* defined(TIME_IS_FAST) */
|
||||||
|
|
||||||
/* Rate-limiter */
|
/* Rate-limiter */
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ struct process_handle_t {
|
|||||||
HANDLE stdout_pipe;
|
HANDLE stdout_pipe;
|
||||||
HANDLE stderr_pipe;
|
HANDLE stderr_pipe;
|
||||||
PROCESS_INFORMATION pid;
|
PROCESS_INFORMATION pid;
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
int stdin_pipe;
|
int stdin_pipe;
|
||||||
int stdout_pipe;
|
int stdout_pipe;
|
||||||
int stderr_pipe;
|
int stderr_pipe;
|
||||||
@ -462,9 +462,9 @@ struct process_handle_t {
|
|||||||
struct waitpid_callback_t *waitpid_cb;
|
struct waitpid_callback_t *waitpid_cb;
|
||||||
/** The exit status reported by waitpid. */
|
/** The exit status reported by waitpid. */
|
||||||
int waitpid_exit_status;
|
int waitpid_exit_status;
|
||||||
#endif // _WIN32
|
#endif /* defined(_WIN32) */
|
||||||
};
|
};
|
||||||
#endif
|
#endif /* defined(UTIL_PRIVATE) */
|
||||||
|
|
||||||
/* Return values of tor_get_exit_code() */
|
/* Return values of tor_get_exit_code() */
|
||||||
#define PROCESS_EXIT_RUNNING 1
|
#define PROCESS_EXIT_RUNNING 1
|
||||||
@ -480,7 +480,7 @@ ssize_t tor_read_all_handle(HANDLE h, char *buf, size_t count,
|
|||||||
ssize_t tor_read_all_handle(int fd, char *buf, size_t count,
|
ssize_t tor_read_all_handle(int fd, char *buf, size_t count,
|
||||||
const process_handle_t *process,
|
const process_handle_t *process,
|
||||||
int *eof);
|
int *eof);
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
ssize_t tor_read_all_from_process_stdout(
|
ssize_t tor_read_all_from_process_stdout(
|
||||||
const process_handle_t *process_handle, char *buf, size_t count);
|
const process_handle_t *process_handle, char *buf, size_t count);
|
||||||
ssize_t tor_read_all_from_process_stderr(
|
ssize_t tor_read_all_from_process_stderr(
|
||||||
@ -502,7 +502,7 @@ tor_get_lines_from_handle,(HANDLE *handle,
|
|||||||
MOCK_DECL(struct smartlist_t *,
|
MOCK_DECL(struct smartlist_t *,
|
||||||
tor_get_lines_from_handle,(int fd,
|
tor_get_lines_from_handle,(int fd,
|
||||||
enum stream_status *stream_status));
|
enum stream_status *stream_status));
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
int
|
int
|
||||||
tor_terminate_process(process_handle_t *process_handle);
|
tor_terminate_process(process_handle_t *process_handle);
|
||||||
@ -539,13 +539,13 @@ STATIC int format_helper_exit_status(unsigned char child_state,
|
|||||||
leading minus) and newline (no null) */
|
leading minus) and newline (no null) */
|
||||||
#define HEX_ERRNO_SIZE (sizeof(char) * 2 + 1 + \
|
#define HEX_ERRNO_SIZE (sizeof(char) * 2 + 1 + \
|
||||||
1 + sizeof(int) * 2 + 1)
|
1 + sizeof(int) * 2 + 1)
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
#endif
|
#endif /* defined(UTIL_PRIVATE) */
|
||||||
|
|
||||||
int size_mul_check(const size_t x, const size_t y);
|
int size_mul_check(const size_t x, const size_t y);
|
||||||
|
|
||||||
#define ARRAY_LENGTH(x) ((sizeof(x)) / sizeof(x[0]))
|
#define ARRAY_LENGTH(x) ((sizeof(x)) / sizeof(x[0]))
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_UTIL_H) */
|
||||||
|
|
||||||
|
@ -59,10 +59,10 @@ tor_set_failed_assertion_callback(void (*fn)(void))
|
|||||||
{
|
{
|
||||||
failed_assertion_cb = fn;
|
failed_assertion_cb = fn;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(TOR_UNIT_TESTS)) */
|
||||||
#define capturing_bugs() (0)
|
#define capturing_bugs() (0)
|
||||||
#define add_captured_bug(s) do { } while (0)
|
#define add_captured_bug(s) do { } while (0)
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/** Helper for tor_assert: report the assertion failure. */
|
/** Helper for tor_assert: report the assertion failure. */
|
||||||
void
|
void
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
* security-critical properties.
|
* security-critical properties.
|
||||||
*/
|
*/
|
||||||
#error "Sorry; we don't support building with NDEBUG."
|
#error "Sorry; we don't support building with NDEBUG."
|
||||||
#endif
|
#endif /* defined(NDEBUG) */
|
||||||
|
|
||||||
/* Sometimes we don't want to use assertions during branch coverage tests; it
|
/* Sometimes we don't want to use assertions during branch coverage tests; it
|
||||||
* leads to tons of unreached branches which in reality are only assertions we
|
* leads to tons of unreached branches which in reality are only assertions we
|
||||||
@ -70,7 +70,7 @@
|
|||||||
tor_assertion_failed_(SHORT_FILE__, __LINE__, __func__, #expr); \
|
tor_assertion_failed_(SHORT_FILE__, __LINE__, __func__, #expr); \
|
||||||
abort(); \
|
abort(); \
|
||||||
} STMT_END
|
} STMT_END
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) && defined(DISABLE_ASSERTS_IN_UNIT_TESTS) */
|
||||||
|
|
||||||
#define tor_assert_unreached() tor_assert(0)
|
#define tor_assert_unreached() tor_assert(0)
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ extern int bug_macro_deadcode_dummy__;
|
|||||||
// We use this "deadcode_dummy__" trick to prevent coverity from
|
// We use this "deadcode_dummy__" trick to prevent coverity from
|
||||||
// complaining about unreachable bug cases.
|
// complaining about unreachable bug cases.
|
||||||
#nodef BUG(x) ((x)?(__coverity_panic__(),1):(0+bug_macro_deadcode_dummy__))
|
#nodef BUG(x) ((x)?(__coverity_panic__(),1):(0+bug_macro_deadcode_dummy__))
|
||||||
#endif
|
#endif /* defined(__COVERITY__) */
|
||||||
|
|
||||||
#if defined(__COVERITY__) || defined(__clang_analyzer__)
|
#if defined(__COVERITY__) || defined(__clang_analyzer__)
|
||||||
// We're running with a static analysis tool: let's treat even nonfatal
|
// We're running with a static analysis tool: let's treat even nonfatal
|
||||||
@ -143,7 +143,7 @@ extern int bug_macro_deadcode_dummy__;
|
|||||||
(PREDICT_UNLIKELY(cond) ? \
|
(PREDICT_UNLIKELY(cond) ? \
|
||||||
(tor_bug_occurred_(SHORT_FILE__,__LINE__,__func__,"!("#cond")",0), 1) \
|
(tor_bug_occurred_(SHORT_FILE__,__LINE__,__func__,"!("#cond")",0), 1) \
|
||||||
: 0)
|
: 0)
|
||||||
#endif
|
#endif /* defined(ALL_BUGS_ARE_FATAL) || ... */
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define IF_BUG_ONCE__(cond,var) \
|
#define IF_BUG_ONCE__(cond,var) \
|
||||||
@ -156,7 +156,7 @@ extern int bug_macro_deadcode_dummy__;
|
|||||||
"!("#cond")", 1); \
|
"!("#cond")", 1); \
|
||||||
} \
|
} \
|
||||||
PREDICT_UNLIKELY(bool_result); } ))
|
PREDICT_UNLIKELY(bool_result); } ))
|
||||||
#else
|
#else /* !(defined(__GNUC__)) */
|
||||||
#define IF_BUG_ONCE__(cond,var) \
|
#define IF_BUG_ONCE__(cond,var) \
|
||||||
static int var = 0; \
|
static int var = 0; \
|
||||||
if (PREDICT_UNLIKELY(cond) ? \
|
if (PREDICT_UNLIKELY(cond) ? \
|
||||||
@ -166,7 +166,7 @@ extern int bug_macro_deadcode_dummy__;
|
|||||||
"!("#cond")", 1), \
|
"!("#cond")", 1), \
|
||||||
1)) \
|
1)) \
|
||||||
: 0)
|
: 0)
|
||||||
#endif
|
#endif /* defined(__GNUC__) */
|
||||||
#define IF_BUG_ONCE_VARNAME_(a) \
|
#define IF_BUG_ONCE_VARNAME_(a) \
|
||||||
warning_logged_on_ ## a ## __
|
warning_logged_on_ ## a ## __
|
||||||
#define IF_BUG_ONCE_VARNAME__(a) \
|
#define IF_BUG_ONCE_VARNAME__(a) \
|
||||||
@ -196,7 +196,7 @@ void tor_capture_bugs_(int n);
|
|||||||
void tor_end_capture_bugs_(void);
|
void tor_end_capture_bugs_(void);
|
||||||
const struct smartlist_t *tor_get_captured_bug_log_(void);
|
const struct smartlist_t *tor_get_captured_bug_log_(void);
|
||||||
void tor_set_failed_assertion_callback(void (*fn)(void));
|
void tor_set_failed_assertion_callback(void (*fn)(void));
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_UTIL_BUG_H) */
|
||||||
|
|
||||||
|
@ -48,5 +48,5 @@ int hex_decode_digit(char c);
|
|||||||
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen);
|
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen);
|
||||||
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen);
|
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_UTIL_FORMAT_H) */
|
||||||
|
|
||||||
|
@ -154,5 +154,5 @@ notify_pending_waitpid_callbacks(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ waitpid_callback_t *set_waitpid_callback(pid_t pid,
|
|||||||
void (*fn)(int, void *), void *arg);
|
void (*fn)(int, void *), void *arg);
|
||||||
void clear_waitpid_callback(waitpid_callback_t *ent);
|
void clear_waitpid_callback(waitpid_callback_t *ent);
|
||||||
void notify_pending_waitpid_callbacks(void);
|
void notify_pending_waitpid_callbacks(void);
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_UTIL_PROCESS_H) */
|
||||||
|
|
||||||
|
@ -59,5 +59,5 @@ replyqueue_t *replyqueue_new(uint32_t alertsocks_flags);
|
|||||||
tor_socket_t replyqueue_get_socket(replyqueue_t *rq);
|
tor_socket_t replyqueue_get_socket(replyqueue_t *rq);
|
||||||
void replyqueue_process(replyqueue_t *queue);
|
void replyqueue_process(replyqueue_t *queue);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_WORKQUEUE_H) */
|
||||||
|
|
||||||
|
@ -814,7 +814,7 @@ parse_virtual_addr_network(const char *val, sa_family_t family,
|
|||||||
ipv6?"IPv6":"");
|
ipv6?"IPv6":"");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
if (bits > max_prefix_bits) {
|
if (bits > max_prefix_bits) {
|
||||||
if (msg)
|
if (msg)
|
||||||
@ -1044,7 +1044,7 @@ addressmap_register_virtual_address(int type, char *new_address)
|
|||||||
safe_str_client(*addrp),
|
safe_str_client(*addrp),
|
||||||
safe_str_client(new_address));
|
safe_str_client(new_address));
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
return *addrp;
|
return *addrp;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ typedef struct virtual_addr_conf_t {
|
|||||||
|
|
||||||
STATIC void get_random_virtual_addr(const virtual_addr_conf_t *conf,
|
STATIC void get_random_virtual_addr(const virtual_addr_conf_t *conf,
|
||||||
tor_addr_t *addr_out);
|
tor_addr_t *addr_out);
|
||||||
#endif
|
#endif /* defined(ADDRESSMAP_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_ADDRESSMAP_H) */
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ learned_router_identity(const tor_addr_t *addr, uint16_t port,
|
|||||||
memcpy(&bridge->ed25519_identity, ed_id, sizeof(*ed_id));
|
memcpy(&bridge->ed25519_identity, ed_id, sizeof(*ed_id));
|
||||||
learned = 1;
|
learned = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
if (learned) {
|
if (learned) {
|
||||||
char *transport_info = NULL;
|
char *transport_info = NULL;
|
||||||
const char *transport_name =
|
const char *transport_name =
|
||||||
|
@ -66,5 +66,5 @@ MOCK_DECL(download_status_t *, get_bridge_dl_status_by_id,
|
|||||||
|
|
||||||
void bridges_free_all(void);
|
void bridges_free_all(void);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_BRIDGES_H) */
|
||||||
|
|
||||||
|
@ -701,7 +701,7 @@ channel_remove_from_digest_map(channel_t *chan)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
/* Pull it out of its list, wherever that list is */
|
/* Pull it out of its list, wherever that list is */
|
||||||
TOR_LIST_REMOVE(chan, next_with_same_id);
|
TOR_LIST_REMOVE(chan, next_with_same_id);
|
||||||
@ -1832,7 +1832,7 @@ cell_queue_entry_is_padding(cell_queue_entry_t *q)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new cell queue entry for a fixed-size cell
|
* Allocate a new cell queue entry for a fixed-size cell
|
||||||
|
@ -487,7 +487,7 @@ STATIC void cell_queue_entry_free(cell_queue_entry_t *q, int handed_off);
|
|||||||
|
|
||||||
void channel_write_cell_generic_(channel_t *chan, const char *cell_type,
|
void channel_write_cell_generic_(channel_t *chan, const char *cell_type,
|
||||||
void *cell, cell_queue_entry_t *q);
|
void *cell, cell_queue_entry_t *q);
|
||||||
#endif
|
#endif /* defined(CHANNEL_PRIVATE_) */
|
||||||
|
|
||||||
/* Channel operations for subclasses and internal use only */
|
/* Channel operations for subclasses and internal use only */
|
||||||
|
|
||||||
@ -580,7 +580,7 @@ void channel_do_open_actions(channel_t *chan);
|
|||||||
extern uint64_t estimated_total_queue_size;
|
extern uint64_t estimated_total_queue_size;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* defined(TOR_CHANNEL_INTERNAL_) */
|
||||||
|
|
||||||
/* Helper functions to perform operations on channels */
|
/* Helper functions to perform operations on channels */
|
||||||
|
|
||||||
@ -719,5 +719,5 @@ int packed_cell_is_destroy(channel_t *chan,
|
|||||||
/* Declare the handle helpers */
|
/* Declare the handle helpers */
|
||||||
HANDLE_DECL(channel, channel_s,)
|
HANDLE_DECL(channel, channel_s,)
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CHANNEL_H) */
|
||||||
|
|
||||||
|
@ -41,5 +41,5 @@ int channelpadding_get_circuits_available_timeout(void);
|
|||||||
unsigned int channelpadding_get_channel_idle_timeout(const channel_t *, int);
|
unsigned int channelpadding_get_channel_idle_timeout(const channel_t *, int);
|
||||||
void channelpadding_new_consensus_params(networkstatus_t *ns);
|
void channelpadding_new_consensus_params(networkstatus_t *ns);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CHANNELPADDING_H) */
|
||||||
|
|
||||||
|
@ -1044,7 +1044,7 @@ channel_tls_time_process_cell(cell_t *cell, channel_tls_t *chan, int *time,
|
|||||||
|
|
||||||
*time += time_passed;
|
*time += time_passed;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(KEEP_TIMING_STATS) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an incoming cell on a channel_tls_t
|
* Handle an incoming cell on a channel_tls_t
|
||||||
@ -1072,9 +1072,9 @@ channel_tls_handle_cell(cell_t *cell, or_connection_t *conn)
|
|||||||
channel_tls_time_process_cell(cl, cn, & tp ## time , \
|
channel_tls_time_process_cell(cl, cn, & tp ## time , \
|
||||||
channel_tls_process_ ## tp ## _cell); \
|
channel_tls_process_ ## tp ## _cell); \
|
||||||
} STMT_END
|
} STMT_END
|
||||||
#else
|
#else /* !(defined(KEEP_TIMING_STATS)) */
|
||||||
#define PROCESS_CELL(tp, cl, cn) channel_tls_process_ ## tp ## _cell(cl, cn)
|
#define PROCESS_CELL(tp, cl, cn) channel_tls_process_ ## tp ## _cell(cl, cn)
|
||||||
#endif
|
#endif /* defined(KEEP_TIMING_STATS) */
|
||||||
|
|
||||||
tor_assert(cell);
|
tor_assert(cell);
|
||||||
tor_assert(conn);
|
tor_assert(conn);
|
||||||
@ -1204,7 +1204,7 @@ channel_tls_handle_var_cell(var_cell_t *var_cell, or_connection_t *conn)
|
|||||||
/* remember which second it is, for next time */
|
/* remember which second it is, for next time */
|
||||||
current_second = now;
|
current_second = now;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(KEEP_TIMING_STATS) */
|
||||||
|
|
||||||
tor_assert(var_cell);
|
tor_assert(var_cell);
|
||||||
tor_assert(conn);
|
tor_assert(conn);
|
||||||
@ -1579,7 +1579,7 @@ channel_tls_process_versions_cell(var_cell_t *cell, channel_tls_t *chan)
|
|||||||
connection_or_close_normally(chan->conn, 1);
|
connection_or_close_normally(chan->conn, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(DISABLE_V3_LINKPROTO_SERVERSIDE) */
|
||||||
|
|
||||||
if (send_versions) {
|
if (send_versions) {
|
||||||
if (connection_or_send_versions(chan->conn, 1) < 0) {
|
if (connection_or_send_versions(chan->conn, 1) < 0) {
|
||||||
|
@ -26,7 +26,7 @@ struct channel_tls_s {
|
|||||||
or_connection_t *conn;
|
or_connection_t *conn;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TOR_CHANNEL_INTERNAL_ */
|
#endif /* defined(TOR_CHANNEL_INTERNAL_) */
|
||||||
|
|
||||||
channel_t * channel_tls_connect(const tor_addr_t *addr, uint16_t port,
|
channel_t * channel_tls_connect(const tor_addr_t *addr, uint16_t port,
|
||||||
const char *id_digest,
|
const char *id_digest,
|
||||||
@ -69,7 +69,7 @@ STATIC void channel_tls_process_auth_challenge_cell(var_cell_t *cell,
|
|||||||
STATIC void channel_tls_common_init(channel_tls_t *tlschan);
|
STATIC void channel_tls_common_init(channel_tls_t *tlschan);
|
||||||
STATIC void channel_tls_process_authenticate_cell(var_cell_t *cell,
|
STATIC void channel_tls_process_authenticate_cell(var_cell_t *cell,
|
||||||
channel_tls_t *tlschan);
|
channel_tls_t *tlschan);
|
||||||
#endif
|
#endif /* defined(CHANNELTLS_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CHANNELTLS_H) */
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ pathbias_is_new_circ_attempt(origin_circuit_t *circ)
|
|||||||
return circ->cpath &&
|
return circ->cpath &&
|
||||||
circ->cpath->next != circ->cpath &&
|
circ->cpath->next != circ->cpath &&
|
||||||
circ->cpath->next->state == CPATH_STATE_AWAITING_KEYS;
|
circ->cpath->next->state == CPATH_STATE_AWAITING_KEYS;
|
||||||
#else
|
#else /* !(defined(N2N_TAGGING_IS_POSSIBLE)) */
|
||||||
/* If tagging attacks are no longer possible, we probably want to
|
/* If tagging attacks are no longer possible, we probably want to
|
||||||
* count bias from the first hop. However, one could argue that
|
* count bias from the first hop. However, one could argue that
|
||||||
* timing-based tagging is still more useful than per-hop failure.
|
* timing-based tagging is still more useful than per-hop failure.
|
||||||
@ -300,7 +300,7 @@ pathbias_is_new_circ_attempt(origin_circuit_t *circ)
|
|||||||
*/
|
*/
|
||||||
return circ->cpath &&
|
return circ->cpath &&
|
||||||
circ->cpath->state == CPATH_STATE_AWAITING_KEYS;
|
circ->cpath->state == CPATH_STATE_AWAITING_KEYS;
|
||||||
#endif
|
#endif /* defined(N2N_TAGGING_IS_POSSIBLE) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,5 +25,5 @@ void pathbias_mark_use_success(origin_circuit_t *circ);
|
|||||||
void pathbias_mark_use_rollback(origin_circuit_t *circ);
|
void pathbias_mark_use_rollback(origin_circuit_t *circ);
|
||||||
const char *pathbias_state_to_string(path_state_t state);
|
const char *pathbias_state_to_string(path_state_t state);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CIRCPATHBIAS_H) */
|
||||||
|
|
||||||
|
@ -1566,7 +1566,7 @@ circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer, int reason)
|
|||||||
|
|
||||||
log_info(LD_CIRC, "finished");
|
log_info(LD_CIRC, "finished");
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* 0 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Given a response payload and keys, initialize, then send a created
|
/** Given a response payload and keys, initialize, then send a created
|
||||||
@ -2104,7 +2104,7 @@ pick_tor2web_rendezvous_node(router_crn_flags_t flags,
|
|||||||
|
|
||||||
return rp_node;
|
return rp_node;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(ENABLE_TOR2WEB_MODE) || defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/* Pick a Rendezvous Point for our HS circuits according to <b>flags</b>. */
|
/* Pick a Rendezvous Point for our HS circuits according to <b>flags</b>. */
|
||||||
static const node_t *
|
static const node_t *
|
||||||
@ -2140,7 +2140,7 @@ pick_rendezvous_node(router_crn_flags_t flags)
|
|||||||
"Unable to find a random rendezvous point that is reachable via "
|
"Unable to find a random rendezvous point that is reachable via "
|
||||||
"a direct connection, falling back to a 3-hop path.");
|
"a direct connection, falling back to a 3-hop path.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(ENABLE_TOR2WEB_MODE) */
|
||||||
|
|
||||||
return router_choose_random_node(NULL, options->ExcludeNodes, flags);
|
return router_choose_random_node(NULL, options->ExcludeNodes, flags);
|
||||||
}
|
}
|
||||||
@ -2430,7 +2430,7 @@ cpath_get_n_hops(crypt_path_t **head_ptr)
|
|||||||
return n_hops;
|
return n_hops;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/** A helper function used by onion_extend_cpath(). Use <b>purpose</b>
|
/** A helper function used by onion_extend_cpath(). Use <b>purpose</b>
|
||||||
* and <b>state</b> and the cpath <b>head</b> (currently populated only
|
* and <b>state</b> and the cpath <b>head</b> (currently populated only
|
||||||
|
@ -86,9 +86,9 @@ STATIC const node_t *pick_tor2web_rendezvous_node(router_crn_flags_t flags,
|
|||||||
const or_options_t *options);
|
const or_options_t *options);
|
||||||
unsigned int cpath_get_n_hops(crypt_path_t **head_ptr);
|
unsigned int cpath_get_n_hops(crypt_path_t **head_ptr);
|
||||||
|
|
||||||
#endif
|
#endif /* defined(ENABLE_TOR2WEB_MODE) || defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#endif
|
#endif /* defined(CIRCUITBUILD_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CIRCUITBUILD_H) */
|
||||||
|
|
||||||
|
@ -1434,7 +1434,7 @@ circuit_unlink_all_from_channel(channel_t *chan, int reason)
|
|||||||
smartlist_free(detached_2);
|
smartlist_free(detached_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(DEBUG_CIRCUIT_UNLINK_ALL) */
|
||||||
|
|
||||||
SMARTLIST_FOREACH_BEGIN(detached, circuit_t *, circ) {
|
SMARTLIST_FOREACH_BEGIN(detached, circuit_t *, circ) {
|
||||||
int mark = 0;
|
int mark = 0;
|
||||||
|
@ -86,7 +86,7 @@ STATIC size_t n_cells_in_circ_queues(const circuit_t *c);
|
|||||||
STATIC uint32_t circuit_max_queued_data_age(const circuit_t *c, uint32_t now);
|
STATIC uint32_t circuit_max_queued_data_age(const circuit_t *c, uint32_t now);
|
||||||
STATIC uint32_t circuit_max_queued_cell_age(const circuit_t *c, uint32_t now);
|
STATIC uint32_t circuit_max_queued_cell_age(const circuit_t *c, uint32_t now);
|
||||||
STATIC uint32_t circuit_max_queued_item_age(const circuit_t *c, uint32_t now);
|
STATIC uint32_t circuit_max_queued_item_age(const circuit_t *c, uint32_t now);
|
||||||
#endif
|
#endif /* defined(CIRCUITLIST_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CIRCUITLIST_H) */
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ struct chanid_circid_muxinfo_t {
|
|||||||
circuitmux_assert_okay(cmux)
|
circuitmux_assert_okay(cmux)
|
||||||
#else
|
#else
|
||||||
#define circuitmux_assert_okay_paranoid(cmux)
|
#define circuitmux_assert_okay_paranoid(cmux)
|
||||||
#endif
|
#endif /* defined(CMUX_PARANOIA) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Static function declarations
|
* Static function declarations
|
||||||
|
@ -156,5 +156,5 @@ void circuitmux_mark_destroyed_circids_usable(circuitmux_t *cmux,
|
|||||||
MOCK_DECL(int, circuitmux_compare_muxes,
|
MOCK_DECL(int, circuitmux_compare_muxes,
|
||||||
(circuitmux_t *cmux_1, circuitmux_t *cmux_2));
|
(circuitmux_t *cmux_1, circuitmux_t *cmux_2));
|
||||||
|
|
||||||
#endif /* TOR_CIRCUITMUX_H */
|
#endif /* !defined(TOR_CIRCUITMUX_H) */
|
||||||
|
|
||||||
|
@ -20,5 +20,5 @@ unsigned int cell_ewma_get_tick(void);
|
|||||||
void cell_ewma_set_scale_factor(const or_options_t *options,
|
void cell_ewma_set_scale_factor(const or_options_t *options,
|
||||||
const networkstatus_t *consensus);
|
const networkstatus_t *consensus);
|
||||||
|
|
||||||
#endif /* TOR_CIRCUITMUX_EWMA_H */
|
#endif /* !defined(TOR_CIRCUITMUX_EWMA_H) */
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ static circuit_build_times_t circ_times;
|
|||||||
static int unit_tests = 0;
|
static int unit_tests = 0;
|
||||||
#else
|
#else
|
||||||
#define unit_tests 0
|
#define unit_tests 0
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/** Return a pointer to the data structure describing our current circuit
|
/** Return a pointer to the data structure describing our current circuit
|
||||||
* build time history and computations. */
|
* build time history and computations. */
|
||||||
@ -148,7 +148,7 @@ circuit_build_times_disabled_(const or_options_t *options,
|
|||||||
"Consensus=%d, Config=%d, AuthDir=%d, StateFile=%d",
|
"Consensus=%d, Config=%d, AuthDir=%d, StateFile=%d",
|
||||||
consensus_disabled, config_disabled, dirauth_disabled,
|
consensus_disabled, config_disabled, dirauth_disabled,
|
||||||
state_disabled);
|
state_disabled);
|
||||||
#endif
|
#endif /* 0 */
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
#if 0
|
#if 0
|
||||||
@ -157,7 +157,7 @@ circuit_build_times_disabled_(const or_options_t *options,
|
|||||||
"Consensus=%d, Config=%d, AuthDir=%d, StateFile=%d",
|
"Consensus=%d, Config=%d, AuthDir=%d, StateFile=%d",
|
||||||
consensus_disabled, config_disabled, dirauth_disabled,
|
consensus_disabled, config_disabled, dirauth_disabled,
|
||||||
state_disabled);
|
state_disabled);
|
||||||
#endif
|
#endif /* 0 */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -608,7 +608,7 @@ circuit_build_times_rewind_history(circuit_build_times_t *cbt, int n)
|
|||||||
"Rewound history by %d places. Current index: %d. "
|
"Rewound history by %d places. Current index: %d. "
|
||||||
"Total: %d", n, cbt->build_times_idx, cbt->total_build_times);
|
"Total: %d", n, cbt->build_times_idx, cbt->total_build_times);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new build time value <b>time</b> to the set of build times. Time
|
* Add a new build time value <b>time</b> to the set of build times. Time
|
||||||
@ -676,7 +676,7 @@ circuit_build_times_min(circuit_build_times_t *cbt)
|
|||||||
}
|
}
|
||||||
return min_build_time;
|
return min_build_time;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate and return a histogram for the set of build times.
|
* Calculate and return a histogram for the set of build times.
|
||||||
@ -1165,7 +1165,7 @@ circuit_build_times_cdf(circuit_build_times_t *cbt, double x)
|
|||||||
tor_assert(0 <= ret && ret <= 1.0);
|
tor_assert(0 <= ret && ret <= 1.0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#ifdef TOR_UNIT_TESTS
|
#ifdef TOR_UNIT_TESTS
|
||||||
/**
|
/**
|
||||||
@ -1200,7 +1200,7 @@ circuit_build_times_generate_sample(circuit_build_times_t *cbt,
|
|||||||
tor_assert(ret > 0);
|
tor_assert(ret > 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#ifdef TOR_UNIT_TESTS
|
#ifdef TOR_UNIT_TESTS
|
||||||
/**
|
/**
|
||||||
@ -1223,7 +1223,7 @@ circuit_build_times_initial_alpha(circuit_build_times_t *cbt,
|
|||||||
(tor_mathlog(cbt->Xm)-tor_mathlog(timeout_ms));
|
(tor_mathlog(cbt->Xm)-tor_mathlog(timeout_ms));
|
||||||
tor_assert(cbt->alpha > 0);
|
tor_assert(cbt->alpha > 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if we need circuits to be built
|
* Returns true if we need circuits to be built
|
||||||
@ -1682,7 +1682,7 @@ circuitbuild_running_unit_tests(void)
|
|||||||
{
|
{
|
||||||
unit_tests = 1;
|
unit_tests = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
void
|
void
|
||||||
circuit_build_times_update_last_circ(circuit_build_times_t *cbt)
|
circuit_build_times_update_last_circ(circuit_build_times_t *cbt)
|
||||||
|
@ -54,7 +54,7 @@ STATIC void circuit_build_times_reset(circuit_build_times_t *cbt);
|
|||||||
/* Network liveness functions */
|
/* Network liveness functions */
|
||||||
STATIC int circuit_build_times_network_check_changed(
|
STATIC int circuit_build_times_network_check_changed(
|
||||||
circuit_build_times_t *cbt);
|
circuit_build_times_t *cbt);
|
||||||
#endif
|
#endif /* defined(CIRCUITSTATS_PRIVATE) */
|
||||||
|
|
||||||
#ifdef TOR_UNIT_TESTS
|
#ifdef TOR_UNIT_TESTS
|
||||||
build_time_t circuit_build_times_generate_sample(circuit_build_times_t *cbt,
|
build_time_t circuit_build_times_generate_sample(circuit_build_times_t *cbt,
|
||||||
@ -63,7 +63,7 @@ double circuit_build_times_cdf(circuit_build_times_t *cbt, double x);
|
|||||||
void circuit_build_times_initial_alpha(circuit_build_times_t *cbt,
|
void circuit_build_times_initial_alpha(circuit_build_times_t *cbt,
|
||||||
double quantile, double time_ms);
|
double quantile, double time_ms);
|
||||||
void circuitbuild_running_unit_tests(void);
|
void circuitbuild_running_unit_tests(void);
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
/* Network liveness functions */
|
/* Network liveness functions */
|
||||||
void circuit_build_times_network_is_live(circuit_build_times_t *cbt);
|
void circuit_build_times_network_is_live(circuit_build_times_t *cbt);
|
||||||
@ -95,7 +95,7 @@ struct circuit_build_times_s {
|
|||||||
/** How long we wait before actually closing the circuit. */
|
/** How long we wait before actually closing the circuit. */
|
||||||
double close_ms;
|
double close_ms;
|
||||||
};
|
};
|
||||||
#endif
|
#endif /* defined(CIRCUITSTATS_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CIRCUITSTATS_H) */
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ circuit_conforms_to_options(const origin_circuit_t *circ,
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
/** Close all circuits that start at us, aren't open, and were born
|
/** Close all circuits that start at us, aren't open, and were born
|
||||||
* at least CircuitBuildTimeout seconds ago.
|
* at least CircuitBuildTimeout seconds ago.
|
||||||
@ -634,7 +634,7 @@ circuit_expire_building(void)
|
|||||||
victim->n_circ_id,
|
victim->n_circ_id,
|
||||||
(int)(now - victim->timestamp_dirty));
|
(int)(now - victim->timestamp_dirty));
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
|
|
||||||
/* if circ is !open, or if it's open but purpose is a non-finished
|
/* if circ is !open, or if it's open but purpose is a non-finished
|
||||||
* intro or rend, then mark it for close */
|
* intro or rend, then mark it for close */
|
||||||
@ -1339,7 +1339,7 @@ circuit_expire_old_circs_as_needed(time_t now)
|
|||||||
log_fn(LOG_INFO,"Creating a new testing circuit.");
|
log_fn(LOG_INFO,"Creating a new testing circuit.");
|
||||||
circuit_launch(CIRCUIT_PURPOSE_C_GENERAL, 0);
|
circuit_launch(CIRCUIT_PURPOSE_C_GENERAL, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 0 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2282,7 +2282,7 @@ circuit_get_open_circ_or_launch(entry_connection_t *conn,
|
|||||||
new_circ_purpose == CIRCUIT_PURPOSE_C_INTRODUCING)) {
|
new_circ_purpose == CIRCUIT_PURPOSE_C_INTRODUCING)) {
|
||||||
want_onehop = 1;
|
want_onehop = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(ENABLE_TOR2WEB_MODE) */
|
||||||
|
|
||||||
/* Determine what kind of a circuit to launch, and actually launch it. */
|
/* Determine what kind of a circuit to launch, and actually launch it. */
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ STATIC int needs_hs_client_circuits(time_t now,
|
|||||||
|
|
||||||
STATIC int needs_circuits_for_build(int num);
|
STATIC int needs_circuits_for_build(int num);
|
||||||
|
|
||||||
#endif
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CIRCUITUSE_H) */
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ command_time_process_cell(cell_t *cell, channel_t *chan, int *time,
|
|||||||
}
|
}
|
||||||
*time += time_passed;
|
*time += time_passed;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(KEEP_TIMING_STATS) */
|
||||||
|
|
||||||
/** Process a <b>cell</b> that was just received on <b>chan</b>. Keep internal
|
/** Process a <b>cell</b> that was just received on <b>chan</b>. Keep internal
|
||||||
* statistics about how many of each cell we've processed so far
|
* statistics about how many of each cell we've processed so far
|
||||||
@ -165,7 +165,7 @@ command_process_cell(channel_t *chan, cell_t *cell)
|
|||||||
/* remember which second it is, for next time */
|
/* remember which second it is, for next time */
|
||||||
current_second = now;
|
current_second = now;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(KEEP_TIMING_STATS) */
|
||||||
|
|
||||||
#ifdef KEEP_TIMING_STATS
|
#ifdef KEEP_TIMING_STATS
|
||||||
#define PROCESS_CELL(tp, cl, cn) STMT_BEGIN { \
|
#define PROCESS_CELL(tp, cl, cn) STMT_BEGIN { \
|
||||||
@ -173,9 +173,9 @@ command_process_cell(channel_t *chan, cell_t *cell)
|
|||||||
command_time_process_cell(cl, cn, & tp ## time , \
|
command_time_process_cell(cl, cn, & tp ## time , \
|
||||||
command_process_ ## tp ## _cell); \
|
command_process_ ## tp ## _cell); \
|
||||||
} STMT_END
|
} STMT_END
|
||||||
#else
|
#else /* !(defined(KEEP_TIMING_STATS)) */
|
||||||
#define PROCESS_CELL(tp, cl, cn) command_process_ ## tp ## _cell(cl, cn)
|
#define PROCESS_CELL(tp, cl, cn) command_process_ ## tp ## _cell(cl, cn)
|
||||||
#endif
|
#endif /* defined(KEEP_TIMING_STATS) */
|
||||||
|
|
||||||
switch (cell->command) {
|
switch (cell->command) {
|
||||||
case CELL_CREATE:
|
case CELL_CREATE:
|
||||||
|
@ -27,5 +27,5 @@ extern uint64_t stats_n_created_cells_processed;
|
|||||||
extern uint64_t stats_n_relay_cells_processed;
|
extern uint64_t stats_n_relay_cells_processed;
|
||||||
extern uint64_t stats_n_destroy_cells_processed;
|
extern uint64_t stats_n_destroy_cells_processed;
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_COMMAND_H) */
|
||||||
|
|
||||||
|
@ -114,9 +114,9 @@
|
|||||||
* Coverity. Here's a kludge to unconfuse it.
|
* Coverity. Here's a kludge to unconfuse it.
|
||||||
*/
|
*/
|
||||||
# define __INCLUDE_LEVEL__ 2
|
# define __INCLUDE_LEVEL__ 2
|
||||||
# endif
|
#endif /* defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__) */
|
||||||
#include <systemd/sd-daemon.h>
|
#include <systemd/sd-daemon.h>
|
||||||
#endif
|
#endif /* defined(HAVE_SYSTEMD) */
|
||||||
|
|
||||||
/* Prefix used to indicate a Unix socket in a FooPort configuration. */
|
/* Prefix used to indicate a Unix socket in a FooPort configuration. */
|
||||||
static const char unix_socket_prefix[] = "unix:";
|
static const char unix_socket_prefix[] = "unix:";
|
||||||
@ -345,7 +345,7 @@ static config_var_t option_vars_[] = {
|
|||||||
SHARE_DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "geoip"),
|
SHARE_DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "geoip"),
|
||||||
V(GeoIPv6File, FILENAME,
|
V(GeoIPv6File, FILENAME,
|
||||||
SHARE_DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "geoip6"),
|
SHARE_DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "geoip6"),
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
OBSOLETE("Group"),
|
OBSOLETE("Group"),
|
||||||
V(GuardLifetime, INTERVAL, "0 minutes"),
|
V(GuardLifetime, INTERVAL, "0 minutes"),
|
||||||
V(HardwareAccel, BOOL, "0"),
|
V(HardwareAccel, BOOL, "0"),
|
||||||
@ -1250,13 +1250,13 @@ options_act_reversible(const or_options_t *old_options, char **msg)
|
|||||||
"on this OS/with this build.");
|
"on this OS/with this build.");
|
||||||
goto rollback;
|
goto rollback;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(!defined(HAVE_SYS_UN_H)) */
|
||||||
if (options->ControlSocketsGroupWritable && !options->ControlSocket) {
|
if (options->ControlSocketsGroupWritable && !options->ControlSocket) {
|
||||||
*msg = tor_strdup("Setting ControlSocketGroupWritable without setting"
|
*msg = tor_strdup("Setting ControlSocketGroupWritable without setting"
|
||||||
"a ControlSocket makes no sense.");
|
"a ControlSocket makes no sense.");
|
||||||
goto rollback;
|
goto rollback;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(HAVE_SYS_UN_H) */
|
||||||
|
|
||||||
if (running_tor) {
|
if (running_tor) {
|
||||||
int n_ports=0;
|
int n_ports=0;
|
||||||
@ -1333,7 +1333,7 @@ options_act_reversible(const or_options_t *old_options, char **msg)
|
|||||||
goto rollback;
|
goto rollback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H) */
|
||||||
|
|
||||||
/* Attempt to lock all current and future memory with mlockall() only once */
|
/* Attempt to lock all current and future memory with mlockall() only once */
|
||||||
if (options->DisableAllSwap) {
|
if (options->DisableAllSwap) {
|
||||||
@ -1385,7 +1385,7 @@ options_act_reversible(const or_options_t *old_options, char **msg)
|
|||||||
options->DataDirectory, strerror(errno));
|
options->DataDirectory, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
/* Bail out at this point if we're not going to be a client or server:
|
/* Bail out at this point if we're not going to be a client or server:
|
||||||
* we don't run Tor itself. */
|
* we don't run Tor itself. */
|
||||||
@ -1667,7 +1667,7 @@ options_act(const or_options_t *old_options)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* LCOV_EXCL_STOP */
|
/* LCOV_EXCL_STOP */
|
||||||
#else
|
#else /* !(defined(ENABLE_TOR2WEB_MODE)) */
|
||||||
if (options->Tor2webMode) {
|
if (options->Tor2webMode) {
|
||||||
log_err(LD_CONFIG, "This copy of Tor was not compiled to run in "
|
log_err(LD_CONFIG, "This copy of Tor was not compiled to run in "
|
||||||
"'tor2web mode'. It cannot be run with the Tor2webMode torrc "
|
"'tor2web mode'. It cannot be run with the Tor2webMode torrc "
|
||||||
@ -1675,7 +1675,7 @@ options_act(const or_options_t *old_options)
|
|||||||
"--enable-tor2web-mode option.");
|
"--enable-tor2web-mode option.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(ENABLE_TOR2WEB_MODE) */
|
||||||
|
|
||||||
/* If we are a bridge with a pluggable transport proxy but no
|
/* If we are a bridge with a pluggable transport proxy but no
|
||||||
Extended ORPort, inform the user that they are missing out. */
|
Extended ORPort, inform the user that they are missing out. */
|
||||||
@ -2868,7 +2868,7 @@ options_validate_cb(void *old_options, void *options, void *default_options,
|
|||||||
#else
|
#else
|
||||||
#define COMPLAIN(args, ...) \
|
#define COMPLAIN(args, ...) \
|
||||||
STMT_BEGIN log_warn(LD_CONFIG, args, ##__VA_ARGS__); STMT_END
|
STMT_BEGIN log_warn(LD_CONFIG, args, ##__VA_ARGS__); STMT_END
|
||||||
#endif
|
#endif /* defined(__GNUC__) && __GNUC__ <= 3 */
|
||||||
|
|
||||||
/** Log a warning message iff <b>filepath</b> is not absolute.
|
/** Log a warning message iff <b>filepath</b> is not absolute.
|
||||||
* Warning message must contain option name <b>option</b> and
|
* Warning message must contain option name <b>option</b> and
|
||||||
@ -3171,7 +3171,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
"and OS X/Darwin-specific feature.");
|
"and OS X/Darwin-specific feature.");
|
||||||
#else
|
#else
|
||||||
options->TransProxyType_parsed = TPT_PF_DIVERT;
|
options->TransProxyType_parsed = TPT_PF_DIVERT;
|
||||||
#endif
|
#endif /* !defined(OpenBSD) && !defined( DARWIN ) */
|
||||||
} else if (!strcasecmp(options->TransProxyType, "tproxy")) {
|
} else if (!strcasecmp(options->TransProxyType, "tproxy")) {
|
||||||
#if !defined(__linux__)
|
#if !defined(__linux__)
|
||||||
REJECT("TPROXY is a Linux-specific feature.");
|
REJECT("TPROXY is a Linux-specific feature.");
|
||||||
@ -3185,7 +3185,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
"and OS X/Darwin-specific feature.");
|
"and OS X/Darwin-specific feature.");
|
||||||
#else
|
#else
|
||||||
options->TransProxyType_parsed = TPT_IPFW;
|
options->TransProxyType_parsed = TPT_IPFW;
|
||||||
#endif
|
#endif /* !defined(KERNEL_MAY_SUPPORT_IPFW) */
|
||||||
} else {
|
} else {
|
||||||
REJECT("Unrecognized value for TransProxyType");
|
REJECT("Unrecognized value for TransProxyType");
|
||||||
}
|
}
|
||||||
@ -3195,10 +3195,10 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
REJECT("Cannot use TransProxyType without any valid TransPort.");
|
REJECT("Cannot use TransProxyType without any valid TransPort.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(USE_TRANSPARENT)) */
|
||||||
if (options->TransPort_set)
|
if (options->TransPort_set)
|
||||||
REJECT("TransPort is disabled in this build.");
|
REJECT("TransPort is disabled in this build.");
|
||||||
#endif
|
#endif /* defined(USE_TRANSPARENT) */
|
||||||
|
|
||||||
if (options->TokenBucketRefillInterval <= 0
|
if (options->TokenBucketRefillInterval <= 0
|
||||||
|| options->TokenBucketRefillInterval > 1000) {
|
|| options->TokenBucketRefillInterval > 1000) {
|
||||||
@ -3519,7 +3519,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
"Tor2WebMode is enabled; disabling UseEntryGuards.");
|
"Tor2WebMode is enabled; disabling UseEntryGuards.");
|
||||||
options->UseEntryGuards = 0;
|
options->UseEntryGuards = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(ENABLE_TOR2WEB_MODE) */
|
||||||
|
|
||||||
if (options->Tor2webRendezvousPoints && !options->Tor2webMode) {
|
if (options->Tor2webRendezvousPoints && !options->Tor2webMode) {
|
||||||
REJECT("Tor2webRendezvousPoints cannot be set without Tor2webMode.");
|
REJECT("Tor2webRendezvousPoints cannot be set without Tor2webMode.");
|
||||||
@ -4367,7 +4367,7 @@ compute_real_max_mem_in_queues(const uint64_t val, int log_guess)
|
|||||||
#else
|
#else
|
||||||
/* (presumably) 32-bit system. Let's hope for 1 GB. */
|
/* (presumably) 32-bit system. Let's hope for 1 GB. */
|
||||||
result = ONE_GIGABYTE;
|
result = ONE_GIGABYTE;
|
||||||
#endif
|
#endif /* SIZEOF_VOID_P >= 8 */
|
||||||
} else {
|
} else {
|
||||||
/* We detected it, so let's pick 3/4 of the total RAM as our limit. */
|
/* We detected it, so let's pick 3/4 of the total RAM as our limit. */
|
||||||
const uint64_t avail = (ram / 4) * 3;
|
const uint64_t avail = (ram / 4) * 3;
|
||||||
@ -4700,7 +4700,7 @@ get_windows_conf_root(void)
|
|||||||
path[sizeof(path)-1] = '\0';
|
path[sizeof(path)-1] = '\0';
|
||||||
#else
|
#else
|
||||||
strlcpy(path,tpath,sizeof(path));
|
strlcpy(path,tpath,sizeof(path));
|
||||||
#endif
|
#endif /* defined(UNICODE) */
|
||||||
|
|
||||||
/* Now we need to free the memory that the path-idl was stored in. In
|
/* Now we need to free the memory that the path-idl was stored in. In
|
||||||
* typical Windows fashion, we can't just call 'free()' on it. */
|
* typical Windows fashion, we can't just call 'free()' on it. */
|
||||||
@ -4716,7 +4716,7 @@ get_windows_conf_root(void)
|
|||||||
is_set = 1;
|
is_set = 1;
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/** Return the default location for our torrc file (if <b>defaults_file</b> is
|
/** Return the default location for our torrc file (if <b>defaults_file</b> is
|
||||||
* false), or for the torrc-defaults file (if <b>defaults_file</b> is true). */
|
* false), or for the torrc-defaults file (if <b>defaults_file</b> is true). */
|
||||||
@ -4740,7 +4740,7 @@ get_default_conf_file(int defaults_file)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return defaults_file ? CONFDIR "/torrc-defaults" : CONFDIR "/torrc";
|
return defaults_file ? CONFDIR "/torrc-defaults" : CONFDIR "/torrc";
|
||||||
#endif
|
#endif /* defined(DISABLE_SYSTEM_TORRC) || ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Verify whether lst is a list of strings containing valid-looking
|
/** Verify whether lst is a list of strings containing valid-looking
|
||||||
@ -4891,9 +4891,9 @@ find_torrc_filename(config_line_t *cmd_arg,
|
|||||||
} else {
|
} else {
|
||||||
fname = dflt ? tor_strdup(dflt) : NULL;
|
fname = dflt ? tor_strdup(dflt) : NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(!defined(_WIN32)) */
|
||||||
fname = dflt ? tor_strdup(dflt) : NULL;
|
fname = dflt ? tor_strdup(dflt) : NULL;
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fname;
|
return fname;
|
||||||
@ -5524,7 +5524,7 @@ options_init_logs(const or_options_t *old_options, or_options_t *options,
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
log_warn(LD_CONFIG, "Syslog is not supported on this system. Sorry.");
|
log_warn(LD_CONFIG, "Syslog is not supported on this system. Sorry.");
|
||||||
#endif
|
#endif /* defined(HAVE_SYSLOG_H) */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6735,7 +6735,7 @@ parse_port_config(smartlist_t *out,
|
|||||||
} else if (!strcasecmp(elt, "AllAddrs")) {
|
} else if (!strcasecmp(elt, "AllAddrs")) {
|
||||||
|
|
||||||
all_addrs = 1;
|
all_addrs = 1;
|
||||||
#endif
|
#endif /* 0 */
|
||||||
} else if (!strcasecmp(elt, "IPv4Only")) {
|
} else if (!strcasecmp(elt, "IPv4Only")) {
|
||||||
bind_ipv4_only = 1;
|
bind_ipv4_only = 1;
|
||||||
} else if (!strcasecmp(elt, "IPv6Only")) {
|
} else if (!strcasecmp(elt, "IPv6Only")) {
|
||||||
@ -7518,7 +7518,7 @@ normalize_data_directory(or_options_t *options)
|
|||||||
strlcpy(p,get_windows_conf_root(),MAX_PATH);
|
strlcpy(p,get_windows_conf_root(),MAX_PATH);
|
||||||
options->DataDirectory = p;
|
options->DataDirectory = p;
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
const char *d = options->DataDirectory;
|
const char *d = options->DataDirectory;
|
||||||
if (!d)
|
if (!d)
|
||||||
d = "~/.tor";
|
d = "~/.tor";
|
||||||
@ -7544,7 +7544,7 @@ normalize_data_directory(or_options_t *options)
|
|||||||
options->DataDirectory = fn;
|
options->DataDirectory = fn;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check and normalize the value of options->DataDirectory; return 0 if it
|
/** Check and normalize the value of options->DataDirectory; return 0 if it
|
||||||
@ -8075,10 +8075,10 @@ config_load_geoip_file_(sa_family_t family,
|
|||||||
}
|
}
|
||||||
geoip_load_file(family, fname);
|
geoip_load_file(family, fname);
|
||||||
tor_free(free_fname);
|
tor_free(free_fname);
|
||||||
#else
|
#else /* !(defined(_WIN32)) */
|
||||||
(void)default_fname;
|
(void)default_fname;
|
||||||
geoip_load_file(family, fname);
|
geoip_load_file(family, fname);
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Load geoip files for IPv4 and IPv6 if <a>options</a> and
|
/** Load geoip files for IPv4 and IPv6 if <a>options</a> and
|
||||||
@ -8153,9 +8153,9 @@ init_cookie_authentication(const char *fname, const char *header,
|
|||||||
log_warn(LD_FS,"Unable to make %s group-readable.", escaped(fname));
|
log_warn(LD_FS,"Unable to make %s group-readable.", escaped(fname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(!defined(_WIN32)) */
|
||||||
(void) group_readable;
|
(void) group_readable;
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
/* Success! */
|
/* Success! */
|
||||||
log_info(LD_GENERAL, "Generated auth cookie file in '%s'.", escaped(fname));
|
log_info(LD_GENERAL, "Generated auth cookie file in '%s'.", escaped(fname));
|
||||||
|
@ -202,7 +202,7 @@ STATIC int parse_port_config(smartlist_t *out,
|
|||||||
const char *defaultaddr,
|
const char *defaultaddr,
|
||||||
int defaultport,
|
int defaultport,
|
||||||
const unsigned flags);
|
const unsigned flags);
|
||||||
#endif
|
#endif /* defined(CONFIG_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CONFIG_H) */
|
||||||
|
|
||||||
|
@ -129,5 +129,5 @@ const char *config_expand_abbrev(const config_format_t *fmt,
|
|||||||
int command_line, int warn_obsolete);
|
int command_line, int warn_obsolete);
|
||||||
void warn_deprecated_option(const char *what, const char *why);
|
void warn_deprecated_option(const char *what, const char *why);
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CONFPARSE_H) */
|
||||||
|
|
||||||
|
@ -704,7 +704,7 @@ connection_free,(connection_t *conn))
|
|||||||
connection_ap_warn_and_unmark_if_pending_circ(TO_ENTRY_CONN(conn),
|
connection_ap_warn_and_unmark_if_pending_circ(TO_ENTRY_CONN(conn),
|
||||||
"connection_free");
|
"connection_free");
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 1 */
|
||||||
connection_unregister_events(conn);
|
connection_unregister_events(conn);
|
||||||
connection_free_(conn);
|
connection_free_(conn);
|
||||||
}
|
}
|
||||||
@ -928,7 +928,7 @@ create_unix_sockaddr(const char *listenaddress, char **readable_address,
|
|||||||
*len_out = sizeof(struct sockaddr_un);
|
*len_out = sizeof(struct sockaddr_un);
|
||||||
return sockaddr;
|
return sockaddr;
|
||||||
}
|
}
|
||||||
#else
|
#else /* !(defined(HAVE_SYS_UN_H) || defined(RUNNING_DOXYGEN)) */
|
||||||
static struct sockaddr *
|
static struct sockaddr *
|
||||||
create_unix_sockaddr(const char *listenaddress, char **readable_address,
|
create_unix_sockaddr(const char *listenaddress, char **readable_address,
|
||||||
socklen_t *len_out)
|
socklen_t *len_out)
|
||||||
@ -941,7 +941,7 @@ create_unix_sockaddr(const char *listenaddress, char **readable_address,
|
|||||||
tor_fragile_assert();
|
tor_fragile_assert();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_SYS_UN_H */
|
#endif /* defined(HAVE_SYS_UN_H) || defined(RUNNING_DOXYGEN) */
|
||||||
|
|
||||||
/** Warn that an accept or a connect has failed because we're running out of
|
/** Warn that an accept or a connect has failed because we're running out of
|
||||||
* TCP sockets we can use on current system. Rate-limit these warnings so
|
* TCP sockets we can use on current system. Rate-limit these warnings so
|
||||||
@ -1056,7 +1056,7 @@ check_location_for_unix_socket(const or_options_t *options, const char *path,
|
|||||||
tor_free(p);
|
tor_free(p);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_SYS_UN_H) */
|
||||||
|
|
||||||
/** Tell the TCP stack that it shouldn't wait for a long time after
|
/** Tell the TCP stack that it shouldn't wait for a long time after
|
||||||
* <b>sock</b> has closed before reusing its port. Return 0 on success,
|
* <b>sock</b> has closed before reusing its port. Return 0 on success,
|
||||||
@ -1079,7 +1079,7 @@ make_socket_reuseable(tor_socket_t sock)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -1100,12 +1100,12 @@ make_win32_socket_exclusive(tor_socket_t sock)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else /* !(defined(SO_EXCLUSIVEADDRUSE)) */
|
||||||
(void) sock;
|
(void) sock;
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif /* defined(SO_EXCLUSIVEADDRUSE) */
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
/** Max backlog to pass to listen. We start at */
|
/** Max backlog to pass to listen. We start at */
|
||||||
static int listen_limit = INT_MAX;
|
static int listen_limit = INT_MAX;
|
||||||
@ -1195,7 +1195,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
|
|||||||
conn_type_to_string(type),
|
conn_type_to_string(type),
|
||||||
tor_socket_strerror(errno));
|
tor_socket_strerror(errno));
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(_WIN32) */
|
||||||
|
|
||||||
#if defined(USE_TRANSPARENT) && defined(IP_TRANSPARENT)
|
#if defined(USE_TRANSPARENT) && defined(IP_TRANSPARENT)
|
||||||
if (options->TransProxyType_parsed == TPT_TPROXY &&
|
if (options->TransProxyType_parsed == TPT_TPROXY &&
|
||||||
@ -1212,7 +1212,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
|
|||||||
tor_socket_strerror(e), extra);
|
tor_socket_strerror(e), extra);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(USE_TRANSPARENT) && defined(IP_TRANSPARENT) */
|
||||||
|
|
||||||
#ifdef IPV6_V6ONLY
|
#ifdef IPV6_V6ONLY
|
||||||
if (listensockaddr->sa_family == AF_INET6) {
|
if (listensockaddr->sa_family == AF_INET6) {
|
||||||
@ -1227,7 +1227,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
|
|||||||
/* Keep going; probably not harmful. */
|
/* Keep going; probably not harmful. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(IPV6_V6ONLY) */
|
||||||
|
|
||||||
if (bind(s,listensockaddr,socklen) < 0) {
|
if (bind(s,listensockaddr,socklen) < 0) {
|
||||||
const char *helpfulhint = "";
|
const char *helpfulhint = "";
|
||||||
@ -1330,7 +1330,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(HAVE_PWD_H) */
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned mode;
|
unsigned mode;
|
||||||
@ -1361,7 +1361,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
|
|||||||
tor_socket_strerror(tor_socket_errno(s)));
|
tor_socket_strerror(tor_socket_errno(s)));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_SYS_UN_H */
|
#endif /* defined(HAVE_SYS_UN_H) */
|
||||||
} else {
|
} else {
|
||||||
log_err(LD_BUG, "Got unexpected address family %d.",
|
log_err(LD_BUG, "Got unexpected address family %d.",
|
||||||
listensockaddr->sa_family);
|
listensockaddr->sa_family);
|
||||||
@ -2626,7 +2626,7 @@ retry_listener_ports(smartlist_t *old_conns,
|
|||||||
if (port->is_unix_addr && !geteuid() && (options->User) &&
|
if (port->is_unix_addr && !geteuid() && (options->User) &&
|
||||||
strcmp(options->User, "root"))
|
strcmp(options->User, "root"))
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif /* !defined(_WIN32) */
|
||||||
|
|
||||||
if (port->is_unix_addr) {
|
if (port->is_unix_addr) {
|
||||||
listensockaddr = (struct sockaddr *)
|
listensockaddr = (struct sockaddr *)
|
||||||
|
@ -286,7 +286,7 @@ MOCK_DECL(STATIC int,connection_connect_sockaddr,
|
|||||||
MOCK_DECL(STATIC void, kill_conn_list_for_oos, (smartlist_t *conns));
|
MOCK_DECL(STATIC void, kill_conn_list_for_oos, (smartlist_t *conns));
|
||||||
MOCK_DECL(STATIC smartlist_t *, pick_oos_victims, (int n));
|
MOCK_DECL(STATIC smartlist_t *, pick_oos_victims, (int n));
|
||||||
|
|
||||||
#endif
|
#endif /* defined(CONNECTION_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CONNECTION_H) */
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@
|
|||||||
#define TRANS_NETFILTER
|
#define TRANS_NETFILTER
|
||||||
#define TRANS_NETFILTER_IPV6
|
#define TRANS_NETFILTER_IPV6
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* defined(HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H) */
|
||||||
|
|
||||||
#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
|
#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_PFVAR_H)
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
@ -661,7 +661,7 @@ connection_ap_about_to_close(entry_connection_t *entry_conn)
|
|||||||
connection_ap_warn_and_unmark_if_pending_circ(entry_conn,
|
connection_ap_warn_and_unmark_if_pending_circ(entry_conn,
|
||||||
"about_to_close");
|
"about_to_close");
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* 1 */
|
||||||
|
|
||||||
control_event_stream_bandwidth(edge_conn);
|
control_event_stream_bandwidth(edge_conn);
|
||||||
control_event_stream_status(entry_conn, STREAM_EVENT_CLOSED,
|
control_event_stream_status(entry_conn, STREAM_EVENT_CLOSED,
|
||||||
@ -871,9 +871,9 @@ connection_ap_rescan_and_attach_pending(void)
|
|||||||
entry_conn->marked_pending_circ_line = 0; \
|
entry_conn->marked_pending_circ_line = 0; \
|
||||||
entry_conn->marked_pending_circ_file = 0; \
|
entry_conn->marked_pending_circ_file = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else /* !(defined(DEBUGGING_17659)) */
|
||||||
#define UNMARK() do { } while (0)
|
#define UNMARK() do { } while (0)
|
||||||
#endif
|
#endif /* defined(DEBUGGING_17659) */
|
||||||
|
|
||||||
/** Tell any AP streams that are listed as waiting for a new circuit to try
|
/** Tell any AP streams that are listed as waiting for a new circuit to try
|
||||||
* again. If there is an available circuit for a stream, attach it. Otherwise,
|
* again. If there is an available circuit for a stream, attach it. Otherwise,
|
||||||
@ -979,7 +979,7 @@ connection_ap_mark_as_pending_circuit_(entry_connection_t *entry_conn,
|
|||||||
log_warn(LD_BUG, "(Previously called from %s:%d.)\n",
|
log_warn(LD_BUG, "(Previously called from %s:%d.)\n",
|
||||||
f2 ? f2 : "<NULL>",
|
f2 ? f2 : "<NULL>",
|
||||||
entry_conn->marked_pending_circ_line);
|
entry_conn->marked_pending_circ_line);
|
||||||
#endif
|
#endif /* defined(DEBUGGING_17659) */
|
||||||
log_backtrace(LOG_WARN, LD_BUG, "To debug, this may help");
|
log_backtrace(LOG_WARN, LD_BUG, "To debug, this may help");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1791,7 +1791,7 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
|
|||||||
connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
|
connection_mark_unattached_ap(conn, END_STREAM_REASON_ENTRYPOLICY);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(ENABLE_TOR2WEB_MODE) */
|
||||||
|
|
||||||
/* socks->address is a non-onion hostname or IP address.
|
/* socks->address is a non-onion hostname or IP address.
|
||||||
* If we can't do any non-onion requests, refuse the connection.
|
* If we can't do any non-onion requests, refuse the connection.
|
||||||
@ -2067,7 +2067,7 @@ get_pf_socket(void)
|
|||||||
#else
|
#else
|
||||||
/* works on NetBSD and FreeBSD */
|
/* works on NetBSD and FreeBSD */
|
||||||
pf = tor_open_cloexec("/dev/pf", O_RDWR, 0);
|
pf = tor_open_cloexec("/dev/pf", O_RDWR, 0);
|
||||||
#endif
|
#endif /* defined(OpenBSD) */
|
||||||
|
|
||||||
if (pf < 0) {
|
if (pf < 0) {
|
||||||
log_warn(LD_NET, "open(\"/dev/pf\") failed: %s", strerror(errno));
|
log_warn(LD_NET, "open(\"/dev/pf\") failed: %s", strerror(errno));
|
||||||
@ -2077,7 +2077,7 @@ get_pf_socket(void)
|
|||||||
pf_socket = pf;
|
pf_socket = pf;
|
||||||
return pf_socket;
|
return pf_socket;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TRANS_PF) */
|
||||||
|
|
||||||
#if defined(TRANS_NETFILTER) || defined(TRANS_PF) || \
|
#if defined(TRANS_NETFILTER) || defined(TRANS_PF) || \
|
||||||
defined(TRANS_TPROXY)
|
defined(TRANS_TPROXY)
|
||||||
@ -2100,7 +2100,7 @@ destination_from_socket(entry_connection_t *conn, socks_request_t *req)
|
|||||||
}
|
}
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TRANS_TPROXY) */
|
||||||
|
|
||||||
#ifdef TRANS_NETFILTER
|
#ifdef TRANS_NETFILTER
|
||||||
int rv = -1;
|
int rv = -1;
|
||||||
@ -2110,13 +2110,13 @@ destination_from_socket(entry_connection_t *conn, socks_request_t *req)
|
|||||||
rv = getsockopt(ENTRY_TO_CONN(conn)->s, SOL_IP, SO_ORIGINAL_DST,
|
rv = getsockopt(ENTRY_TO_CONN(conn)->s, SOL_IP, SO_ORIGINAL_DST,
|
||||||
(struct sockaddr*)&orig_dst, &orig_dst_len);
|
(struct sockaddr*)&orig_dst, &orig_dst_len);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif /* defined(TRANS_NETFILTER_IPV4) */
|
||||||
#ifdef TRANS_NETFILTER_IPV6
|
#ifdef TRANS_NETFILTER_IPV6
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
rv = getsockopt(ENTRY_TO_CONN(conn)->s, SOL_IPV6, IP6T_SO_ORIGINAL_DST,
|
rv = getsockopt(ENTRY_TO_CONN(conn)->s, SOL_IPV6, IP6T_SO_ORIGINAL_DST,
|
||||||
(struct sockaddr*)&orig_dst, &orig_dst_len);
|
(struct sockaddr*)&orig_dst, &orig_dst_len);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif /* defined(TRANS_NETFILTER_IPV6) */
|
||||||
default:
|
default:
|
||||||
log_warn(LD_BUG,
|
log_warn(LD_BUG,
|
||||||
"Received transparent data from an unsuported socket family %d",
|
"Received transparent data from an unsuported socket family %d",
|
||||||
@ -2142,7 +2142,7 @@ destination_from_socket(entry_connection_t *conn, socks_request_t *req)
|
|||||||
(void)req;
|
(void)req;
|
||||||
log_warn(LD_BUG, "Unable to determine destination from socket.");
|
log_warn(LD_BUG, "Unable to determine destination from socket.");
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif /* defined(TRANS_NETFILTER) || ... */
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tor_addr_from_sockaddr(&addr, (struct sockaddr*)&orig_dst, &req->port);
|
tor_addr_from_sockaddr(&addr, (struct sockaddr*)&orig_dst, &req->port);
|
||||||
@ -2150,7 +2150,7 @@ destination_from_socket(entry_connection_t *conn, socks_request_t *req)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TRANS_NETFILTER) || defined(TRANS_PF) || ... */
|
||||||
|
|
||||||
#ifdef TRANS_PF
|
#ifdef TRANS_PF
|
||||||
static int
|
static int
|
||||||
@ -2184,7 +2184,7 @@ destination_from_pf(entry_connection_t *conn, socks_request_t *req)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(__FreeBSD__) */
|
||||||
|
|
||||||
memset(&pnl, 0, sizeof(pnl));
|
memset(&pnl, 0, sizeof(pnl));
|
||||||
pnl.proto = IPPROTO_TCP;
|
pnl.proto = IPPROTO_TCP;
|
||||||
@ -2233,7 +2233,7 @@ destination_from_pf(entry_connection_t *conn, socks_request_t *req)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* defined(TRANS_PF) */
|
||||||
|
|
||||||
/** Fetch the original destination address and port from a
|
/** Fetch the original destination address and port from a
|
||||||
* system-specific interface and put them into a
|
* system-specific interface and put them into a
|
||||||
@ -2269,7 +2269,7 @@ connection_ap_get_original_destination(entry_connection_t *conn,
|
|||||||
log_warn(LD_BUG, "Called connection_ap_get_original_destination, but no "
|
log_warn(LD_BUG, "Called connection_ap_get_original_destination, but no "
|
||||||
"transparent proxy method was configured.");
|
"transparent proxy method was configured.");
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif /* defined(TRANS_NETFILTER) || ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/** connection_edge_process_inbuf() found a conn in state
|
/** connection_edge_process_inbuf() found a conn in state
|
||||||
|
@ -191,7 +191,7 @@ STATIC void connection_ap_handshake_rewrite(entry_connection_t *conn,
|
|||||||
rewrite_result_t *out);
|
rewrite_result_t *out);
|
||||||
|
|
||||||
STATIC int connection_ap_process_http_connect(entry_connection_t *conn);
|
STATIC int connection_ap_process_http_connect(entry_connection_t *conn);
|
||||||
#endif
|
#endif /* defined(CONNECTION_EDGE_PRIVATE) */
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CONNECTION_EDGE_H) */
|
||||||
|
|
||||||
|
@ -118,5 +118,5 @@ void connection_or_group_set_badness_(smartlist_t *group, int force);
|
|||||||
extern int certs_cell_ed25519_disabled_for_testing;
|
extern int certs_cell_ed25519_disabled_for_testing;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif /* !defined(TOR_CONNECTION_OR_H) */
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user