mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
cleanup: use strcmpstart() in more places
svn:r2372
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
|
||||
+1
-2
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user