summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-11-17 07:37:45 +0000
committerNick Mathewson <nickm@torproject.org>2003-11-17 07:37:45 +0000
commit44ced0952f22aabf2d3686ad861abe99196964a2 (patch)
tree2d2cb38dbbb01a69fcc0be690bfbbe9c7143507b
parent42b5ed754f18a1ff473ab622409846103dc2fcdf (diff)
downloadtor-44ced0952f22aabf2d3686ad861abe99196964a2.tar.gz
tor-44ced0952f22aabf2d3686ad861abe99196964a2.zip
Fix bytesex issues on in.s_addr
svn:r826
-rw-r--r--src/or/connection_edge.c15
-rw-r--r--src/or/routers.c14
2 files changed, 15 insertions, 14 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 69216eae7e..57f72e8808 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -618,7 +618,7 @@ static void connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t
crypto_pseudo_rand(STREAM_ID_SIZE, ap_conn->stream_id);
/* FIXME check for collisions */
- in.s_addr = client_dns_lookup_entry(ap_conn->socks_request->address);
+ in.s_addr = htonl(client_dns_lookup_entry(ap_conn->socks_request->address));
string_addr = in.s_addr ? inet_ntoa(in) : NULL;
memcpy(payload, ap_conn->stream_id, STREAM_ID_SIZE);
@@ -831,8 +831,9 @@ static uint32_t client_dns_lookup_entry(const char *address)
assert(address);
if (inet_aton(address, &in)) {
- log_fn(LOG_DEBUG, "Using static address %s (%08X)", address, in.s_addr);
- return in.s_addr;
+ log_fn(LOG_DEBUG, "Using static address %s (%08X)", address,
+ ntohl(in.s_addr));
+ return ntohl(in.s_addr);
}
search.address = (char*)address;
ent = SPLAY_FIND(client_dns_tree, &client_dns_root, &search);
@@ -848,7 +849,7 @@ static uint32_t client_dns_lookup_entry(const char *address)
--client_dns_size;
return 0;
}
- in.s_addr = ent->addr;
+ in.s_addr = htonl(ent->addr);
log_fn(LOG_DEBUG, "Found cached entry for address %s: %s", address,
inet_ntoa(in));
return ent->addr;
@@ -865,9 +866,9 @@ static void client_dns_set_entry(const char *address, uint32_t val)
assert(val);
if (inet_aton(address, &in)) {
- if (in.s_addr == val)
+ if (ntohl(in.s_addr) == val)
return;
- in.s_addr = val;
+ in.s_addr = htonl(val);
log_fn(LOG_WARN,
"Trying to store incompatible cached value %s for static address %s",
inet_ntoa(in), address);
@@ -881,7 +882,7 @@ static void client_dns_set_entry(const char *address, uint32_t val)
ent->addr = val;
ent->expires = now+MAX_DNS_ENTRY_AGE;
} else {
- in.s_addr = val;
+ in.s_addr = htonl(val);
log_fn(LOG_DEBUG, "Caching result for address %s: %s", address,
inet_ntoa(in));
ent = tor_malloc(sizeof(struct client_dns_entry));
diff --git a/src/or/routers.c b/src/or/routers.c
index 00efba68e3..c25aa6eadb 100644
--- a/src/or/routers.c
+++ b/src/or/routers.c
@@ -996,7 +996,7 @@ static int router_add_exit_policy(routerinfo_t *router,
if (strcmp(address, "*") == 0) {
newe->addr = 0;
} else if (inet_aton(address, &in) != 0) {
- newe->addr = in.s_addr;
+ newe->addr = ntohl(in.s_addr);
} else {
log_fn(LOG_WARN, "Malformed IP %s in exit policy; rejecting.",
address);
@@ -1014,7 +1014,7 @@ static int router_add_exit_policy(routerinfo_t *router,
/* strtol handled the whole mask. */
newe->msk = ~((1<<(32-bits))-1);
} else if (inet_aton(mask, &in) != 0) {
- newe->msk = in.s_addr;
+ newe->msk = ntohl(in.s_addr);
} else {
log_fn(LOG_WARN, "Malformed mask %s on exit policy; rejecting.",
mask);
@@ -1033,9 +1033,9 @@ static int router_add_exit_policy(routerinfo_t *router,
}
}
- in.s_addr = newe->addr;
+ in.s_addr = htonl(newe->addr);
address = tor_strdup(inet_ntoa(in));
- in.s_addr = newe->msk;
+ in.s_addr = htonl(newe->msk);
log_fn(LOG_DEBUG,"%s %s/%s:%d",
newe->policy_type == EXIT_POLICY_REJECT ? "reject" : "accept",
address, inet_ntoa(in), newe->prt);
@@ -1106,7 +1106,7 @@ int router_compare_addr_to_exit_policy(uint32_t addr, uint16_t port,
}
}
if (match) {
- in.s_addr = addr;
+ in.s_addr = htonl(addr);
log_fn(LOG_INFO,"Address %s:%d matches exit policy '%s'",
inet_ntoa(in), port, tmpe->string);
if(tmpe->policy_type == EXIT_POLICY_ACCEPT)
@@ -1276,7 +1276,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
written = result;
for(tmpe=router->exit_policy; tmpe; tmpe=tmpe->next) {
- in.s_addr = tmpe->addr;
+ in.s_addr = htonl(tmpe->addr);
result = snprintf(s+written, maxlen-written, "%s %s",
tmpe->policy_type == EXIT_POLICY_ACCEPT ? "accept" : "reject",
tmpe->msk == 0 ? "*" : inet_ntoa(in));
@@ -1286,7 +1286,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
}
written += result;
if (tmpe->msk != 0xFFFFFFFFu) {
- in.s_addr = tmpe->msk;
+ in.s_addr = htonl(tmpe->msk);
result = snprintf(s+written, maxlen-written, "/%s", inet_ntoa(in));
if (result<0 || result+written > maxlen)
return -1;