Browse Source

Merge commit 'sebastian/coverity'

Nick Mathewson 15 years ago
parent
commit
9e6225ae16
4 changed files with 22 additions and 23 deletions
  1. 2 7
      src/common/crypto.c
  2. 1 1
      src/common/crypto.h
  3. 4 1
      src/or/config.c
  4. 15 14
      src/or/directory.c

+ 2 - 7
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

+ 1 - 1
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);

+ 4 - 1
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));

+ 15 - 14
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.",