mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +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
|
* 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
|
* containing the onion address without the .onion part. On error, address_out
|
||||||
* is untouched. */
|
* 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_helper_add_service(int hs_version,
|
||||||
add_onion_secret_key_t *pk,
|
add_onion_secret_key_t *pk,
|
||||||
smartlist_t *port_cfgs, int max_streams,
|
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")) {
|
} else if (!strcasecmp(arg->key, "ClientAuthV3")) {
|
||||||
hs_service_authorized_client_t *client_v3 =
|
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) {
|
if (!client_v3) {
|
||||||
control_write_endreply(conn, 512, "Cannot decode v3 client auth key");
|
control_write_endreply(conn, 512, "Cannot decode v3 client auth key");
|
||||||
goto out;
|
goto out;
|
||||||
@ -1926,6 +1926,7 @@ handle_control_add_onion(control_connection_t *conn,
|
|||||||
auth_clients, auth_clients_v3, &service_id);
|
auth_clients, auth_clients_v3, &service_id);
|
||||||
port_cfgs = NULL; /* port_cfgs is now owned by the rendservice code. */
|
port_cfgs = NULL; /* port_cfgs is now owned by the rendservice code. */
|
||||||
auth_clients = NULL; /* so is auth_clients */
|
auth_clients = NULL; /* so is auth_clients */
|
||||||
|
auth_clients_v3 = NULL; /* so is auth_clients_v3 */
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case RSAE_OKAY:
|
case RSAE_OKAY:
|
||||||
{
|
{
|
||||||
|
@ -103,17 +103,6 @@ STATIC control_cmd_args_t *control_cmd_parse_args(
|
|||||||
size_t body_len,
|
size_t body_len,
|
||||||
const char *body,
|
const char *body,
|
||||||
char **error_out);
|
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) */
|
#endif /* defined(CONTROL_CMD_PRIVATE) */
|
||||||
|
|
||||||
|
@ -1119,7 +1119,7 @@ client_filename_is_valid(const char *filename)
|
|||||||
*
|
*
|
||||||
* Return the key on success, return NULL, otherwise. */
|
* Return the key on success, return NULL, otherwise. */
|
||||||
hs_service_authorized_client_t *
|
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;
|
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
|
* and end up in trouble when copying the decoded key into a fixed length
|
||||||
* buffer. */
|
* buffer. */
|
||||||
if (strlen(key_str) != BASE32_NOPAD_LEN(CURVE25519_PUBKEY_LEN)) {
|
if (strlen(key_str) != BASE32_NOPAD_LEN(CURVE25519_PUBKEY_LEN)) {
|
||||||
if (log) {
|
log_fn(severity, LD_REND, "Client authorization encoded base32 public key "
|
||||||
log_warn(LD_REND, "Client authorization encoded base32 public key "
|
"length is invalid: %s", key_str);
|
||||||
"length is invalid: %s", key_str);
|
|
||||||
}
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1140,10 +1138,8 @@ parse_authorized_client_key(const char *key_str, bool log)
|
|||||||
sizeof(client->client_pk.public_key),
|
sizeof(client->client_pk.public_key),
|
||||||
key_str, strlen(key_str)) !=
|
key_str, strlen(key_str)) !=
|
||||||
sizeof(client->client_pk.public_key)) {
|
sizeof(client->client_pk.public_key)) {
|
||||||
if (log) {
|
log_fn(severity, LD_REND, "Client authorization public key cannot be "
|
||||||
log_warn(LD_REND, "Client authorization public key cannot be decoded: "
|
"decoded: %s", key_str);
|
||||||
"%s", key_str);
|
|
||||||
}
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1151,7 +1147,7 @@ parse_authorized_client_key(const char *key_str, bool log)
|
|||||||
|
|
||||||
err:
|
err:
|
||||||
if (client != NULL) {
|
if (client != NULL) {
|
||||||
tor_free(client);
|
service_authorized_client_free(client);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1202,7 +1198,7 @@ parse_authorized_client(const char *client_key_str)
|
|||||||
goto err;
|
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;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3759,11 +3755,8 @@ hs_service_add_ephemeral(ed25519_secret_key_t *sk, smartlist_t *ports,
|
|||||||
|
|
||||||
if (auth_clients_v3) {
|
if (auth_clients_v3) {
|
||||||
if (service->config.clients == NULL) {
|
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
|
/* 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);
|
void hs_service_circuit_cleanup_on_close(const circuit_t *circ);
|
||||||
|
|
||||||
hs_service_authorized_client_t *
|
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
|
void
|
||||||
service_authorized_client_free_(hs_service_authorized_client_t *client);
|
service_authorized_client_free_(hs_service_authorized_client_t *client);
|
||||||
|
Loading…
Reference in New Issue
Block a user