mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
More logic corrections
This commit is contained in:
parent
be6db23d1d
commit
7d54734900
@ -1649,7 +1649,7 @@ handle_control_hspost(control_connection_t *conn,
|
||||
* On success (RSAE_OKAY), the address_out points to a newly allocated string
|
||||
* containing the onion address without the .onion part. On error, address_out
|
||||
* is untouched. */
|
||||
STATIC hs_service_add_ephemeral_status_t
|
||||
static hs_service_add_ephemeral_status_t
|
||||
add_onion_helper_add_service(int hs_version,
|
||||
add_onion_secret_key_t *pk,
|
||||
smartlist_t *port_cfgs, int max_streams,
|
||||
@ -1831,7 +1831,7 @@ handle_control_add_onion(control_connection_t *conn,
|
||||
}
|
||||
} else if (!strcasecmp(arg->key, "ClientAuthV3")) {
|
||||
hs_service_authorized_client_t *client_v3 =
|
||||
parse_authorized_client_key(arg->value, false);
|
||||
parse_authorized_client_key(arg->value, LOG_INFO);
|
||||
if (!client_v3) {
|
||||
control_write_endreply(conn, 512, "Cannot decode v3 client auth key");
|
||||
goto out;
|
||||
@ -1926,6 +1926,7 @@ handle_control_add_onion(control_connection_t *conn,
|
||||
auth_clients, auth_clients_v3, &service_id);
|
||||
port_cfgs = NULL; /* port_cfgs is now owned by the rendservice code. */
|
||||
auth_clients = NULL; /* so is auth_clients */
|
||||
auth_clients_v3 = NULL; /* so is auth_clients_v3 */
|
||||
switch (ret) {
|
||||
case RSAE_OKAY:
|
||||
{
|
||||
|
@ -103,17 +103,6 @@ STATIC control_cmd_args_t *control_cmd_parse_args(
|
||||
size_t body_len,
|
||||
const char *body,
|
||||
char **error_out);
|
||||
#ifdef TOR_UNIT_TESTS
|
||||
#include "feature/hs/hs_common.h"
|
||||
|
||||
STATIC hs_service_add_ephemeral_status_t
|
||||
add_onion_helper_add_service(int hs_version,
|
||||
add_onion_secret_key_t *pk,
|
||||
smartlist_t *port_cfgs, int max_streams,
|
||||
int max_streams_close_circuit, int auth_type,
|
||||
smartlist_t *auth_clients,
|
||||
smartlist_t *auth_clients_v3, char **address_out);
|
||||
#endif /* defined(TOR_UNIT_TESTS) */
|
||||
|
||||
#endif /* defined(CONTROL_CMD_PRIVATE) */
|
||||
|
||||
|
@ -1119,7 +1119,7 @@ client_filename_is_valid(const char *filename)
|
||||
*
|
||||
* Return the key on success, return NULL, otherwise. */
|
||||
hs_service_authorized_client_t *
|
||||
parse_authorized_client_key(const char *key_str, bool log)
|
||||
parse_authorized_client_key(const char *key_str, int severity)
|
||||
{
|
||||
hs_service_authorized_client_t *client = NULL;
|
||||
|
||||
@ -1128,10 +1128,8 @@ parse_authorized_client_key(const char *key_str, bool log)
|
||||
* and end up in trouble when copying the decoded key into a fixed length
|
||||
* buffer. */
|
||||
if (strlen(key_str) != BASE32_NOPAD_LEN(CURVE25519_PUBKEY_LEN)) {
|
||||
if (log) {
|
||||
log_warn(LD_REND, "Client authorization encoded base32 public key "
|
||||
"length is invalid: %s", key_str);
|
||||
}
|
||||
log_fn(severity, LD_REND, "Client authorization encoded base32 public key "
|
||||
"length is invalid: %s", key_str);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -1140,10 +1138,8 @@ parse_authorized_client_key(const char *key_str, bool log)
|
||||
sizeof(client->client_pk.public_key),
|
||||
key_str, strlen(key_str)) !=
|
||||
sizeof(client->client_pk.public_key)) {
|
||||
if (log) {
|
||||
log_warn(LD_REND, "Client authorization public key cannot be decoded: "
|
||||
"%s", key_str);
|
||||
}
|
||||
log_fn(severity, LD_REND, "Client authorization public key cannot be "
|
||||
"decoded: %s", key_str);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -1151,7 +1147,7 @@ parse_authorized_client_key(const char *key_str, bool log)
|
||||
|
||||
err:
|
||||
if (client != NULL) {
|
||||
tor_free(client);
|
||||
service_authorized_client_free(client);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -1202,7 +1198,7 @@ parse_authorized_client(const char *client_key_str)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if ((client = parse_authorized_client_key(pubkey_b32, true)) == NULL) {
|
||||
if ((client = parse_authorized_client_key(pubkey_b32, LOG_WARN)) == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -3759,11 +3755,8 @@ hs_service_add_ephemeral(ed25519_secret_key_t *sk, smartlist_t *ports,
|
||||
|
||||
if (auth_clients_v3) {
|
||||
if (service->config.clients == NULL) {
|
||||
service->config.clients = smartlist_new();
|
||||
service->config.clients = auth_clients_v3;
|
||||
}
|
||||
SMARTLIST_FOREACH(auth_clients_v3, hs_service_authorized_client_t *, c, {
|
||||
smartlist_add(service->config.clients, c);
|
||||
});
|
||||
}
|
||||
|
||||
/* Build the onion address for logging purposes but also the control port
|
||||
|
@ -390,7 +390,7 @@ void hs_service_dump_stats(int severity);
|
||||
void hs_service_circuit_cleanup_on_close(const circuit_t *circ);
|
||||
|
||||
hs_service_authorized_client_t *
|
||||
parse_authorized_client_key(const char *key_str, bool log);
|
||||
parse_authorized_client_key(const char *key_str, int severity);
|
||||
|
||||
void
|
||||
service_authorized_client_free_(hs_service_authorized_client_t *client);
|
||||
|
Loading…
Reference in New Issue
Block a user