tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mutate.cc (690B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #include "mutate.h"
      6 
      7 #include <cstddef>
      8 #include <cstdint>
      9 #include <random>
     10 
     11 size_t CustomMutate(Mutators mutators, uint8_t* data, size_t size,
     12                    size_t maxSize, unsigned int seed) {
     13  std::mt19937 rng(seed);
     14  static std::bernoulli_distribution bdist;
     15 
     16  if (bdist(rng)) {
     17    std::uniform_int_distribution<size_t> idist(0, mutators.size() - 1);
     18    return mutators.at(idist(rng))(data, size, maxSize, seed);
     19  }
     20 
     21  return LLVMFuzzerMutate(data, size, maxSize);
     22 }