From 2412e0e4024325608b551f74140e449d2016916f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 6 Oct 2011 12:59:25 -0400 Subject: [PATCH 1/2] Check return of init_keys() ip_address_changed: fix Coverity CID 484 --- changes/cov484 | 4 ++++ src/or/main.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changes/cov484 diff --git a/changes/cov484 b/changes/cov484 new file mode 100644 index 000000000..33adbda18 --- /dev/null +++ b/changes/cov484 @@ -0,0 +1,4 @@ + o Minor bugfixes: + - Report any failure in init_keys() calls done because our IP address + has changed. Spotted by Coverity Scan. Bugfix on 0.1.1.4-alpha; + fixes CID 484. diff --git a/src/or/main.c b/src/or/main.c index 289d80550..c011c9b46 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1378,7 +1378,8 @@ ip_address_changed(int at_interface) if (at_interface) { if (! server) { /* Okay, change our keys. */ - init_keys(); + if (init_keys()<0) + log_warn(LD_GENERAL, "Unable to rotate keys after IP change!"); } } else { if (server) { From 246afc1b1ba8c81557307bfffa5291c91cc2c782 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 6 Oct 2011 13:02:50 -0400 Subject: [PATCH 2/2] Make internal error check for unrecognized digest algorithm more robust Fixes Coverity CID 479. --- changes/cov479 | 5 +++++ src/common/crypto.c | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 changes/cov479 diff --git a/changes/cov479 b/changes/cov479 new file mode 100644 index 000000000..afbaffc63 --- /dev/null +++ b/changes/cov479 @@ -0,0 +1,5 @@ + o Minor bugfixes: + - Fix internal bug-checking logic that was supposed to catch + failures in digest generation so that it will fail more robustly + if we ask for a nonexistent algorithm. Found by Coverity Scan. + Bugfix on 0.2.2.1-alpha; fixes Coverity CID 479. diff --git a/src/common/crypto.c b/src/common/crypto.c index 851f11bf3..235bd88ff 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -1663,6 +1663,10 @@ crypto_digest_get_digest(crypto_digest_env_t *digest, SHA256_Final(r, &tmpenv.d.sha2); break; default: + log_warn(LD_BUG, "Called with unknown algorithm %d", digest->algorithm); + /* If fragile_assert is not enabled, then we should at least not + * leak anything. */ + memset(r, 0xff, sizeof(r)); tor_fragile_assert(); break; }