[tor-commits] [tor/master] Ensure signing_key is non-NULL before accessing one of its members

nickm at torproject.org nickm at torproject.org
Tue Jun 2 19:07:40 UTC 2015


commit 383a27afc58b7a416fe0f30c80fdd069bc03d5d4
Author: teor <teor2345 at gmail.com>
Date:   Wed Jun 3 03:56:05 2015 +1000

    Ensure signing_key is non-NULL before accessing one of its members
    
    signing_key can be NULL in ed_key_init_from_file in routerkeys.c.
    Discovered by clang 3.7 address sanitizer.
    
    Fix on c03694938ed0, not in any released version of Tor.
---
 changes/bug16115-signing-key-NULL-check |    6 ++++++
 src/or/routerkeys.c                     |    3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/changes/bug16115-signing-key-NULL-check b/changes/bug16115-signing-key-NULL-check
new file mode 100644
index 0000000..3d4f05b
--- /dev/null
+++ b/changes/bug16115-signing-key-NULL-check
@@ -0,0 +1,6 @@
+  o Minor fixes (threads, comments):
+    - Ensure signing_key is non-NULL before accessing one of its members
+      signing_key can be NULL in ed_key_init_from_file in routerkeys.c.
+      Discovered by clang 3.7 address sanitizer.
+      Patch by "teor".
+      Fix on c03694938ed0, not in any released version of Tor.
diff --git a/src/or/routerkeys.c b/src/or/routerkeys.c
index b17d195..e79204c 100644
--- a/src/or/routerkeys.c
+++ b/src/or/routerkeys.c
@@ -152,7 +152,8 @@ ed_key_init_from_file(const char *fname, uint32_t flags,
                         ED25519_PUBKEY_LEN)) {
     tor_log(severity, LD_OR, "Cert was for wrong key");
     bad_cert = 1;
-  } else if (tor_cert_checksig(cert, &signing_key->pubkey, now) < 0 &&
+  } else if (signing_key &&
+             tor_cert_checksig(cert, &signing_key->pubkey, now) < 0 &&
              (signing_key || cert->cert_expired)) {
     tor_log(severity, LD_OR, "Can't check certificate");
     bad_cert = 1;





More information about the tor-commits mailing list