static void
crypto_log_errors(int severity, const char *doing)
{
- int err;
+ unsigned int err;
const char *msg, *lib, *func;
while ((err = ERR_get_error()) != 0) {
msg = (const char*)ERR_reason_error_string(err);
RAND_screen();
return 0;
#else
- static char *filenames[] = {
+ static const char *filenames[] = {
"/dev/srandom", "/dev/urandom", "/dev/random", NULL
};
int fd;
n += r;
}
- n += tor_vsnprintf(buf+n,buf_len-n,format,ap);
- if(n < 0) {
+ r = tor_vsnprintf(buf+n,buf_len-n,format,ap);
+ if(r < 0) {
n = buf_len-2;
strlcpy(buf+buf_len-TRUNCATED_STR_LEN-1, TRUNCATED_STR,
buf_len-(buf_len-TRUNCATED_STR_LEN-1));
+ } else {
+ n += r;
}
buf[n]='\n';
buf[n+1]='\0';
goto error;
if ((nid = OBJ_txt2nid("organizationName")) == NID_undef) goto error;
if (!(X509_NAME_add_entry_by_NID(name, nid, MBSTRING_ASC,
- "TOR", -1, -1, 0))) goto error;
+ (char*)"TOR", -1, -1, 0))) goto error;
if ((nid = OBJ_txt2nid("commonName")) == NID_undef) goto error;
if (!(X509_NAME_add_entry_by_NID(name, nid, MBSTRING_ASC,
(char*)cname, -1, -1, 0))) goto error;
goto error;
if ((nid = OBJ_txt2nid("organizationName")) == NID_undef) goto error;
if (!(X509_NAME_add_entry_by_NID(name_issuer, nid, MBSTRING_ASC,
- "TOR", -1, -1, 0))) goto error;
+ (char*)"TOR", -1, -1, 0))) goto error;
if ((nid = OBJ_txt2nid("commonName")) == NID_undef) goto error;
if (!(X509_NAME_add_entry_by_NID(name_issuer, nid, MBSTRING_ASC,
(char*)cname_sign, -1, -1, 0))) goto error;
char buf[1024];
char *s = buf;
struct crypt_path_t *hop;
- char *states[] = {"closed", "waiting for keys", "open"};
+ const char *states[] = {"closed", "waiting for keys", "open"};
routerinfo_t *router;
tor_assert(CIRCUIT_IS_ORIGIN(circ));
tor_assert(circ->cpath);
*/
static void
circuit_dump_details(int severity, circuit_t *circ, int poll_index,
- char *type, int this_circid, int other_circid) {
+ const char *type, int this_circid, int other_circid) {
struct crypt_path_t *hop;
log(severity,"Conn %d has %s circuit: circID %d (other side %d), state %d (%s), born %d",
poll_index, type, this_circid, other_circid, circ->state,
circuit_t *global_circuitlist=NULL;
/** Array of strings to make circ-\>state human-readable */
-char *circuit_state_to_string[] = {
+const char *circuit_state_to_string[] = {
"doing handshakes", /* 0 */
"processing the onion", /* 1 */
"connecting to firsthop", /* 2 */
/* An abbreviation for a configuration option allowed on the command line */
typedef struct config_abbrev_t {
- char *abbreviated;
- char *full;
+ const char *abbreviated;
+ const char *full;
int commandline_only;
} config_abbrev_t;
PLURAL(RendNode),
PLURAL(RendExcludeNode),
{ "l", "LogLevel" , 1},
- { NULL, NULL },
+ { NULL, NULL , 0},
};
#undef PLURAL
/* A variable allowed in the configuration file or on the command line */
typedef struct config_var_t {
- char *name; /**< The full keyword (case insensitive) */
+ const char *name; /**< The full keyword (case insensitive) */
config_type_t type; /**< How to interpret the type and turn it into a value */
off_t var_offset; /**< Offset of the corresponding member of or_options_t */
} config_var_t;
options->SocksPort = 9050;
options->AllowUnverifiedNodes = smartlist_create();
- smartlist_add(options->AllowUnverifiedNodes, "middle");
- smartlist_add(options->AllowUnverifiedNodes, "rendezvous");
+ smartlist_add(options->AllowUnverifiedNodes, tor_strdup("middle"));
+ smartlist_add(options->AllowUnverifiedNodes, tor_strdup("rendezvous"));
config_free_lines(options->ExitPolicy);
options->ExitPolicy = NULL;
smartlist_free(options->FirewallPorts);
options->FirewallPorts = NULL;
}
+ if (options->AllowUnverifiedNodes) {
+ SMARTLIST_FOREACH(options->AllowUnverifiedNodes, char *, cp, tor_free(cp));
+ smartlist_free(options->AllowUnverifiedNodes);
+ options->AllowUnverifiedNodes = NULL;
+ }
}
/** Set <b>options</b> to hold reasonable defaults for most options.
extern int shutting_down; /* whether we should refuse new connections */
/** Array of strings to make conn-\>type human-readable. */
-char *conn_type_to_string[] = {
+const char *conn_type_to_string[] = {
"", /* 0 */
"OP listener", /* 1 */
"OP", /* 2 */
};
/** Array of string arrays to make {conn-\>type,conn-\>state} human-readable. */
-char *conn_state_to_string[][_CONN_TYPE_MAX+1] = {
+const char *conn_state_to_string[][_CONN_TYPE_MAX+1] = {
{ NULL }, /* no type associated with 0 */
{ NULL }, /* op listener, obsolete */
{ NULL }, /* op, obsolete */
#include "tree.h"
extern or_options_t options; /* command-line and config-file options */
-extern char *conn_state_to_string[][_CONN_TYPE_MAX+1]; /* from connection.c */
static struct exit_policy_t *socks_policy = NULL;
char hoststring[128];
char url[128];
int use_newer = 0;
- char *httpcommand = NULL;
+ const char *httpcommand = NULL;
tor_assert(conn);
tor_assert(conn->type == CONN_TYPE_DIR);
/********* START VARIABLES **********/
-/* declared in connection.c */
-extern char *conn_state_to_string[][_CONN_TYPE_MAX+1];
-
or_options_t options; /**< Command-line and config-file options. */
int global_read_bucket; /**< Max number of bytes I can read this second. */
int global_write_bucket; /**< Max number of bytes I can write this second. */
int marked_for_close; /**< Boolean: should we close this conn on the next
* iteration of the main loop?
*/
- char *marked_for_close_file; /**< For debugging: in which file were we marked
- * for close? */
+ const char *marked_for_close_file; /**< For debugging: in which file were
+ * we marked for close? */
int hold_open_until_flushed; /**< Despite this connection's being marked
* for close, do we flush it before closing it?
*/
int marked_for_close; /**< Should we close this circuit at the end of the
* main loop? */
- char *marked_for_close_file; /**< For debugging: in which file was this
- * circuit marked for close? */
+ const char *marked_for_close_file; /**< For debugging: in which file was this
+ * circuit marked for close? */
/** The IPv4 address of the OR that is next in this circuit. */
uint32_t n_addr;
/********************************* circuitlist.c ***********************/
-extern char *circuit_state_to_string[];
+extern const char *circuit_state_to_string[];
void circuit_close_all_marked(void);
circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn);
void circuit_free_cpath_node(crypt_path_t *victim);
#define CONN_TYPE_TO_STRING(t) (((t) < _CONN_TYPE_MIN || (t) > _CONN_TYPE_MAX) ? \
"Unknown" : conn_type_to_string[(t)])
-extern char *conn_type_to_string[];
-extern char *conn_state_to_string[][_CONN_TYPE_MAX+1];
+extern const char *conn_type_to_string[];
+extern const char *conn_state_to_string[][_CONN_TYPE_MAX+1];
connection_t *connection_new(int type);
void connection_free(connection_t *conn);
int router_nickname_matches(routerinfo_t *router, const char *nickname);
int router_is_unreliable_router(routerinfo_t *router, int need_uptime, int need_bw);
routerinfo_t *routerlist_sl_choose_by_bandwidth(smartlist_t *sl);
-routerinfo_t *router_choose_random_node(char *preferred, char *excluded,
+routerinfo_t *router_choose_random_node(const char *preferred,
+ const char *excluded,
struct smartlist_t *excludedsmartlist,
int preferuptime, int preferbandwidth,
int allow_unverified, int strict);
/* Else, append the default exitpolicy. */
default_policy.key = NULL;
- default_policy.value = DEFAULT_EXIT_POLICY;
+ default_policy.value = (char*)DEFAULT_EXIT_POLICY;
default_policy.next = NULL;
config_parse_exit_policy(&default_policy, &router->exit_policy);
}
* available. If <b>strict</b> is true, never pick any node besides
* those in <b>preferred</b>.
*/
-routerinfo_t *router_choose_random_node(char *preferred, char *excluded,
+routerinfo_t *router_choose_random_node(const char *preferred,
+ const char *excluded,
smartlist_t *excludedsmartlist,
int preferuptime, int preferbandwidth,
int allow_unverified, int strict)
++cp;
if (strlen(cp) != HEX_DIGEST_LEN) {
log_fn(LOG_WARN, "Bad length (%d) on digest in router status entry (%s)",
- strlen(cp), s);
+ (int)strlen(cp), s);
return -1;
}
strlcpy(hexdigest, cp, sizeof(hexdigest));
size_t object_size; /**< Bytes in object_body */
char *object_body; /**< Contents of object, base64-decoded. */
crypto_pk_env_t *key; /**< For public keys only. */
- char *error; /**< For _ERR tokens only. */
+ const char *error; /**< For _ERR tokens only. */
} directory_token_t;
/* ********************************************************************** */
/** Table mapping keywords to token value and to argument rules. */
static struct {
- char *t; int v; arg_syntax s; obj_syntax os; where_syntax ws;
+ const char *t; int v; arg_syntax s; obj_syntax os; where_syntax ws;
} token_table[] = {
{ "accept", K_ACCEPT, ARGS, NO_OBJ, RTR_ONLY },
{ "directory-signature", K_DIRECTORY_SIGNATURE, ARGS, NEED_OBJ,DIR_ONLY},