Browse Source

Merge branch 'maint-0.2.7'

Nick Mathewson 8 years ago
parent
commit
ee5337e904
2 changed files with 8 additions and 1 deletions
  1. 3 0
      changes/bug17722
  2. 5 1
      src/or/torcert.c

+ 3 - 0
changes/bug17722

@@ -0,0 +1,3 @@
+  o Minor bugfixes (code correctness)
+    - Fix undefined behavior in the tor_cert_checksig function. Fixes bug
+      17722; bugfix on tor-0.2.7.2-alpha.

+ 5 - 1
src/or/torcert.c

@@ -206,7 +206,11 @@ tor_cert_checksig(tor_cert_t *cert,
     return -1;
   } else {
     cert->sig_ok = 1;
-    memcpy(cert->signing_key.pubkey, checkable.pubkey->pubkey, 32);
+    /* Only copy the checkable public key when it is different from the signing
+     * key of the certificate to avoid undefined behavior. */
+    if (cert->signing_key.pubkey != checkable.pubkey->pubkey) {
+      memcpy(cert->signing_key.pubkey, checkable.pubkey->pubkey, 32);
+    }
     cert->cert_valid = 1;
     return 0;
   }