Be endianly-correct for rendezvous functionality

svn:r1565
This commit is contained in:
Nick Mathewson 2004-04-08 04:47:39 +00:00
parent 15de201041
commit bb46d782ab
3 changed files with 8 additions and 8 deletions

View File

@ -42,14 +42,14 @@ rend_encode_service_descriptor(rend_service_descriptor_t *desc,
*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 @@ rend_service_descriptor_t *rend_parse_service_descriptor(
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) {

View File

@ -28,7 +28,7 @@ rend_mid_establish_intro(circuit_t *circ, const char *request, int request_len)
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)

View File

@ -498,7 +498,7 @@ rend_service_intro_is_ready(circuit_t *circuit)
/* 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);