aboutsummaryrefslogtreecommitdiff
path: root/src/or/rendservice.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-08-21 10:49:01 -0400
committerNick Mathewson <nickm@torproject.org>2014-08-22 12:23:01 -0400
commitd31bcc4b235c98ffb1b9a2c4fead7fb61d71fe75 (patch)
tree913b3fbc45c84e14f4a343f7507672320521cbfe /src/or/rendservice.c
parenta8cc41a2303b9f6c8cffa6b69cd759760d91226e (diff)
downloadtor-d31bcc4b235c98ffb1b9a2c4fead7fb61d71fe75.tar.gz
tor-d31bcc4b235c98ffb1b9a2c4fead7fb61d71fe75.zip
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]
Diffstat (limited to 'src/or/rendservice.c')
-rw-r--r--src/or/rendservice.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 0633c35fbb..749d6fa880 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -1646,6 +1646,7 @@ rend_service_begin_parse_intro(const uint8_t *request,
err:
rend_service_free_intro(rv);
rv = NULL;
+
if (err_msg_out && !err_msg) {
tor_asprintf(&err_msg,
"unknown INTRODUCE%d error",
@@ -1981,7 +1982,7 @@ rend_service_decrypt_intro(
char service_id[REND_SERVICE_ID_LEN_BASE32+1];
ssize_t key_len;
uint8_t buf[RELAY_PAYLOAD_SIZE];
- int result, status = 0;
+ int result, status = -1;
if (!intro || !key) {
if (err_msg_out) {
@@ -2060,6 +2061,8 @@ rend_service_decrypt_intro(
intro->plaintext = tor_malloc(intro->plaintext_len);
memcpy(intro->plaintext, buf, intro->plaintext_len);
+ status = 0;
+
goto done;
err:
@@ -2068,7 +2071,6 @@ rend_service_decrypt_intro(
"unknown INTRODUCE%d error decrypting encrypted part",
intro ? (int)(intro->type) : -1);
}
- if (status >= 0) status = -1;
done:
if (err_msg_out) *err_msg_out = err_msg;
@@ -2095,7 +2097,7 @@ rend_service_parse_intro_plaintext(
char *err_msg = NULL;
ssize_t ver_specific_len, ver_invariant_len;
uint8_t version;
- int status = 0;
+ int status = -1;
if (!intro) {
if (err_msg_out) {
@@ -2154,6 +2156,7 @@ rend_service_parse_intro_plaintext(
(int)(intro->type),
(long)(intro->plaintext_len));
status = -6;
+ goto err;
} else {
memcpy(intro->rc,
intro->plaintext + ver_specific_len,
@@ -2166,6 +2169,7 @@ rend_service_parse_intro_plaintext(
/* Flag it as being fully parsed */
intro->parsed = 1;
+ status = 0;
goto done;
err:
@@ -2174,7 +2178,6 @@ rend_service_parse_intro_plaintext(
"unknown INTRODUCE%d error parsing encrypted part",
intro ? (int)(intro->type) : -1);
}
- if (status >= 0) status = -1;
done:
if (err_msg_out) *err_msg_out = err_msg;