mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 13:03:45 +02:00
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()
This commit is contained in:
parent
3f567a07ca
commit
cf6f30963c
1 changed files with 4 additions and 14 deletions
|
@ -60,20 +60,10 @@ public:
|
||||||
static inline bool secureEq(const void *a,const void *b,unsigned int len)
|
static inline bool secureEq(const void *a,const void *b,unsigned int len)
|
||||||
throw()
|
throw()
|
||||||
{
|
{
|
||||||
const char *p1 = (const char *)a;
|
char diff = 0;
|
||||||
const char *p2 = (const char *)b;
|
for(unsigned int i=0;i<len;++i)
|
||||||
uint64_t diff = 0;
|
diff |= ( (reinterpret_cast<const char *>(a))[i] ^ (reinterpret_cast<const char *>(b))[i] );
|
||||||
|
return (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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue