diff options
author | Tim Taubert <ttaubert@mozilla.com> | 2017-01-09 12:15:40 -0500 |
---|---|---|
committer | Tim Taubert <ttaubert@mozilla.com> | 2017-01-09 12:15:40 -0500 |
commit | e449c2b4fbfd41761ed159d649ab66bff2427a7e (patch) | |
tree | 1faf08a10bf3dfb4ffa7d8660c529dbf51f5a631 /fuzz/shared.h | |
parent | d8d18be6b10128c49d13e55f3f0fb860aabcbb13 (diff) | |
download | nss-hg-e449c2b4fbfd41761ed159d649ab66bff2427a7e.tar.gz |
Bug 1326416 - Update libFuzzer revision r=franziskus
Differential Revision: https://nss-review.dev.mozaws.net/D132
Diffstat (limited to 'fuzz/shared.h')
-rw-r--r-- | fuzz/shared.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fuzz/shared.h b/fuzz/shared.h index 09d805ed8..107024904 100644 --- a/fuzz/shared.h +++ b/fuzz/shared.h @@ -7,6 +7,7 @@ #ifndef shared_h__ #define shared_h__ +#include "cert.h" #include "nss.h" class NSSDatabase { @@ -15,4 +16,24 @@ class NSSDatabase { ~NSSDatabase() { NSS_Shutdown(); } }; +void QuickDERDecode(void *dst, const SEC_ASN1Template *tpl, const uint8_t *buf, + size_t len) { + PORTCheapArenaPool pool; + SECItem data = {siBuffer, const_cast<unsigned char *>(buf), + static_cast<unsigned int>(len)}; + + PORT_InitCheapArena(&pool, DER_DEFAULT_CHUNKSIZE); + (void)SEC_QuickDERDecodeItem(&pool.arena, dst, tpl, &data); + PORT_DestroyCheapArena(&pool); +} + +#define ADD_CUSTOM_MUTATORS(...) \ + extern "C" size_t LLVMFuzzerCustomMutator( \ + uint8_t *Data, size_t Size, size_t MaxSize, unsigned int Seed) { \ + std::vector<decltype(LLVMFuzzerCustomMutator) *> mutators = __VA_ARGS__; \ + fuzzer::Random R(Seed); \ + auto idx = R(mutators.size()); \ + return mutators.at(idx)(Data, Size, MaxSize, Seed); \ + } + #endif // shared_h__ |