Bug 1457612 - Use BitwiseCast instead of direct bit-punning in jsdate.cpp:NowAsMillis. r=luke

--HG--
extra : rebase_source : 34fc0e7a08eaf3a971ed11984b2a979c7b8f39a5
This commit is contained in:
Jeff Walden 2018-04-27 18:25:42 -07:00
Родитель 14dba54ee1
Коммит 2690d2331a
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -19,6 +19,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/Atomics.h"
#include "mozilla/Casting.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/Sprintf.h"
#include "mozilla/TextUtils.h"
@ -51,6 +52,7 @@ using namespace js;
using mozilla::Atomic;
using mozilla::ArrayLength;
using mozilla::BitwiseCast;
using mozilla::IsAsciiAlpha;
using mozilla::IsFinite;
using mozilla::IsNaN;
@ -1324,7 +1326,7 @@ NowAsMillis(JSContext* cx)
// with trying to prevent an attacker from calculating the midpoint themselves.
// So we use a very simple, very fast CRC with a hardcoded seed.
uint64_t midpoint = *((uint64_t*)&clamped);
uint64_t midpoint = BitwiseCast<uint64_t>(clamped);
midpoint ^= 0x0F00DD1E2BAD2DED; // XOR in a 'secret'
// MurmurHash3 internal component from
// https://searchfox.org/mozilla-central/rev/61d400da1c692453c2dc2c1cf37b616ce13dea5b/dom/canvas/MurmurHash3.cpp#85