Make FX_Random::Fill() the only entry point to FX_Random. Prevent future generations from instantiating these with ad-hoc seeds. Change-Id: Id060d95ad06f7dbed42fc5857a23ff04276f81e6 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/148651 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/fx_random.h b/core/fxcrt/fx_random.h index 77a291b..654f2c3 100644 --- a/core/fxcrt/fx_random.h +++ b/core/fxcrt/fx_random.h
@@ -19,6 +19,11 @@ public: static constexpr size_t kStateSize = 848; + // Using a temporary MT generator, fills `buffer` with random 32-bit unsigned + // integers. + static void Fill(pdfium::span<uint32_t> buffer); + + private: explicit FX_Random(uint32_t seed); FX_Random(const FX_Random&) = delete; @@ -26,14 +31,9 @@ ~FX_Random(); - // Using a temporary MT generator, fills `buffer` with random 32-bit unsigned - // integers. - static void Fill(pdfium::span<uint32_t> buffer); - // Returns a single random 32-bit unsigned integer. uint32_t Generate(); - private: uint32_t next_index_; std::array<uint32_t, kStateSize> state_; };