[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Fix bytesex issues on in.s_addr
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv15512
Modified Files:
connection_edge.c routers.c
Log Message:
Fix bytesex issues on in.s_addr
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- connection_edge.c 17 Nov 2003 07:20:51 -0000 1.61
+++ connection_edge.c 17 Nov 2003 07:37:45 -0000 1.62
@@ -618,7 +618,7 @@
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 @@
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 @@
--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 @@
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 @@
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));
Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- routers.c 16 Nov 2003 17:15:40 -0000 1.92
+++ routers.c 17 Nov 2003 07:37:45 -0000 1.93
@@ -996,7 +996,7 @@
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 @@
/* 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 @@
}
}
- 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 @@
}
}
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 @@
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 @@
}
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;