[or-cvs] Be endianly-correct for rendezvous functionality
Nick Mathewson
nickm at seul.org
Thu Apr 8 04:47:41 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv3710/src/or
Modified Files:
rendcommon.c rendmid.c rendservice.c
Log Message:
Be endianly-correct for rendezvous functionality
Index: rendcommon.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendcommon.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- rendcommon.c 8 Apr 2004 03:02:50 -0000 1.22
+++ rendcommon.c 8 Apr 2004 04:47:39 -0000 1.23
@@ -42,14 +42,14 @@
*len_out += strlen(desc->intro_points[i]) + 1;
}
cp = *str_out = tor_malloc(*len_out);
- set_uint16(cp, (uint16_t)asn1len);
+ set_uint16(cp, htons((uint16_t)asn1len));
cp += 2;
memcpy(cp, buf, asn1len);
tor_free(buf);
cp += asn1len;
- set_uint32(cp, (uint32_t)desc->timestamp);
+ set_uint32(cp, htonl((uint32_t)desc->timestamp));
cp += 4;
- set_uint16(cp, (uint16_t)desc->n_intro_points);
+ set_uint16(cp, htons((uint16_t)desc->n_intro_points));
cp += 2;
for (i=0; i < desc->n_intro_points; ++i) {
ipoint = (char*)desc->intro_points[i];
@@ -79,17 +79,17 @@
cp = str;
end = str+len;
if (end-cp < 2) goto truncated;
- asn1len = get_uint16(cp);
+ asn1len = ntohs(get_uint16(cp));
cp += 2;
if (end-cp < asn1len) goto truncated;
result->pk = crypto_pk_asn1_decode(cp, asn1len);
if (!result->pk) goto truncated;
cp += asn1len;
if (end-cp < 4) goto truncated;
- result->timestamp = (time_t) get_uint32(cp);
+ result->timestamp = (time_t) ntohl(get_uint32(cp));
cp += 4;
if (end-cp < 2) goto truncated;
- result->n_intro_points = get_uint16(cp);
+ result->n_intro_points = ntohs(get_uint16(cp));
result->intro_points = tor_malloc_zero(sizeof(char*)*result->n_intro_points);
cp += 2;
for (i=0;i<result->n_intro_points;++i) {
Index: rendmid.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendmid.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- rendmid.c 6 Apr 2004 03:44:36 -0000 1.15
+++ rendmid.c 8 Apr 2004 04:47:39 -0000 1.16
@@ -28,7 +28,7 @@
if (request_len < 2+DIGEST_LEN)
goto truncated;
/* First 2 bytes: length of asn1-encoded key. */
- asn1len = get_uint16(request);
+ asn1len = ntohs(get_uint16(request));
/* Next asn1len bytes: asn1-encoded key. */
if (request_len < 2+DIGEST_LEN+asn1len)
Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- rendservice.c 8 Apr 2004 04:36:13 -0000 1.43
+++ rendservice.c 8 Apr 2004 04:47:39 -0000 1.44
@@ -498,7 +498,7 @@
/* Build the payload for a RELAY_ESTABLISH_INTRO cell. */
len = crypto_pk_asn1_encode(service->private_key, buf+2,
RELAY_PAYLOAD_SIZE-2);
- set_uint16(buf, len);
+ set_uint16(buf, htons(len));
len += 2;
memcpy(auth, circuit->cpath->prev->handshake_digest, DIGEST_LEN);
memcpy(auth+DIGEST_LEN, "INTRODUCE", 9);
More information about the tor-commits
mailing list