aboutsummaryrefslogtreecommitdiff
path: root/src/key.h
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2013-10-28 11:20:26 +0100
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2013-10-28 17:09:50 +0100
commita39967401e0ffb22649b36782435bffdec980255 (patch)
treecc842940e6cfbd145f4c32ff7b28a99f1061e969 /src/key.h
parent377cd749308d43bc718cac806a3f8a1710652b0e (diff)
fix wrong memcmp() usage in CKey::operator==
- add a check for CKey::size() of a and b (size can be 0 or 32) - change the fixed value in memcmp() to use a.size() instead - fixes #3090
Diffstat (limited to 'src/key.h')
-rw-r--r--src/key.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/key.h b/src/key.h
index ac050356f2..bbe64d6685 100644
--- a/src/key.h
+++ b/src/key.h
@@ -205,7 +205,8 @@ public:
}
friend bool operator==(const CKey &a, const CKey &b) {
- return a.fCompressed == b.fCompressed && memcmp(&a.vch[0], &b.vch[0], 32);
+ return a.fCompressed == b.fCompressed && a.size() == b.size() &&
+ memcmp(&a.vch[0], &b.vch[0], a.size()) == 0;
}
// Initialize using begin and end iterators to byte data.
@@ -261,9 +262,9 @@ public:
// Derive BIP32 child key.
bool Derive(CKey& keyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const;
-
+
// Load private key and check that public key matches.
- bool Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck);
+ bool Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck);
};
struct CExtPubKey {