diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-07 10:59:59 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-07 10:59:59 -0700 |
commit | cf6f30963cdf6de47342e6724ebd7f8e8058ad43 (patch) | |
tree | f08c42ba4a327edad73e82862fa9319c333f1f49 /node | |
parent | 3f567a07ca0cda5c3370105d88cb939ad62b4b7d (diff) | |
download | infinitytier-cf6f30963cdf6de47342e6724ebd7f8e8058ad43.tar.gz infinitytier-cf6f30963cdf6de47342e6724ebd7f8e8058ad43.zip |
Kill a potential source of type punning BUS errors on Android, and besides that hack probably did not improve performance at all given the short lenghts of things compared with secureEq()
Diffstat (limited to 'node')
-rw-r--r-- | node/Utils.hpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/node/Utils.hpp b/node/Utils.hpp index bd567cf5..70918eb5 100644 --- a/node/Utils.hpp +++ b/node/Utils.hpp @@ -60,20 +60,10 @@ public: static inline bool secureEq(const void *a,const void *b,unsigned int len) throw() { - const char *p1 = (const char *)a; - const char *p2 = (const char *)b; - uint64_t diff = 0; - - while (len >= 8) { - diff |= (*((const uint64_t *)p1) ^ *((const uint64_t *)p2)); - p1 += 8; - p2 += 8; - len -= 8; - } - while (len--) - diff |= (uint64_t)(*p1++ ^ *p2++); - - return (diff == 0ULL); + char diff = 0; + for(unsigned int i=0;i<len;++i) + diff |= ( (reinterpret_cast<const char *>(a))[i] ^ (reinterpret_cast<const char *>(b))[i] ); + return (diff == 0); } /** |