aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-12-12 02:10:19 -0500
committerNick Mathewson <nickm@torproject.org>2009-12-12 02:10:19 -0500
commit9e6225ae1662e10f3e6c32af52736b60eb489b55 (patch)
tree58bd66dc3650837882fcea828c3c5817a15e449c
parent0c1b3070cfec670190636d74f97c2aaf0e521bdb (diff)
parentf1b7295b27ba1f472304f2931bb23df6884b64e6 (diff)
downloadtor-9e6225ae1662e10f3e6c32af52736b60eb489b55.tar
tor-9e6225ae1662e10f3e6c32af52736b60eb489b55.tar.gz
Merge commit 'sebastian/coverity'
-rw-r--r--src/common/crypto.c9
-rw-r--r--src/common/crypto.h2
-rw-r--r--src/or/config.c5
-rw-r--r--src/or/directory.c29
4 files changed, 22 insertions, 23 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 4d17a8f21..e996b48a1 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -427,10 +427,7 @@ crypto_create_init_cipher(const char *key, int encrypt_mode)
return NULL;
}
- if (crypto_cipher_set_key(crypto, key)) {
- crypto_log_errors(LOG_WARN, "setting symmetric key");
- goto error;
- }
+ crypto_cipher_set_key(crypto, key);
if (encrypt_mode)
r = crypto_cipher_encrypt_init_cipher(crypto);
@@ -1254,16 +1251,14 @@ crypto_cipher_generate_key(crypto_cipher_env_t *env)
/** Set the symmetric key for the cipher in <b>env</b> to the first
* CIPHER_KEY_LEN bytes of <b>key</b>. Does not initialize the cipher.
- * Return 0 on success, -1 on failure.
*/
-int
+void
crypto_cipher_set_key(crypto_cipher_env_t *env, const char *key)
{
tor_assert(env);
tor_assert(key);
memcpy(env->key, key, CIPHER_KEY_LEN);
- return 0;
}
/** Generate an initialization vector for our AES-CTR cipher; store it
diff --git a/src/common/crypto.h b/src/common/crypto.h
index d9adb16f8..239acb587 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -151,7 +151,7 @@ int crypto_pk_check_fingerprint_syntax(const char *s);
/* symmetric crypto */
int crypto_cipher_generate_key(crypto_cipher_env_t *env);
-int crypto_cipher_set_key(crypto_cipher_env_t *env, const char *key);
+void crypto_cipher_set_key(crypto_cipher_env_t *env, const char *key);
void crypto_cipher_generate_iv(char *iv_out);
int crypto_cipher_set_iv(crypto_cipher_env_t *env, const char *iv);
const char *crypto_cipher_get_key(crypto_cipher_env_t *env);
diff --git a/src/or/config.c b/src/or/config.c
index 416cbc130..deeda163b 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1575,7 +1575,10 @@ config_get_commandlines(int argc, char **argv, config_line_t **result)
*new = tor_malloc_zero(sizeof(config_line_t));
s = argv[i];
- while (*s == '-')
+ /* Each keyword may be prefixed with one or two dashes. */
+ if (*s == '-')
+ s++;
+ if (*s == '-')
s++;
(*new)->key = tor_strdup(expand_abbrev(&options_format, s, 1, 1));
diff --git a/src/or/directory.c b/src/or/directory.c
index 427f5d8c0..45483cce2 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1463,21 +1463,22 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
}
(void) skewed; /* skewed isn't used yet. */
- if (status_code == 503 && body_len < 16) {
- routerstatus_t *rs;
- trusted_dir_server_t *ds;
- log_info(LD_DIR,"Received http status code %d (%s) from server "
- "'%s:%d'. I'll try again soon.",
- status_code, escaped(reason), conn->_base.address,
- conn->_base.port);
- if ((rs = router_get_consensus_status_by_id(conn->identity_digest)))
- rs->last_dir_503_at = now;
- if ((ds = router_get_trusteddirserver_by_digest(conn->identity_digest)))
- ds->fake_status.last_dir_503_at = now;
+ if (status_code == 503) {
+ if (body_len < 16) {
+ routerstatus_t *rs;
+ trusted_dir_server_t *ds;
+ log_info(LD_DIR,"Received http status code %d (%s) from server "
+ "'%s:%d'. I'll try again soon.",
+ status_code, escaped(reason), conn->_base.address,
+ conn->_base.port);
+ if ((rs = router_get_consensus_status_by_id(conn->identity_digest)))
+ rs->last_dir_503_at = now;
+ if ((ds = router_get_trusteddirserver_by_digest(conn->identity_digest)))
+ ds->fake_status.last_dir_503_at = now;
- tor_free(body); tor_free(headers); tor_free(reason);
- return -1;
- } else if (status_code == 503) {
+ tor_free(body); tor_free(headers); tor_free(reason);
+ return -1;
+ }
/* XXXX022 Remove this once every server with bug 539 is obsolete. */
log_info(LD_DIR, "Server at '%s:%d' sent us a 503 response, but included "
"a body anyway. We'll pretend it gave us a 200.",