aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-02-22 12:17:23 -0500
committerNick Mathewson <nickm@torproject.org>2013-04-18 11:04:56 -0400
commitfd93622cc897ede9c52205390bfb71e2e8588259 (patch)
tree7f65e88b42952611c42bfec5a3eec73a79a0121c /src/test
parent1186628fa93386a9051f4d076f2d97ec9c5dee51 (diff)
downloadtor-fd93622cc897ede9c52205390bfb71e2e8588259.tar
tor-fd93622cc897ede9c52205390bfb71e2e8588259.tar.gz
Use chunks, not buffers, for router descriptors
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_dir.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index fbd49b710..ea0011a6d 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -73,7 +73,8 @@ test_dir_nicknames(void)
static void
test_dir_formats(void)
{
- char buf[8192], buf2[8192];
+ char *buf = NULL;
+ char buf2[8192];
char platform[256];
char fingerprint[FINGERPRINT_LEN+1];
char *pk1_str = NULL, *pk2_str = NULL, *pk3_str = NULL, *cp;
@@ -142,8 +143,8 @@ test_dir_formats(void)
test_assert(!crypto_pk_write_public_key_to_string(pk3 , &pk3_str,
&pk3_str_len));
- memset(buf, 0, 2048);
- test_assert(router_dump_router_to_string(buf, 2048, r1, pk2)>0);
+ buf = router_dump_router_to_string(r1, pk2);
+ test_assert(buf);
strlcpy(buf2, "router Magri 18.244.0.1 9000 0 9003\n"
"or-address [1:2:3:4::]:9999\n"
@@ -170,8 +171,10 @@ test_dir_formats(void)
* twice */
test_streq(buf, buf2);
+ tor_free(buf);
- test_assert(router_dump_router_to_string(buf, 2048, r1, pk2)>0);
+ buf = router_dump_router_to_string(r1, pk2);
+ test_assert(buf);
cp = buf;
rp1 = router_parse_entry_from_string((const char*)cp,NULL,1,0,NULL);
test_assert(rp1);
@@ -232,6 +235,7 @@ test_dir_formats(void)
if (r2)
routerinfo_free(r2);
+ tor_free(buf);
tor_free(pk1_str);
tor_free(pk2_str);
tor_free(pk3_str);