summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-09-23 22:18:50 +0000
committerRoger Dingledine <arma@torproject.org>2004-09-23 22:18:50 +0000
commitfa0a1ec49ff9cd93730e81f5eb4112624b5c0443 (patch)
tree3beb7863d2e6cf91a3c8b4a632624c423c5edfe2
parent09f450104ae87cadf71e4eca982fc35446c6af30 (diff)
downloadtor-fa0a1ec49ff9cd93730e81f5eb4112624b5c0443.tar.gz
tor-fa0a1ec49ff9cd93730e81f5eb4112624b5c0443.zip
cleanup: use strcmpstart() in more places
svn:r2372
-rw-r--r--src/or/circuituse.c2
-rw-r--r--src/or/connection_edge.c2
-rw-r--r--src/or/connection_or.c2
-rw-r--r--src/or/directory.c4
-rw-r--r--src/or/router.c2
-rw-r--r--src/or/routerparse.c2
-rw-r--r--src/or/test.c3
7 files changed, 8 insertions, 9 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 9173bc09a0..549993a7c1 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -79,7 +79,7 @@ static int circuit_is_acceptable(circuit_t *circ,
/* 0.0.7 servers and earlier don't support DNS resolution. There are no
* ORs running code before 0.0.7, so we only worry about 0.0.7. Once all
* servers are running 0.0.8, remove this check. */
- if (!strncmp(exitrouter->platform, "Tor 0.0.7", 9))
+ if (!strcmpstart(exitrouter->platform, "Tor 0.0.7"))
return 0;
} else if(purpose == CIRCUIT_PURPOSE_C_GENERAL) {
if(!connection_ap_can_use_exit(conn, exitrouter)) {
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index d1bf109f22..1b2279c93d 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -957,7 +957,7 @@ int connection_ap_can_use_exit(connection_t *conn, routerinfo_t *exit)
/* 0.0.7 servers and earlier don't support DNS resolution. There are no
* ORs running code before 0.0.7, so we only worry about 0.0.7. Once all
* servers are running 0.0.8, remove this check. XXX */
- return strncmp(exit->platform, "Tor 0.0.7", 9) ? 1 : 0;
+ return strcmpstart(exit->platform, "Tor 0.0.7") ? 1 : 0;
}
addr = client_dns_lookup_entry(conn->socks_request->address);
if(router_compare_addr_to_exit_policy(addr,
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 2d18e90e26..5272b4a6c6 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -218,7 +218,7 @@ int connection_tls_start_handshake(connection_t *conn, int receiving) {
him = router_get_by_digest(conn->identity_digest);
me = router_get_my_routerinfo();
- if(him && !strncmp(him->platform, "Tor 0.0.7", 9) &&
+ if(him && !strcmpstart(him->platform, "Tor 0.0.7") &&
(!me || !me->is_verified)) {
log_fn(LOG_INFO,"He's running 0.0.7, and I'm unverified. Acting like OP.");
use_no_cert = 1;
diff --git a/src/or/directory.c b/src/or/directory.c
index 872f7b7cd7..e738796e97 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -623,7 +623,7 @@ directory_handle_command_get(connection_t *conn, char *headers,
return 0;
}
- if(!strncmp(url,rend_fetch_url,strlen(rend_fetch_url))) {
+ if(!strcmpstart(url,rend_fetch_url)) {
/* rendezvous descriptor fetch */
const char *descp;
int desc_len;
@@ -709,7 +709,7 @@ directory_handle_command_post(connection_t *conn, char *headers,
return 0;
}
- if(!strncmp(url,rend_publish_string,strlen(rend_publish_string))) {
+ if(!strcmpstart(url,rend_publish_string)) {
/* rendezvous descriptor post */
if(rend_cache_store(body, body_len) < 0)
connection_write_to_buf(answer400, strlen(answer400), conn);
diff --git a/src/or/router.c b/src/or/router.c
index 8eb483643e..ce564ff97d 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -397,7 +397,7 @@ void router_retry_connections(void) {
int router_is_clique_mode(routerinfo_t *router) {
if(router->is_trusted_dir)
return 1;
- if(!strncmp(router->platform, "Tor 0.0.7", 9))
+ if(!strcmpstart(router->platform, "Tor 0.0.7"))
return 1;
return 0;
}
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index c970851b91..fdc34f205f 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -591,7 +591,7 @@ router_parse_list_from_string(const char **s, routerlist_t **dest,
while (1) {
*s = eat_whitespace(*s);
/* Don't start parsing the rest of *s unless it contains a router. */
- if (strncmp(*s, "router ", 7)!=0)
+ if (strcmpstart(*s, "router ")!=0)
break;
if ((end = strstr(*s+1, "\nrouter "))) {
end++;
diff --git a/src/or/test.c b/src/or/test.c
index 0ca1ab290a..3546cbc2aa 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -869,8 +869,7 @@ test_dir_format()
bw_lines = rep_hist_get_bandwidth_lines();
test_assert(bw_lines);
- test_assert(!strncmp(bw_lines, "opt write-history ",
- strlen("opt write-history ")));
+ test_assert(!strcmpstart(bw_lines, "opt write-history "));
test_assert(!crypto_pk_write_public_key_to_string(pk1, &pk1_str,
&pk1_str_len));