Loading src/common/util.h +2 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,8 @@ struct timeval { #define CONFIG_LEGAL_FILENAME_CHARACTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/ " #endif #define HEX_CHARACTERS "0123456789ABCDEFabcdef" size_t strlcat(char *dst, const char *src, size_t siz); size_t strlcpy(char *dst, const char *src, size_t siz); Loading src/or/config.c +4 −0 Original line number Diff line number Diff line Loading @@ -735,6 +735,10 @@ int getconfig(int argc, char **argv, or_options_t *options) { log_fn(LOG_WARN, "Nickname '%s' contains illegal characters.", options->Nickname); result = -1; } if (strlen(options->Nickname) == 0) { log_fn(LOG_WARN, "Nickname must have at least one character"); result = -1; } if (strlen(options->Nickname) > MAX_NICKNAME_LEN) { log_fn(LOG_WARN, "Nickname '%s' has more than %d characters.", options->Nickname, MAX_NICKNAME_LEN); Loading src/or/or.h +2 −0 Original line number Diff line number Diff line Loading @@ -1386,6 +1386,8 @@ int router_is_me(routerinfo_t *router); int router_rebuild_descriptor(void); int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, crypto_pk_env_t *ident_key); int is_legal_nickname(const char *s); int is_legal_nickname_or_hexdigest(const char *s); /********************************* routerlist.c ***************************/ Loading src/or/router.c +20 −0 Original line number Diff line number Diff line Loading @@ -774,6 +774,26 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, return written+1; } int is_legal_nickname(const char *s) { size_t len; tor_assert(s); len = strlen(s); return len > 0 && len <= MAX_NICKNAME_LEN && strspn(s,LEGAL_NICKNAME_CHARACTERS)==len; } int is_legal_nickname_or_hexdigest(const char *s) { size_t len; tor_assert(s); if (*s!='$') return is_legal_nickname(s); len = strlen(s); return len == HEX_DIGEST_LEN+1 && strspn(s+1,HEX_CHARACTERS)==len-1; } /* Local Variables: mode:c Loading src/or/routerparse.c +2 −7 Original line number Diff line number Diff line Loading @@ -681,13 +681,8 @@ routerinfo_t *router_parse_entry_from_string(const char *s, if (tok->n_args == 2 || tok->n_args == 5 || tok->n_args == 6) { router->nickname = tor_strdup(tok->args[0]); if (strlen(router->nickname) > MAX_NICKNAME_LEN) { log_fn(LOG_WARN,"Router nickname too long."); goto err; } if (strspn(router->nickname, LEGAL_NICKNAME_CHARACTERS) != strlen(router->nickname)) { log_fn(LOG_WARN, "Router nickname contains illegal characters."); if (!is_legal_nickname(router->nickname)) { log_fn(LOG_WARN,"Router nickname is invalid"); goto err; } router->address = tor_strdup(tok->args[1]); Loading Loading
src/common/util.h +2 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,8 @@ struct timeval { #define CONFIG_LEGAL_FILENAME_CHARACTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/ " #endif #define HEX_CHARACTERS "0123456789ABCDEFabcdef" size_t strlcat(char *dst, const char *src, size_t siz); size_t strlcpy(char *dst, const char *src, size_t siz); Loading
src/or/config.c +4 −0 Original line number Diff line number Diff line Loading @@ -735,6 +735,10 @@ int getconfig(int argc, char **argv, or_options_t *options) { log_fn(LOG_WARN, "Nickname '%s' contains illegal characters.", options->Nickname); result = -1; } if (strlen(options->Nickname) == 0) { log_fn(LOG_WARN, "Nickname must have at least one character"); result = -1; } if (strlen(options->Nickname) > MAX_NICKNAME_LEN) { log_fn(LOG_WARN, "Nickname '%s' has more than %d characters.", options->Nickname, MAX_NICKNAME_LEN); Loading
src/or/or.h +2 −0 Original line number Diff line number Diff line Loading @@ -1386,6 +1386,8 @@ int router_is_me(routerinfo_t *router); int router_rebuild_descriptor(void); int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, crypto_pk_env_t *ident_key); int is_legal_nickname(const char *s); int is_legal_nickname_or_hexdigest(const char *s); /********************************* routerlist.c ***************************/ Loading
src/or/router.c +20 −0 Original line number Diff line number Diff line Loading @@ -774,6 +774,26 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, return written+1; } int is_legal_nickname(const char *s) { size_t len; tor_assert(s); len = strlen(s); return len > 0 && len <= MAX_NICKNAME_LEN && strspn(s,LEGAL_NICKNAME_CHARACTERS)==len; } int is_legal_nickname_or_hexdigest(const char *s) { size_t len; tor_assert(s); if (*s!='$') return is_legal_nickname(s); len = strlen(s); return len == HEX_DIGEST_LEN+1 && strspn(s+1,HEX_CHARACTERS)==len-1; } /* Local Variables: mode:c Loading
src/or/routerparse.c +2 −7 Original line number Diff line number Diff line Loading @@ -681,13 +681,8 @@ routerinfo_t *router_parse_entry_from_string(const char *s, if (tok->n_args == 2 || tok->n_args == 5 || tok->n_args == 6) { router->nickname = tor_strdup(tok->args[0]); if (strlen(router->nickname) > MAX_NICKNAME_LEN) { log_fn(LOG_WARN,"Router nickname too long."); goto err; } if (strspn(router->nickname, LEGAL_NICKNAME_CHARACTERS) != strlen(router->nickname)) { log_fn(LOG_WARN, "Router nickname contains illegal characters."); if (!is_legal_nickname(router->nickname)) { log_fn(LOG_WARN,"Router nickname is invalid"); goto err; } router->address = tor_strdup(tok->args[1]); Loading