Commit e7db789e authored by Nick Mathewson's avatar Nick Mathewson 🥄
Browse files

r14399@tombo: nickm | 2008-02-22 14:09:38 -0500

 More 64-to-32 fixes. Partial backport candidate. still not done.


svn:r13680
parent a20eda56
...@@ -715,7 +715,7 @@ crypto_pk_public_checksig(crypto_pk_env_t *env, char *to, ...@@ -715,7 +715,7 @@ crypto_pk_public_checksig(crypto_pk_env_t *env, char *to,
*/ */
int int
crypto_pk_public_checksig_digest(crypto_pk_env_t *env, const char *data, crypto_pk_public_checksig_digest(crypto_pk_env_t *env, const char *data,
int datalen, const char *sig, int siglen) size_t datalen, const char *sig, size_t siglen)
{ {
char digest[DIGEST_LEN]; char digest[DIGEST_LEN];
char *buf; char *buf;
...@@ -935,12 +935,12 @@ crypto_pk_private_hybrid_decrypt(crypto_pk_env_t *env, ...@@ -935,12 +935,12 @@ crypto_pk_private_hybrid_decrypt(crypto_pk_env_t *env,
* Return -1 on error, or the number of characters used on success. * Return -1 on error, or the number of characters used on success.
*/ */
int int
crypto_pk_asn1_encode(crypto_pk_env_t *pk, char *dest, int dest_len) crypto_pk_asn1_encode(crypto_pk_env_t *pk, char *dest, size_t dest_len)
{ {
int len; int len;
unsigned char *buf, *cp; unsigned char *buf, *cp;
len = i2d_RSAPublicKey(pk->key, NULL); len = i2d_RSAPublicKey(pk->key, NULL);
if (len < 0 || len > dest_len) if (len < 0 || (size_t)len > dest_len)
return -1; return -1;
cp = buf = tor_malloc(len+1); cp = buf = tor_malloc(len+1);
len = i2d_RSAPublicKey(pk->key, &cp); len = i2d_RSAPublicKey(pk->key, &cp);
......
...@@ -97,7 +97,7 @@ int crypto_pk_private_decrypt(crypto_pk_env_t *env, char *to, ...@@ -97,7 +97,7 @@ int crypto_pk_private_decrypt(crypto_pk_env_t *env, char *to,
int crypto_pk_public_checksig(crypto_pk_env_t *env, char *to, int crypto_pk_public_checksig(crypto_pk_env_t *env, char *to,
const char *from, size_t fromlen); const char *from, size_t fromlen);
int crypto_pk_public_checksig_digest(crypto_pk_env_t *env, const char *data, int crypto_pk_public_checksig_digest(crypto_pk_env_t *env, const char *data,
int datalen, const char *sig, int siglen); size_t datalen, const char *sig, size_t siglen);
int crypto_pk_private_sign(crypto_pk_env_t *env, char *to, int crypto_pk_private_sign(crypto_pk_env_t *env, char *to,
const char *from, size_t fromlen); const char *from, size_t fromlen);
int crypto_pk_private_sign_digest(crypto_pk_env_t *env, char *to, int crypto_pk_private_sign_digest(crypto_pk_env_t *env, char *to,
...@@ -109,7 +109,7 @@ int crypto_pk_private_hybrid_decrypt(crypto_pk_env_t *env, char *to, ...@@ -109,7 +109,7 @@ int crypto_pk_private_hybrid_decrypt(crypto_pk_env_t *env, char *to,
const char *from, size_t fromlen, const char *from, size_t fromlen,
int padding, int warnOnFailure); int padding, int warnOnFailure);
int crypto_pk_asn1_encode(crypto_pk_env_t *pk, char *dest, int dest_len); int crypto_pk_asn1_encode(crypto_pk_env_t *pk, char *dest, size_t dest_len);
crypto_pk_env_t *crypto_pk_asn1_decode(const char *str, size_t len); crypto_pk_env_t *crypto_pk_asn1_decode(const char *str, size_t len);
int crypto_pk_get_digest(crypto_pk_env_t *pk, char *digest_out); int crypto_pk_get_digest(crypto_pk_env_t *pk, char *digest_out);
int crypto_pk_get_fingerprint(crypto_pk_env_t *pk, char *fp_out,int add_space); int crypto_pk_get_fingerprint(crypto_pk_env_t *pk, char *fp_out,int add_space);
......
...@@ -2561,10 +2561,10 @@ alloc_http_authenticator(const char *authenticator) ...@@ -2561,10 +2561,10 @@ alloc_http_authenticator(const char *authenticator)
{ {
/* an authenticator in Basic authentication /* an authenticator in Basic authentication
* is just the string "username:password" */ * is just the string "username:password" */
const int authenticator_length = strlen(authenticator); const size_t authenticator_length = strlen(authenticator);
/* The base64_encode function needs a minimum buffer length /* The base64_encode function needs a minimum buffer length
* of 66 bytes. */ * of 66 bytes. */
const int base64_authenticator_length = (authenticator_length/48+1)*66; const size_t base64_authenticator_length = (authenticator_length/48+1)*66;
char *base64_authenticator = tor_malloc(base64_authenticator_length); char *base64_authenticator = tor_malloc(base64_authenticator_length);
if (base64_encode(base64_authenticator, base64_authenticator_length, if (base64_encode(base64_authenticator, base64_authenticator_length,
authenticator, authenticator_length) < 0) { authenticator, authenticator_length) < 0) {
......
...@@ -364,7 +364,7 @@ connection_ap_expire_beginning(void) ...@@ -364,7 +364,7 @@ connection_ap_expire_beginning(void)
/* if it's an internal linked connection, don't yell its status. */ /* if it's an internal linked connection, don't yell its status. */
severity = (!conn->_base.addr && !conn->_base.port) severity = (!conn->_base.addr && !conn->_base.port)
? LOG_INFO : LOG_NOTICE; ? LOG_INFO : LOG_NOTICE;
seconds_idle = now - conn->_base.timestamp_lastread; seconds_idle = (int)( now - conn->_base.timestamp_lastread );
if (AP_CONN_STATE_IS_UNATTACHED(conn->_base.state)) { if (AP_CONN_STATE_IS_UNATTACHED(conn->_base.state)) {
if (seconds_idle >= options->SocksTimeout) { if (seconds_idle >= options->SocksTimeout) {
...@@ -1004,7 +1004,7 @@ parse_virtual_addr_network(const char *val, int validate_only, ...@@ -1004,7 +1004,7 @@ parse_virtual_addr_network(const char *val, int validate_only,
if (validate_only) if (validate_only)
return 0; return 0;
virtual_addr_network = addr & (0xfffffffful << (32-bits)); virtual_addr_network = (uint32_t)( addr & (0xfffffffful << (32-bits)) );
virtual_addr_netmask_bits = bits; virtual_addr_netmask_bits = bits;
if (addr_mask_cmp_bits(next_virtual_addr, addr, bits)) if (addr_mask_cmp_bits(next_virtual_addr, addr, bits))
...@@ -1938,7 +1938,7 @@ connection_ap_handshake_send_begin(edge_connection_t *ap_conn) ...@@ -1938,7 +1938,7 @@ connection_ap_handshake_send_begin(edge_connection_t *ap_conn)
(circ->_base.purpose == CIRCUIT_PURPOSE_C_GENERAL) ? (circ->_base.purpose == CIRCUIT_PURPOSE_C_GENERAL) ?
ap_conn->socks_request->address : "", ap_conn->socks_request->address : "",
ap_conn->socks_request->port); ap_conn->socks_request->port);
payload_len = strlen(payload)+1; payload_len = (int)strlen(payload)+1;
log_debug(LD_APP, log_debug(LD_APP,
"Sending relay cell to begin stream %d.", ap_conn->stream_id); "Sending relay cell to begin stream %d.", ap_conn->stream_id);
...@@ -1995,7 +1995,7 @@ connection_ap_handshake_send_resolve(edge_connection_t *ap_conn) ...@@ -1995,7 +1995,7 @@ connection_ap_handshake_send_resolve(edge_connection_t *ap_conn)
if (command == SOCKS_COMMAND_RESOLVE) { if (command == SOCKS_COMMAND_RESOLVE) {
string_addr = ap_conn->socks_request->address; string_addr = ap_conn->socks_request->address;
payload_len = strlen(string_addr)+1; payload_len = (int)strlen(string_addr)+1;
tor_assert(payload_len <= RELAY_PAYLOAD_SIZE); tor_assert(payload_len <= RELAY_PAYLOAD_SIZE);
} else { } else {
struct in_addr in; struct in_addr in;
...@@ -2029,7 +2029,7 @@ connection_ap_handshake_send_resolve(edge_connection_t *ap_conn) ...@@ -2029,7 +2029,7 @@ connection_ap_handshake_send_resolve(edge_connection_t *ap_conn)
(int)(uint8_t)((a>>24)&0xff)); (int)(uint8_t)((a>>24)&0xff));
} }
string_addr = inaddr_buf; string_addr = inaddr_buf;
payload_len = strlen(inaddr_buf)+1; payload_len = (int)strlen(inaddr_buf)+1;
tor_assert(payload_len <= RELAY_PAYLOAD_SIZE); tor_assert(payload_len <= RELAY_PAYLOAD_SIZE);
} }
......
...@@ -288,7 +288,7 @@ connection_or_flushed_some(or_connection_t *conn) ...@@ -288,7 +288,7 @@ connection_or_flushed_some(or_connection_t *conn)
/* If we're under the low water mark, add cells until we're just over the /* If we're under the low water mark, add cells until we're just over the
* high water mark. */ * high water mark. */
if (datalen < OR_CONN_LOWWATER) { if (datalen < OR_CONN_LOWWATER) {
int n = (OR_CONN_HIGHWATER - datalen + CELL_NETWORK_SIZE-1) ssize_t n = (OR_CONN_HIGHWATER - datalen + CELL_NETWORK_SIZE-1)
/ CELL_NETWORK_SIZE; / CELL_NETWORK_SIZE;
while (conn->active_circuits && n > 0) { while (conn->active_circuits && n > 0) {
int flushed = connection_or_flush_from_first_active_circuit(conn, 1); int flushed = connection_or_flush_from_first_active_circuit(conn, 1);
...@@ -1023,7 +1023,7 @@ connection_or_send_destroy(uint16_t circ_id, or_connection_t *conn, int reason) ...@@ -1023,7 +1023,7 @@ connection_or_send_destroy(uint16_t circ_id, or_connection_t *conn, int reason)
static const uint16_t or_protocol_versions[] = { 1, 2 }; static const uint16_t or_protocol_versions[] = { 1, 2 };
/** Number of versions in <b>or_protocol_versions</b>. */ /** Number of versions in <b>or_protocol_versions</b>. */
static const int n_or_protocol_versions = static const int n_or_protocol_versions =
sizeof(or_protocol_versions)/sizeof(uint16_t); (int)( sizeof(or_protocol_versions)/sizeof(uint16_t) );
/** Return true iff <b>v</b> is a link protocol version that this Tor /** Return true iff <b>v</b> is a link protocol version that this Tor
* implementation believes it can support. */ * implementation believes it can support. */
...@@ -1074,7 +1074,7 @@ connection_or_send_netinfo(or_connection_t *conn) ...@@ -1074,7 +1074,7 @@ connection_or_send_netinfo(or_connection_t *conn)
cell.command = CELL_NETINFO; cell.command = CELL_NETINFO;
/* Their address. */ /* Their address. */
set_uint32(cell.payload, htonl(now)); set_uint32(cell.payload, htonl((uint32_t)now));
cell.payload[4] = RESOLVED_TYPE_IPV4; cell.payload[4] = RESOLVED_TYPE_IPV4;
cell.payload[5] = 4; cell.payload[5] = 4;
set_uint32(cell.payload+6, htonl(conn->_base.addr)); set_uint32(cell.payload+6, htonl(conn->_base.addr));
......
...@@ -398,7 +398,7 @@ get_escaped_string_length(const char *start, size_t in_len_max, ...@@ -398,7 +398,7 @@ get_escaped_string_length(const char *start, size_t in_len_max,
} }
if (chars_out) if (chars_out)
*chars_out = chars; *chars_out = chars;
return cp - start+1; return (int)(cp - start+1);
} }
/** As decode_escaped_string, but does not decode the string: copies the /** As decode_escaped_string, but does not decode the string: copies the
...@@ -631,9 +631,9 @@ send_control_event_extended(uint16_t event, event_format_t which, ...@@ -631,9 +631,9 @@ send_control_event_extended(uint16_t event, event_format_t which,
static origin_circuit_t * static origin_circuit_t *
get_circ(const char *id) get_circ(const char *id)
{ {
unsigned long n_id; uint32_t n_id;
int ok; int ok;
n_id = tor_parse_ulong(id, 10, 0, ULONG_MAX, &ok, NULL); n_id = (uint32_t) tor_parse_ulong(id, 10, 0, UINT32_MAX, &ok, NULL);
if (!ok) if (!ok)
return NULL; return NULL;
return circuit_get_by_global_id(n_id); return circuit_get_by_global_id(n_id);
...@@ -643,10 +643,10 @@ get_circ(const char *id) ...@@ -643,10 +643,10 @@ get_circ(const char *id)
static edge_connection_t * static edge_connection_t *
get_stream(const char *id) get_stream(const char *id)
{ {
unsigned long n_id; uint32_t n_id;
int ok; int ok;
edge_connection_t *conn; edge_connection_t *conn;
n_id = tor_parse_ulong(id, 10, 0, ULONG_MAX, &ok, NULL); n_id = (uint32_t) tor_parse_ulong(id, 10, 0, UINT32_MAX, &ok, NULL);
if (!ok) if (!ok)
return NULL; return NULL;
conn = connection_get_by_global_id(n_id); conn = connection_get_by_global_id(n_id);
...@@ -1008,7 +1008,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len, ...@@ -1008,7 +1008,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
cp = body; cp = body;
while (TOR_ISXDIGIT(*cp)) while (TOR_ISXDIGIT(*cp))
++cp; ++cp;
i = cp - body; i = (int)(cp - body);
tor_assert(i>0); tor_assert(i>0);
password_len = i/2; password_len = i/2;
password = tor_malloc(password_len + 1); password = tor_malloc(password_len + 1);
...@@ -2197,8 +2197,8 @@ handle_control_attachstream(control_connection_t *conn, uint32_t len, ...@@ -2197,8 +2197,8 @@ handle_control_attachstream(control_connection_t *conn, uint32_t len,
char *hopstring = smartlist_get(args, 2); char *hopstring = smartlist_get(args, 2);
if (!strcasecmpstart(hopstring, "HOP=")) { if (!strcasecmpstart(hopstring, "HOP=")) {
hopstring += strlen("HOP="); hopstring += strlen("HOP=");
hop = tor_parse_ulong(hopstring, 10, 0, ULONG_MAX, hop = (int) tor_parse_ulong(hopstring, 10, 0, INT_MAX,
&hop_line_ok, NULL); &hop_line_ok, NULL);
if (!hop_line_ok) { /* broken hop line */ if (!hop_line_ok) { /* broken hop line */
connection_printf_to_buf(conn, "552 Bad value hop=%s\r\n", hopstring); connection_printf_to_buf(conn, "552 Bad value hop=%s\r\n", hopstring);
} }
...@@ -2660,6 +2660,7 @@ int ...@@ -2660,6 +2660,7 @@ int
connection_control_process_inbuf(control_connection_t *conn) connection_control_process_inbuf(control_connection_t *conn)
{ {
size_t data_len; size_t data_len;
uint32_t cmd_data_len;
int cmd_len; int cmd_len;
char *args; char *args;
...@@ -2721,7 +2722,7 @@ connection_control_process_inbuf(control_connection_t *conn) ...@@ -2721,7 +2722,7 @@ connection_control_process_inbuf(control_connection_t *conn)
tor_assert(data_len); tor_assert(data_len);
last_idx = conn->incoming_cmd_cur_len; last_idx = conn->incoming_cmd_cur_len;
conn->incoming_cmd_cur_len += data_len; conn->incoming_cmd_cur_len += (int)data_len;
/* We have appended a line to incoming_cmd. Is the command done? */ /* We have appended a line to incoming_cmd. Is the command done? */
if (last_idx == 0 && *conn->incoming_cmd != '+') if (last_idx == 0 && *conn->incoming_cmd != '+')
...@@ -2772,64 +2773,71 @@ connection_control_process_inbuf(control_connection_t *conn) ...@@ -2772,64 +2773,71 @@ connection_control_process_inbuf(control_connection_t *conn)
return 0; return 0;
} }
if (data_len >= UINT32_MAX) {
connection_write_str_to_buf("500 A 4GB command? Nice try.\r\n", conn);
connection_mark_for_close(TO_CONN(conn));
return 0;
}
cmd_data_len = (uint32_t)data_len;
if (!strcasecmp(conn->incoming_cmd, "SETCONF")) { if (!strcasecmp(conn->incoming_cmd, "SETCONF")) {
if (handle_control_setconf(conn, data_len, args)) if (handle_control_setconf(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "RESETCONF")) { } else if (!strcasecmp(conn->incoming_cmd, "RESETCONF")) {
if (handle_control_resetconf(conn, data_len, args)) if (handle_control_resetconf(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "GETCONF")) { } else if (!strcasecmp(conn->incoming_cmd, "GETCONF")) {
if (handle_control_getconf(conn, data_len, args)) if (handle_control_getconf(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "SETEVENTS")) { } else if (!strcasecmp(conn->incoming_cmd, "SETEVENTS")) {
if (handle_control_setevents(conn, data_len, args)) if (handle_control_setevents(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "AUTHENTICATE")) { } else if (!strcasecmp(conn->incoming_cmd, "AUTHENTICATE")) {
if (handle_control_authenticate(conn, data_len, args)) if (handle_control_authenticate(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "SAVECONF")) { } else if (!strcasecmp(conn->incoming_cmd, "SAVECONF")) {
if (handle_control_saveconf(conn, data_len, args)) if (handle_control_saveconf(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "SIGNAL")) { } else if (!strcasecmp(conn->incoming_cmd, "SIGNAL")) {
if (handle_control_signal(conn, data_len, args)) if (handle_control_signal(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "MAPADDRESS")) { } else if (!strcasecmp(conn->incoming_cmd, "MAPADDRESS")) {
if (handle_control_mapaddress(conn, data_len, args)) if (handle_control_mapaddress(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "GETINFO")) { } else if (!strcasecmp(conn->incoming_cmd, "GETINFO")) {
if (handle_control_getinfo(conn, data_len, args)) if (handle_control_getinfo(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "EXTENDCIRCUIT")) { } else if (!strcasecmp(conn->incoming_cmd, "EXTENDCIRCUIT")) {
if (handle_control_extendcircuit(conn, data_len, args)) if (handle_control_extendcircuit(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "SETCIRCUITPURPOSE")) { } else if (!strcasecmp(conn->incoming_cmd, "SETCIRCUITPURPOSE")) {
if (handle_control_setcircuitpurpose(conn, data_len, args)) if (handle_control_setcircuitpurpose(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "SETROUTERPURPOSE")) { } else if (!strcasecmp(conn->incoming_cmd, "SETROUTERPURPOSE")) {
connection_write_str_to_buf("511 SETROUTERPURPOSE is obsolete.\r\n", conn); connection_write_str_to_buf("511 SETROUTERPURPOSE is obsolete.\r\n", conn);
} else if (!strcasecmp(conn->incoming_cmd, "ATTACHSTREAM")) { } else if (!strcasecmp(conn->incoming_cmd, "ATTACHSTREAM")) {
if (handle_control_attachstream(conn, data_len, args)) if (handle_control_attachstream(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "+POSTDESCRIPTOR")) { } else if (!strcasecmp(conn->incoming_cmd, "+POSTDESCRIPTOR")) {
if (handle_control_postdescriptor(conn, data_len, args)) if (handle_control_postdescriptor(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "REDIRECTSTREAM")) { } else if (!strcasecmp(conn->incoming_cmd, "REDIRECTSTREAM")) {
if (handle_control_redirectstream(conn, data_len, args)) if (handle_control_redirectstream(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "CLOSESTREAM")) { } else if (!strcasecmp(conn->incoming_cmd, "CLOSESTREAM")) {
if (handle_control_closestream(conn, data_len, args)) if (handle_control_closestream(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "CLOSECIRCUIT")) { } else if (!strcasecmp(conn->incoming_cmd, "CLOSECIRCUIT")) {
if (handle_control_closecircuit(conn, data_len, args)) if (handle_control_closecircuit(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "USEFEATURE")) { } else if (!strcasecmp(conn->incoming_cmd, "USEFEATURE")) {
if (handle_control_usefeature(conn, data_len, args)) if (handle_control_usefeature(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "RESOLVE")) { } else if (!strcasecmp(conn->incoming_cmd, "RESOLVE")) {
if (handle_control_resolve(conn, data_len, args)) if (handle_control_resolve(conn, cmd_data_len, args))
return -1; return -1;
} else if (!strcasecmp(conn->incoming_cmd, "PROTOCOLINFO")) { } else if (!strcasecmp(conn->incoming_cmd, "PROTOCOLINFO")) {
if (handle_control_protocolinfo(conn, data_len, args)) if (handle_control_protocolinfo(conn, cmd_data_len, args))
return -1; return -1;
} else { } else {
connection_printf_to_buf(conn, "510 Unrecognized command \"%s\"\r\n", connection_printf_to_buf(conn, "510 Unrecognized command \"%s\"\r\n",
...@@ -3457,7 +3465,7 @@ control_event_or_authdir_new_descriptor(const char *action, ...@@ -3457,7 +3465,7 @@ control_event_or_authdir_new_descriptor(const char *action,
{ {
char firstline[1024]; char firstline[1024];
char *buf; char *buf;
int totallen; size_t totallen;
char *esc = NULL; char *esc = NULL;
size_t esclen; size_t esclen;
......
...@@ -250,7 +250,7 @@ cpuworker_main(void *data) ...@@ -250,7 +250,7 @@ cpuworker_main(void *data)
dup_onion_keys(&onion_key, &last_onion_key); dup_onion_keys(&onion_key, &last_onion_key);
for (;;) { for (;;) {
int r; ssize_t r;
if ((r = recv(fd, &question_type, 1, 0)) != 1) { if ((r = recv(fd, &question_type, 1, 0)) != 1) {
// log_fn(LOG_ERR,"read type failed. Exiting."); // log_fn(LOG_ERR,"read type failed. Exiting.");
......
...@@ -1225,7 +1225,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn) ...@@ -1225,7 +1225,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
size_t body_len=0, orig_len=0; size_t body_len=0, orig_len=0;
int status_code; int status_code;
time_t date_header=0; time_t date_header=0;
int delta; long delta;
compress_method_t compression; compress_method_t compression;
int plausible; int plausible;
int skewed=0; int skewed=0;
...@@ -1281,7 +1281,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn) ...@@ -1281,7 +1281,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
* inaccurate if we spend a lot of time downloading.) * inaccurate if we spend a lot of time downloading.)
*/ */
delta = conn->_base.timestamp_lastwritten - date_header; delta = conn->_base.timestamp_lastwritten - date_header;
if (abs(delta)>ALLOW_DIRECTORY_TIME_SKEW) { if (labs(delta)>ALLOW_DIRECTORY_TIME_SKEW) {
char dbuf[64]; char dbuf[64];
int trusted = router_digest_is_trusted_dir(conn->identity_digest); int trusted = router_digest_is_trusted_dir(conn->identity_digest);
format_time_interval(dbuf, sizeof(dbuf), delta); format_time_interval(dbuf, sizeof(dbuf), delta);
...@@ -1296,11 +1296,11 @@ connection_dir_client_reached_eof(dir_connection_t *conn) ...@@ -1296,11 +1296,11 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
delta>0 ? "behind" : "ahead"); delta>0 ? "behind" : "ahead");
skewed = 1; /* don't check the recommended-versions line */ skewed = 1; /* don't check the recommended-versions line */
control_event_general_status(trusted ? LOG_WARN : LOG_NOTICE, control_event_general_status(trusted ? LOG_WARN : LOG_NOTICE,
"CLOCK_SKEW SKEW=%d SOURCE=DIRSERV:%s:%d", "CLOCK_SKEW SKEW=%ld SOURCE=DIRSERV:%s:%d",
delta, conn->_base.address, conn->_base.port); delta, conn->_base.address, conn->_base.port);
} else { } else {
log_debug(LD_HTTP, "Time on received directory is within tolerance; " log_debug(LD_HTTP, "Time on received directory is within tolerance; "
"we are %d seconds skewed. (That's okay.)", delta); "we are %ld seconds skewed. (That's okay.)", delta);
} }
} }
(void) skewed; /* skewed isn't used yet. */ (void) skewed; /* skewed isn't used yet. */
...@@ -1977,7 +1977,7 @@ static void ...@@ -1977,7 +1977,7 @@ static void
write_http_response_header_impl(dir_connection_t *conn, ssize_t length, write_http_response_header_impl(dir_connection_t *conn, ssize_t length,
const char *type, const char *encoding, const char *type, const char *encoding,
const char *extra_headers, const char *extra_headers,
int cache_lifetime) long cache_lifetime)
{ {
char date[RFC1123_TIME_LEN+1]; char date[RFC1123_TIME_LEN+1];
char tmp[1024]; char tmp[1024];
...@@ -2041,7 +2041,7 @@ write_http_response_header_impl(dir_connection_t *conn, ssize_t length, ...@@ -2041,7 +2041,7 @@ write_http_response_header_impl(dir_connection_t *conn, ssize_t length,
* based on whether the response will be <b>compressed</b> or not. */ * based on whether the response will be <b>compressed</b> or not. */
static void static void
write_http_response_header(dir_connection_t *conn, ssize_t length, write_http_response_header(dir_connection_t *conn, ssize_t length,
int compressed, int cache_lifetime) int compressed, long cache_lifetime)
{ {
write_http_response_header_impl(conn, length, write_http_response_header_impl(conn, length,
compressed?"application/octet-stream":"text/plain", compressed?"application/octet-stream":"text/plain",
...@@ -2273,7 +2273,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers, ...@@ -2273,7 +2273,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
int is_v3 = !strcmpstart(url, "/tor/status-vote"); int is_v3 = !strcmpstart(url, "/tor/status-vote");
const char *request_type = NULL; const char *request_type = NULL;
const char *key = url + strlen("/tor/status/"); const char *key = url + strlen("/tor/status/");
int lifetime = NETWORKSTATUS_CACHE_LIFETIME; long lifetime = NETWORKSTATUS_CACHE_LIFETIME;
if (!is_v3) { if (!is_v3) {
dirserv_get_networkstatus_v2_fingerprints(dir_fps, key); dirserv_get_networkstatus_v2_fingerprints(dir_fps, key);
if (!strcmpstart(key, "fp/")) if (!strcmpstart(key, "fp/"))
...@@ -3004,7 +3004,7 @@ download_status_increment_failure(download_status_t *dls, int status_code, ...@@ -3004,7 +3004,7 @@ download_status_increment_failure(download_status_t *dls, int status_code,
const char *item, int server, time_t now) const char *item, int server, time_t now)
{ {
const int *schedule; const int *schedule;
int schedule_len; size_t schedule_len;
int increment; int increment;
tor_assert(dls); tor_assert(dls);
if (status_code != 503 || server) if (status_code != 503 || server)
......
...@@ -31,9 +31,9 @@ const char dirserv_c_id[] = ...@@ -31,9 +31,9 @@ const char dirserv_c_id[] =
extern time_t time_of_process_start; /* from main.c */ extern time_t time_of_process_start; /* from main.c */
/** Do we need to regenerate the directory when someone asks for it? */ /** Do we need to regenerate the directory when someone asks for it? */
static int the_directory_is_dirty = 1; static time_t the_directory_is_dirty = 1;
static int runningrouters_is_dirty = 1; static time_t runningrouters_is_dirty = 1;
static int the_v2_networkstatus_is_dirty = 1; static time_t the_v2_networkstatus_is_dirty = 1;
/** Most recently generated encoded signed v1 directory. (v1 auth dirservers /** Most recently generated encoded signed v1 directory. (v1 auth dirservers
* only.) */ * only.) */
...@@ -1628,7 +1628,7 @@ static uint64_t total_exit_bandwidth = 0; ...@@ -1628,7 +1628,7 @@ static uint64_t total_exit_bandwidth = 0;
/** Helper: estimate the uptime of a router given its stated uptime and the /** Helper: estimate the uptime of a router given its stated uptime and the
* amount of time since it last stated its stated uptime. */ * amount of time since it last stated its stated uptime. */
static INLINE int static INLINE long
real_uptime(routerinfo_t *router, time_t now) real_uptime(routerinfo_t *router, time_t now)
{ {
if (now < router->cache_info.published_on) if (now < router->cache_info.published_on)
...@@ -1652,7 +1652,7 @@ dirserv_thinks_router_is_unreliable(time_t now, ...@@ -1652,7 +1652,7 @@ dirserv_thinks_router_is_unreliable(time_t now,
/* XXXX Once most authorities are on v3, we should change the rule from /* XXXX Once most authorities are on v3, we should change the rule from
* "use uptime if we don't have mtbf data" to "don't advertise Stable on * "use uptime if we don't have mtbf data" to "don't advertise Stable on
* v3 if we don't have enough mtbf data." */ * v3 if we don't have enough mtbf data." */
int uptime = real_uptime(router, now); long uptime = real_uptime(router, now);
if ((unsigned)uptime < stable_uptime && if ((unsigned)uptime < stable_uptime &&
(unsigned)uptime < UPTIME_TO_GUARANTEE_STABLE) (unsigned)uptime < UPTIME_TO_GUARANTEE_STABLE)
return 1; return 1;
...@@ -1681,7 +1681,7 @@ dirserv_thinks_router_is_unreliable(time_t now, ...@@ -1681,7 +1681,7 @@ dirserv_thinks_router_is_unreliable(time_t now,
static int static int
dirserv_thinks_router_is_hs_dir(routerinfo_t *router, time_t now) dirserv_thinks_router_is_hs_dir(routerinfo_t *router, time_t now)
{ {