Merge commit 'sebastian/coverity'

This commit is contained in:
Nick Mathewson 2009-12-12 02:10:19 -05:00
commit 9e6225ae16
4 changed files with 22 additions and 23 deletions

View file

@ -427,10 +427,7 @@ crypto_create_init_cipher(const char *key, int encrypt_mode)
return NULL; return NULL;
} }
if (crypto_cipher_set_key(crypto, key)) { crypto_cipher_set_key(crypto, key);
crypto_log_errors(LOG_WARN, "setting symmetric key");
goto error;
}
if (encrypt_mode) if (encrypt_mode)
r = crypto_cipher_encrypt_init_cipher(crypto); 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 /** 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. * 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) crypto_cipher_set_key(crypto_cipher_env_t *env, const char *key)
{ {
tor_assert(env); tor_assert(env);
tor_assert(key); tor_assert(key);
memcpy(env->key, key, CIPHER_KEY_LEN); memcpy(env->key, key, CIPHER_KEY_LEN);
return 0;
} }
/** Generate an initialization vector for our AES-CTR cipher; store it /** Generate an initialization vector for our AES-CTR cipher; store it

View file

@ -151,7 +151,7 @@ int crypto_pk_check_fingerprint_syntax(const char *s);
/* symmetric crypto */ /* symmetric crypto */
int crypto_cipher_generate_key(crypto_cipher_env_t *env); 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); void crypto_cipher_generate_iv(char *iv_out);
int crypto_cipher_set_iv(crypto_cipher_env_t *env, const char *iv); int crypto_cipher_set_iv(crypto_cipher_env_t *env, const char *iv);
const char *crypto_cipher_get_key(crypto_cipher_env_t *env); const char *crypto_cipher_get_key(crypto_cipher_env_t *env);

View file

@ -1575,7 +1575,10 @@ config_get_commandlines(int argc, char **argv, config_line_t **result)
*new = tor_malloc_zero(sizeof(config_line_t)); *new = tor_malloc_zero(sizeof(config_line_t));
s = argv[i]; s = argv[i];
while (*s == '-') /* Each keyword may be prefixed with one or two dashes. */
if (*s == '-')
s++;
if (*s == '-')
s++; s++;
(*new)->key = tor_strdup(expand_abbrev(&options_format, s, 1, 1)); (*new)->key = tor_strdup(expand_abbrev(&options_format, s, 1, 1));

View file

@ -1463,21 +1463,22 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
} }
(void) skewed; /* skewed isn't used yet. */ (void) skewed; /* skewed isn't used yet. */
if (status_code == 503 && body_len < 16) { if (status_code == 503) {
routerstatus_t *rs; if (body_len < 16) {
trusted_dir_server_t *ds; routerstatus_t *rs;
log_info(LD_DIR,"Received http status code %d (%s) from server " trusted_dir_server_t *ds;
"'%s:%d'. I'll try again soon.", log_info(LD_DIR,"Received http status code %d (%s) from server "
status_code, escaped(reason), conn->_base.address, "'%s:%d'. I'll try again soon.",
conn->_base.port); status_code, escaped(reason), conn->_base.address,
if ((rs = router_get_consensus_status_by_id(conn->identity_digest))) conn->_base.port);
rs->last_dir_503_at = now; if ((rs = router_get_consensus_status_by_id(conn->identity_digest)))
if ((ds = router_get_trusteddirserver_by_digest(conn->identity_digest))) rs->last_dir_503_at = now;
ds->fake_status.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); tor_free(body); tor_free(headers); tor_free(reason);
return -1; return -1;
} else if (status_code == 503) { }
/* XXXX022 Remove this once every server with bug 539 is obsolete. */ /* 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 " 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.", "a body anyway. We'll pretend it gave us a 200.",