[or-cvs] use size_t rather than int for directory lengths in memory
Roger Dingledine
arma at seul.org
Fri Oct 1 21:02:14 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
dirserv.c main.c
Log Message:
use size_t rather than int for directory lengths in memory
this might fix a bug with amd64
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- dirserv.c 29 Sep 2004 06:52:35 -0000 1.86
+++ dirserv.c 1 Oct 2004 21:02:12 -0000 1.87
@@ -643,14 +643,14 @@
/** 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 @@
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 @@
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 @@
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
@@ -771,7 +769,7 @@
char digest[DIGEST_LEN];
char signature[PK_BYTES];
int i;
- char published[33];
+ char published[33];
size_t len;
time_t published_on;
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.330
retrieving revision 1.331
diff -u -d -r1.330 -r1.331
--- main.c 29 Sep 2004 06:52:35 -0000 1.330
+++ main.c 1 Oct 2004 21:02:12 -0000 1.331
@@ -979,7 +979,7 @@
#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);
More information about the tor-commits
mailing list