mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Do not replace old directory if new one is invalid
svn:r272
This commit is contained in:
parent
afc0eb2c71
commit
b58939745e
@ -524,7 +524,7 @@ int router_get_list_from_string(char *s)
|
|||||||
int router_get_list_from_string_impl(char *s, directory_t **dest) {
|
int router_get_list_from_string_impl(char *s, directory_t **dest) {
|
||||||
directory_token_t tok;
|
directory_token_t tok;
|
||||||
if (router_get_next_token(&s, &tok)) {
|
if (router_get_next_token(&s, &tok)) {
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
return router_get_list_from_string_tok(&s, dest, &tok);
|
return router_get_list_from_string_tok(&s, dest, &tok);
|
||||||
}
|
}
|
||||||
@ -557,6 +557,7 @@ int router_get_dir_from_string_impl(char *s, directory_t **dest,
|
|||||||
directory_token_t tok;
|
directory_token_t tok;
|
||||||
char digest[20];
|
char digest[20];
|
||||||
char signed_digest[128];
|
char signed_digest[128];
|
||||||
|
directory_t *new_dir = NULL;
|
||||||
|
|
||||||
#define NEXT_TOK() \
|
#define NEXT_TOK() \
|
||||||
do { \
|
do { \
|
||||||
@ -584,7 +585,7 @@ int router_get_dir_from_string_impl(char *s, directory_t **dest,
|
|||||||
TOK_IS(K_SERVER_SOFTWARE, "server-software");
|
TOK_IS(K_SERVER_SOFTWARE, "server-software");
|
||||||
|
|
||||||
NEXT_TOK();
|
NEXT_TOK();
|
||||||
if (router_get_list_from_string_tok(&s, dest, &tok))
|
if (router_get_list_from_string_tok(&s, &new_dir, &tok))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
TOK_IS(K_DIRECTORY_SIGNATURE, "directory-signature");
|
TOK_IS(K_DIRECTORY_SIGNATURE, "directory-signature");
|
||||||
@ -608,6 +609,10 @@ int router_get_dir_from_string_impl(char *s, directory_t **dest,
|
|||||||
NEXT_TOK();
|
NEXT_TOK();
|
||||||
TOK_IS(_EOF, "end of directory");
|
TOK_IS(_EOF, "end of directory");
|
||||||
|
|
||||||
|
if (*dest)
|
||||||
|
directory_free(*dest);
|
||||||
|
*dest = new_dir;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#undef NEXT_TOK
|
#undef NEXT_TOK
|
||||||
#undef TOK_IS
|
#undef TOK_IS
|
||||||
@ -655,7 +660,8 @@ static int router_get_list_from_string_tok(char **s, directory_t **dest,
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
static int
|
|
||||||
|
int
|
||||||
router_resolve(routerinfo_t *router)
|
router_resolve(routerinfo_t *router)
|
||||||
{
|
{
|
||||||
struct hostent *rent;
|
struct hostent *rent;
|
||||||
|
Loading…
Reference in New Issue
Block a user