fix macro

Signed-off-by: Asra Ali <asraa@google.com>
This commit is contained in:
Asra Ali 2020-04-29 09:27:18 -04:00
parent ca0fb3040c
commit 0c292aee11
4 changed files with 6 additions and 6 deletions

View File

@ -1151,7 +1151,7 @@ int snprintf_float(T value, int precision, float_specs specs,
for (;;) {
auto begin = buf.data() + offset;
auto capacity = buf.capacity() - offset;
#ifdef FUZZ_MODE
#ifdef FMT_FUZZ
if (precision > 100000)
throw std::runtime_error(
"fuzz mode - avoid large allocation inside snprintf");

View File

@ -699,7 +699,7 @@ class basic_memory_buffer : public internal::buffer<T> {
template <typename T, std::size_t SIZE, typename Allocator>
void basic_memory_buffer<T, SIZE, Allocator>::grow(std::size_t size) {
#ifdef FUZZ_MODE
#ifdef FMT_FUZZ
if (size > 1000) throw std::runtime_error("fuzz mode - won't grow that much");
#endif
std::size_t old_capacity = this->capacity();
@ -1136,7 +1136,7 @@ template <typename Char> class float_writer {
*it++ = static_cast<Char>('0');
return it;
}
#ifdef FUZZ_MODE
#ifdef FMT_FUZZ
if (num_zeros > 1000)
throw std::runtime_error("fuzz mode - avoiding excessive cpu use");
#endif

View File

@ -13,7 +13,7 @@ namespace internal {
template <typename T>
int format_float(char* buf, std::size_t size, const char* format, int precision,
T value) {
#ifdef FUZZ_MODE
#ifdef FMT_FUZZ
if (precision > 100000)
throw std::runtime_error(
"fuzz mode - avoid large allocation inside snprintf");

View File

@ -7,13 +7,13 @@ in fmt. It is a part of the continous fuzzing at
The source code is modified to make the fuzzing possible without locking up on
resource exhaustion:
```cpp
#ifdef FUZZ_MODE
#ifdef FMT_FUZZ
if(spec.precision>100000) {
throw std::runtime_error("fuzz mode - avoiding large precision");
}
#endif
```
This macro `FUZZ_MODE` is enabled on OSS-Fuzz builds and makes fuzzing
This macro `FMT_FUZZ` is enabled on OSS-Fuzz builds and makes fuzzing
practically possible. It is used in fmt code to prevent resource exhaustion in
fuzzing mode.
The macro `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` is the