summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2009-11-13 19:58:59 +0100
committerPeter Palfrader <peter@palfrader.org>2009-11-13 19:58:59 +0100
commit4db6e63c263591d3bea58c018446cecb321e2b64 (patch)
treeb55ba6e190fb9ad2584224f1a27310c3d0cd824b /src/common
parent58ccdfccefb467fe453ec65e1cea90a6e7f729af (diff)
parent751e9b2bb64f5c4f5af6e3c9105c85deae17943e (diff)
downloadtor-4db6e63c263591d3bea58c018446cecb321e2b64.tar.gz
tor-4db6e63c263591d3bea58c018446cecb321e2b64.zip
Merge branch 'debian-merge' into debian-0.2.1
* debian-merge: (37 commits) New upstream version bump to 0.2.1.20 Move moria1 and Tonga to alternate IP addresses. read the "circwindow" parameter from the consensus Code to parse and access network parameters. Revert "Teach connection_ap_can_use_exit about Exclude*Nodes" Work around a memory leak in openssl 0.9.8g (and maybe others) Teach connection_ap_can_use_exit about Exclude*Nodes make some bug 1090 warnings go away Fix a memory leak when parsing a ns Fix obscure 64-bit big-endian hidserv bug turns out the packaging changes aren't in 0.2.1.20 update changelog with bundle details Use an _actual_ fix for the byte-reverse warning. Use a simpler fix for the byte-reversing warning Fix compile warnings on Snow Leopard Add getinfo accepted-server-descriptor. Clean spec. Reduce log level for bug case that we now know really exists. Only send reachability status events on overall success/failure update the README instructions and OS X makefiles ...
Diffstat (limited to 'src/common')
-rw-r--r--src/common/address.c9
-rw-r--r--src/common/log.c22
-rw-r--r--src/common/torint.h4
-rw-r--r--src/common/tortls.c13
-rw-r--r--src/common/tortls.h4
-rw-r--r--src/common/util.c7
6 files changed, 39 insertions, 20 deletions
diff --git a/src/common/address.c b/src/common/address.c
index fac9d50e15..2fe013a2cd 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -373,10 +373,11 @@ tor_addr_parse_reverse_lookup_name(tor_addr_t *result, const char *address,
return -1; /* malformed. */
/* reverse the bytes */
- inaddr.s_addr = (((inaddr.s_addr & 0x000000fful) << 24)
- |((inaddr.s_addr & 0x0000ff00ul) << 8)
- |((inaddr.s_addr & 0x00ff0000ul) >> 8)
- |((inaddr.s_addr & 0xff000000ul) >> 24));
+ inaddr.s_addr = (uint32_t)
+ (((inaddr.s_addr & 0x000000ff) << 24)
+ |((inaddr.s_addr & 0x0000ff00) << 8)
+ |((inaddr.s_addr & 0x00ff0000) >> 8)
+ |((inaddr.s_addr & 0xff000000) >> 24));
if (result) {
tor_addr_from_in(result, &inaddr);
diff --git a/src/common/log.c b/src/common/log.c
index a7b0c12c4a..423a687a51 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -94,7 +94,8 @@ should_log_function_name(log_domain_mask_t domain, int severity)
}
/** A mutex to guard changes to logfiles and logging. */
-static tor_mutex_t *log_mutex = NULL;
+static tor_mutex_t log_mutex;
+static int log_mutex_initialized = 0;
/** Linked list of logfile_t. */
static logfile_t *logfiles = NULL;
@@ -105,9 +106,9 @@ static int syslog_count = 0;
#endif
#define LOCK_LOGS() STMT_BEGIN \
- tor_mutex_acquire(log_mutex); \
+ tor_mutex_acquire(&log_mutex); \
STMT_END
-#define UNLOCK_LOGS() STMT_BEGIN tor_mutex_release(log_mutex); STMT_END
+#define UNLOCK_LOGS() STMT_BEGIN tor_mutex_release(&log_mutex); STMT_END
/** What's the lowest log level anybody cares about? Checking this lets us
* bail out early from log_debug if we aren't debugging. */
@@ -148,8 +149,8 @@ _log_prefix(char *buf, size_t buf_len, int severity)
t = (time_t)now.tv_sec;
n = strftime(buf, buf_len, "%b %d %H:%M:%S", tor_localtime_r(&t, &tm));
- r = tor_snprintf(buf+n, buf_len-n, ".%.3ld [%s] ",
- (long)now.tv_usec / 1000, sev_to_string(severity));
+ r = tor_snprintf(buf+n, buf_len-n, ".%.3i [%s] ",
+ (int)now.tv_usec / 1000, sev_to_string(severity));
if (r<0)
return buf_len-1;
else
@@ -448,8 +449,9 @@ logs_free_all(void)
log_free(victim);
}
tor_free(appname);
- tor_mutex_free(log_mutex);
- log_mutex = NULL;
+
+ /* We _could_ destroy the log mutex here, but that would screw up any logs
+ * that happened between here and the end of execution. */
}
/** Remove and free the log entry <b>victim</b> from the linked-list
@@ -545,8 +547,10 @@ add_stream_log(const log_severity_list_t *severity,
void
init_logging(void)
{
- if (!log_mutex)
- log_mutex = tor_mutex_new();
+ if (!log_mutex_initialized) {
+ tor_mutex_init(&log_mutex);
+ log_mutex_initialized = 1;
+ }
}
/** Add a log handler to receive messages during startup (before the real
diff --git a/src/common/torint.h b/src/common/torint.h
index 1f7421174a..f8441859a9 100644
--- a/src/common/torint.h
+++ b/src/common/torint.h
@@ -119,6 +119,10 @@ typedef unsigned int uint32_t;
#endif
#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+
#if (SIZEOF_LONG == 4)
#ifndef HAVE_INT32_T
typedef signed long int32_t;
diff --git a/src/common/tortls.c b/src/common/tortls.c
index f14eab18a5..c6b11e9a6e 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -829,6 +829,9 @@ tor_tls_new(int sock, int isServer)
if (!SSL_set_cipher_list(result->ssl,
isServer ? SERVER_CIPHER_LIST : CLIENT_CIPHER_LIST)) {
tls_log_errors(NULL, LOG_WARN, "setting ciphers");
+#ifdef SSL_set_tlsext_host_name
+ SSL_set_tlsext_host_name(result->ssl, NULL);
+#endif
SSL_free(result->ssl);
tor_free(result);
return NULL;
@@ -839,6 +842,9 @@ tor_tls_new(int sock, int isServer)
bio = BIO_new_socket(sock, BIO_NOCLOSE);
if (! bio) {
tls_log_errors(NULL, LOG_WARN, "opening BIO");
+#ifdef SSL_set_tlsext_host_name
+ SSL_set_tlsext_host_name(result->ssl, NULL);
+#endif
SSL_free(result->ssl);
tor_free(result);
return NULL;
@@ -919,6 +925,9 @@ tor_tls_free(tor_tls_t *tls)
if (!removed) {
log_warn(LD_BUG, "Freeing a TLS that was not in the ssl->tls map.");
}
+#ifdef SSL_set_tlsext_host_name
+ SSL_set_tlsext_host_name(tls->ssl, NULL);
+#endif
SSL_free(tls->ssl);
tls->ssl = NULL;
tls->negotiated_callback = NULL;
@@ -1443,8 +1452,8 @@ tor_tls_used_v1_handshake(tor_tls_t *tls)
* buffer and *<b>wbuf_bytes</b> to the amount actually used. */
void
tor_tls_get_buffer_sizes(tor_tls_t *tls,
- int *rbuf_capacity, int *rbuf_bytes,
- int *wbuf_capacity, int *wbuf_bytes)
+ size_t *rbuf_capacity, size_t *rbuf_bytes,
+ size_t *wbuf_capacity, size_t *wbuf_bytes)
{
if (tls->ssl->s3->rbuf.buf)
*rbuf_capacity = tls->ssl->s3->rbuf.len;
diff --git a/src/common/tortls.h b/src/common/tortls.h
index 44e3b499ef..d00690911c 100644
--- a/src/common/tortls.h
+++ b/src/common/tortls.h
@@ -73,8 +73,8 @@ void tor_tls_get_n_raw_bytes(tor_tls_t *tls,
size_t *n_read, size_t *n_written);
void tor_tls_get_buffer_sizes(tor_tls_t *tls,
- int *rbuf_capacity, int *rbuf_bytes,
- int *wbuf_capacity, int *wbuf_bytes);
+ size_t *rbuf_capacity, size_t *rbuf_bytes,
+ size_t *wbuf_capacity, size_t *wbuf_bytes);
int tor_tls_used_v1_handshake(tor_tls_t *tls);
diff --git a/src/common/util.c b/src/common/util.c
index 7b9e5eb562..9dcf9fba64 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1816,7 +1816,8 @@ write_chunks_to_file_impl(const char *fname, const smartlist_t *chunks,
int open_flags)
{
open_file_t *file = NULL;
- int fd, result;
+ int fd;
+ ssize_t result;
fd = start_writing_to_file(fname, open_flags, 0600, &file);
if (fd<0)
return -1;
@@ -1901,7 +1902,7 @@ read_file_to_str(const char *filename, int flags, struct stat *stat_out)
int fd; /* router file */
struct stat statbuf;
char *string;
- int r;
+ ssize_t r;
int bin = flags & RFTS_BIN;
tor_assert(filename);
@@ -1960,7 +1961,7 @@ read_file_to_str(const char *filename, int flags, struct stat *stat_out)
* match for size. */
int save_errno = errno;
log_warn(LD_FS,"Could read only %d of %ld bytes of file \"%s\".",
- r, (long)statbuf.st_size,filename);
+ (int)r, (long)statbuf.st_size,filename);
tor_free(string);
close(fd);
errno = save_errno;