diff options
author | Roger Dingledine <arma@torproject.org> | 2004-10-01 21:02:12 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-10-01 21:02:12 +0000 |
commit | 3f4b544b77f32e906d898f9c5616c7e060c0e177 (patch) | |
tree | 2dcd5550c664130e5a5f17b7411718d60c6d7588 /src | |
parent | 8ba86dbee9c61b543ced2faeab1e6a7dbdf904ed (diff) | |
download | tor-3f4b544b77f32e906d898f9c5616c7e060c0e177.tar tor-3f4b544b77f32e906d898f9c5616c7e060c0e177.tar.gz |
use size_t rather than int for directory lengths in memory
this might fix a bug with amd64
svn:r2410
Diffstat (limited to 'src')
-rw-r--r-- | src/or/dirserv.c | 16 | ||||
-rw-r--r-- | src/or/main.c | 2 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index ec4e8d3b0..8158e6aed 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -643,14 +643,14 @@ dirserv_dump_directory_to_string(char *s, unsigned int maxlen, /** Most recently generated encoded signed directory. */ static char *the_directory = NULL; -static int the_directory_len = -1; +static size_t the_directory_len = 0; static char *the_directory_z = NULL; -static int the_directory_z_len = -1; +static size_t the_directory_z_len = 0; static char *cached_directory = NULL; /* used only by non-auth dirservers */ -static int cached_directory_len = -1; +static size_t cached_directory_len = 0; static char *cached_directory_z = NULL; -static int cached_directory_z_len = -1; +static size_t cached_directory_z_len = 0; static time_t cached_directory_published = 0; void dirserv_set_cached_directory(const char *directory, time_t when) @@ -692,7 +692,7 @@ size_t dirserv_get_directory(const char **directory, int compress) if (!options.AuthoritativeDir) { if (compress?cached_directory_z:cached_directory) { *directory = compress?cached_directory_z:cached_directory; - return (size_t) (compress?cached_directory_z_len:cached_directory_len); + return compress?cached_directory_z_len:cached_directory_len; } else { /* no directory yet retrieved */ return 0; @@ -717,7 +717,6 @@ static int dirserv_regenerate_directory(void) char *new_directory; char filename[512]; - size_t z_dir_len; new_directory = tor_malloc(MAX_DIR_SIZE); if (dirserv_dump_directory_to_string(new_directory, MAX_DIR_SIZE, get_identity_key())) { @@ -728,16 +727,15 @@ static int dirserv_regenerate_directory(void) tor_free(the_directory); the_directory = new_directory; the_directory_len = strlen(the_directory); - log_fn(LOG_INFO,"New directory (size %d):\n%s",the_directory_len, + log_fn(LOG_INFO,"New directory (size %d):\n%s",(int)the_directory_len, the_directory); tor_free(the_directory_z); - if (tor_gzip_compress(&the_directory_z, &z_dir_len, + if (tor_gzip_compress(&the_directory_z, &the_directory_z_len, the_directory, the_directory_len, ZLIB_METHOD)) { log_fn(LOG_WARN, "Error gzipping directory."); return -1; } - the_directory_z_len = (int)z_dir_len; /* Now read the directory we just made in order to update our own * router lists. This does more signature checking than is strictly diff --git a/src/or/main.c b/src/or/main.c index bef042cd2..17df97c70 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -979,7 +979,7 @@ static void dumpstats(int severity) { #else "Average bandwidth used: %llu/%ld = %d bytes/sec", #endif - stats_n_bytes_read, stats_n_seconds_uptime, + (long long unsigned int)stats_n_bytes_read, stats_n_seconds_uptime, (int) (stats_n_bytes_read/stats_n_seconds_uptime)); rep_hist_dump_stats(now,severity); |