[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] now base16_encode() and base32_encode() can"t ever fail
- To: or-cvs@freehaven.net
- Subject: [or-cvs] now base16_encode() and base32_encode() can"t ever fail
- From: arma@seul.org (Roger Dingledine)
- Date: Thu, 22 Jul 2004 04:30:08 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Thu, 22 Jul 2004 04:30:15 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
rendcommon.c rendmid.c rendservice.c test.c
Log Message:
now base16_encode() and base32_encode() can't ever fail
Index: rendcommon.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendcommon.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- rendcommon.c 18 May 2004 15:35:21 -0000 1.33
+++ rendcommon.c 22 Jul 2004 08:30:06 -0000 1.34
@@ -146,8 +146,7 @@
tor_assert(pk);
if (crypto_pk_get_digest(pk, buf) < 0)
return -1;
- if (base32_encode(out, REND_SERVICE_ID_LEN+1, buf, 10) < 0)
- return -1;
+ base32_encode(out, REND_SERVICE_ID_LEN+1, buf, 10);
return 0;
}
Index: rendmid.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendmid.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- rendmid.c 9 May 2004 16:47:25 -0000 1.22
+++ rendmid.c 22 Jul 2004 08:30:06 -0000 1.23
@@ -69,10 +69,7 @@
goto err;
}
- if (base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
- pk_digest,10)) {
- goto err;
- }
+ base32_encode(serviceid, REND_SERVICE_ID_LEN+1, pk_digest,10);
/* Close any other intro circuits with the same pk. */
c = NULL;
@@ -133,9 +130,7 @@
goto err;
}
- if (base32_encode(serviceid, REND_SERVICE_ID_LEN+1, request,10)) {
- goto err;
- }
+ base32_encode(serviceid, REND_SERVICE_ID_LEN+1, request,10);
/* The first 20 bytes are all we look at: they have a hash of Bob's PK. */
intro_circ = circuit_get_next_by_pk_and_purpose(
Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- rendservice.c 2 Jul 2004 23:40:03 -0000 1.73
+++ rendservice.c 22 Jul 2004 08:30:06 -0000 1.74
@@ -353,10 +353,8 @@
char serviceid[REND_SERVICE_ID_LEN+1];
char hexcookie[9];
- if (base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
- circuit->rend_pk_digest,10)) {
- return -1;
- }
+ base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
+ circuit->rend_pk_digest,10);
log_fn(LOG_INFO, "Received INTRODUCE2 cell for service %s on circ %d",
serviceid, circuit->n_circ_id);
@@ -382,9 +380,7 @@
return -1;
}
if (memcmp(circuit->rend_pk_digest, request, DIGEST_LEN)) {
- if (base32_encode(serviceid, REND_SERVICE_ID_LEN+1, request, 10)) {
- return -1;
- }
+ base32_encode(serviceid, REND_SERVICE_ID_LEN+1, request, 10);
log_fn(LOG_WARN, "Got an INTRODUCE2 cell for the wrong service (%s)",
serviceid);
return -1;
@@ -552,10 +548,8 @@
tor_assert(circuit->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO);
tor_assert(CIRCUIT_IS_ORIGIN(circuit) && circuit->cpath);
- if (base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
- circuit->rend_pk_digest,10)) {
- tor_assert(0);
- }
+ base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
+ circuit->rend_pk_digest,10);
service = rend_service_get_by_pk_digest(circuit->rend_pk_digest);
if (!service) {
@@ -644,10 +638,8 @@
tor_assert(hop);
hex_encode(circuit->rend_cookie, 4, hexcookie);
- if (base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
- circuit->rend_pk_digest,10)) {
- tor_assert(0);
- }
+ base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
+ circuit->rend_pk_digest,10);
log_fn(LOG_INFO,
"Done building circuit %d to rendezvous with cookie %s for service %s",
@@ -933,11 +925,8 @@
tor_assert(circ->purpose == CIRCUIT_PURPOSE_S_REND_JOINED);
log_fn(LOG_DEBUG,"beginning to hunt for addr/port");
- if (base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
- circ->rend_pk_digest,10)) {
- log_fn(LOG_WARN,"bug: base32 failed");
- return -1;
- }
+ base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
+ circ->rend_pk_digest,10);
service = rend_service_get_by_pk_digest(circ->rend_pk_digest);
if (!service) {
log_fn(LOG_WARN, "Couldn't find any service associated with pk %s on rendezvous circuit %d; closing",
Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- test.c 20 Jul 2004 21:13:11 -0000 1.102
+++ test.c 22 Jul 2004 08:30:06 -0000 1.103
@@ -412,18 +412,16 @@
* [00110101 01100011 01101000 01110010 01110011]
* By 5s: [00110 10101 10001 10110 10000 11100 10011 10011]
*/
- i = base32_encode(data2, 9, data1, 5);
+ base32_encode(data2, 9, data1, 5);
test_streq(data2, "gvrwq4tt");
strcpy(data1, "\xFF\xF5\x6D\x44\xAE\x0D\x5C\xC9\x62\xC4");
- i = base32_encode(data2, 30, data1, 10);
- test_eq(i,0);
+ base32_encode(data2, 30, data1, 10);
test_streq(data2, "772w2rfobvomsywe");
/* Base16 tests */
strcpy(data1, "6chrs\xff");
- i = base16_encode(data2, 13, data1, 6);
- test_eq(i,0);
+ base16_encode(data2, 13, data1, 6);
test_streq(data2, "3663687273FF");
strcpy(data1, "f0d678affc000100");