mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-13 06:33:44 +01:00
Tidy status handling in rendservice.c
We had some code to fix up the 'status' return value to -1 on error if it wasn't set, but it was unreachable because our code was correct. Tweak this by initializing status to -1, and then only setting it to 0 on success. Also add a goto which was missing: its absence was harmless. [CID 718614, 718616]
This commit is contained in:
parent
a8cc41a230
commit
d31bcc4b23
@ -1646,6 +1646,7 @@ rend_service_begin_parse_intro(const uint8_t *request,
|
|||||||
err:
|
err:
|
||||||
rend_service_free_intro(rv);
|
rend_service_free_intro(rv);
|
||||||
rv = NULL;
|
rv = NULL;
|
||||||
|
|
||||||
if (err_msg_out && !err_msg) {
|
if (err_msg_out && !err_msg) {
|
||||||
tor_asprintf(&err_msg,
|
tor_asprintf(&err_msg,
|
||||||
"unknown INTRODUCE%d error",
|
"unknown INTRODUCE%d error",
|
||||||
@ -1981,7 +1982,7 @@ rend_service_decrypt_intro(
|
|||||||
char service_id[REND_SERVICE_ID_LEN_BASE32+1];
|
char service_id[REND_SERVICE_ID_LEN_BASE32+1];
|
||||||
ssize_t key_len;
|
ssize_t key_len;
|
||||||
uint8_t buf[RELAY_PAYLOAD_SIZE];
|
uint8_t buf[RELAY_PAYLOAD_SIZE];
|
||||||
int result, status = 0;
|
int result, status = -1;
|
||||||
|
|
||||||
if (!intro || !key) {
|
if (!intro || !key) {
|
||||||
if (err_msg_out) {
|
if (err_msg_out) {
|
||||||
@ -2060,6 +2061,8 @@ rend_service_decrypt_intro(
|
|||||||
intro->plaintext = tor_malloc(intro->plaintext_len);
|
intro->plaintext = tor_malloc(intro->plaintext_len);
|
||||||
memcpy(intro->plaintext, buf, intro->plaintext_len);
|
memcpy(intro->plaintext, buf, intro->plaintext_len);
|
||||||
|
|
||||||
|
status = 0;
|
||||||
|
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
@ -2068,7 +2071,6 @@ rend_service_decrypt_intro(
|
|||||||
"unknown INTRODUCE%d error decrypting encrypted part",
|
"unknown INTRODUCE%d error decrypting encrypted part",
|
||||||
intro ? (int)(intro->type) : -1);
|
intro ? (int)(intro->type) : -1);
|
||||||
}
|
}
|
||||||
if (status >= 0) status = -1;
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (err_msg_out) *err_msg_out = err_msg;
|
if (err_msg_out) *err_msg_out = err_msg;
|
||||||
@ -2095,7 +2097,7 @@ rend_service_parse_intro_plaintext(
|
|||||||
char *err_msg = NULL;
|
char *err_msg = NULL;
|
||||||
ssize_t ver_specific_len, ver_invariant_len;
|
ssize_t ver_specific_len, ver_invariant_len;
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
int status = 0;
|
int status = -1;
|
||||||
|
|
||||||
if (!intro) {
|
if (!intro) {
|
||||||
if (err_msg_out) {
|
if (err_msg_out) {
|
||||||
@ -2154,6 +2156,7 @@ rend_service_parse_intro_plaintext(
|
|||||||
(int)(intro->type),
|
(int)(intro->type),
|
||||||
(long)(intro->plaintext_len));
|
(long)(intro->plaintext_len));
|
||||||
status = -6;
|
status = -6;
|
||||||
|
goto err;
|
||||||
} else {
|
} else {
|
||||||
memcpy(intro->rc,
|
memcpy(intro->rc,
|
||||||
intro->plaintext + ver_specific_len,
|
intro->plaintext + ver_specific_len,
|
||||||
@ -2166,6 +2169,7 @@ rend_service_parse_intro_plaintext(
|
|||||||
/* Flag it as being fully parsed */
|
/* Flag it as being fully parsed */
|
||||||
intro->parsed = 1;
|
intro->parsed = 1;
|
||||||
|
|
||||||
|
status = 0;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
@ -2174,7 +2178,6 @@ rend_service_parse_intro_plaintext(
|
|||||||
"unknown INTRODUCE%d error parsing encrypted part",
|
"unknown INTRODUCE%d error parsing encrypted part",
|
||||||
intro ? (int)(intro->type) : -1);
|
intro ? (int)(intro->type) : -1);
|
||||||
}
|
}
|
||||||
if (status >= 0) status = -1;
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (err_msg_out) *err_msg_out = err_msg;
|
if (err_msg_out) *err_msg_out = err_msg;
|
||||||
|
Loading…
Reference in New Issue
Block a user