use FMT_THROW
Signed-off-by: Asra Ali <asraa@google.com>
This commit is contained in:
parent
6f435f55c8
commit
9aa1517525
@ -1153,8 +1153,8 @@ int snprintf_float(T value, int precision, float_specs specs,
|
|||||||
auto capacity = buf.capacity() - offset;
|
auto capacity = buf.capacity() - offset;
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||||
if (precision > 100000)
|
if (precision > 100000)
|
||||||
throw std::runtime_error(
|
FMT_THROW(std::runtime_error(
|
||||||
"fuzz mode - avoid large allocation inside snprintf");
|
"fuzz mode - avoid large allocation inside snprintf"));
|
||||||
#endif
|
#endif
|
||||||
// Suppress the warning about a nonliteral format string.
|
// Suppress the warning about a nonliteral format string.
|
||||||
// Cannot use auto becase of a bug in MinGW (#1532).
|
// Cannot use auto becase of a bug in MinGW (#1532).
|
||||||
|
|||||||
@ -700,7 +700,7 @@ class basic_memory_buffer : public internal::buffer<T> {
|
|||||||
template <typename T, std::size_t SIZE, typename Allocator>
|
template <typename T, std::size_t SIZE, typename Allocator>
|
||||||
void basic_memory_buffer<T, SIZE, Allocator>::grow(std::size_t size) {
|
void basic_memory_buffer<T, SIZE, Allocator>::grow(std::size_t size) {
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||||
if (size > 1000) throw std::runtime_error("fuzz mode - won't grow that much");
|
if (size > 1000) FMT_THROW(std::runtime_error("fuzz mode - won't grow that much"));
|
||||||
#endif
|
#endif
|
||||||
std::size_t old_capacity = this->capacity();
|
std::size_t old_capacity = this->capacity();
|
||||||
std::size_t new_capacity = old_capacity + old_capacity / 2;
|
std::size_t new_capacity = old_capacity + old_capacity / 2;
|
||||||
@ -1138,7 +1138,7 @@ template <typename Char> class float_writer {
|
|||||||
}
|
}
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||||
if (num_zeros > 1000)
|
if (num_zeros > 1000)
|
||||||
throw std::runtime_error("fuzz mode - avoiding excessive cpu use");
|
FMT_THROW(std::runtime_error("fuzz mode - avoiding excessive cpu use"));
|
||||||
#endif
|
#endif
|
||||||
it = std::fill_n(it, num_zeros, static_cast<Char>('0'));
|
it = std::fill_n(it, num_zeros, static_cast<Char>('0'));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,8 +15,8 @@ int format_float(char* buf, std::size_t size, const char* format, int precision,
|
|||||||
T value) {
|
T value) {
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||||
if (precision > 100000)
|
if (precision > 100000)
|
||||||
throw std::runtime_error(
|
FMT_THROW(std::runtime_error(
|
||||||
"fuzz mode - avoid large allocation inside snprintf");
|
"fuzz mode - avoid large allocation inside snprintf"));
|
||||||
#endif
|
#endif
|
||||||
// Suppress the warning about nonliteral format string.
|
// Suppress the warning about nonliteral format string.
|
||||||
int (*snprintf_ptr)(char*, size_t, const char*, ...) = FMT_SNPRINTF;
|
int (*snprintf_ptr)(char*, size_t, const char*, ...) = FMT_SNPRINTF;
|
||||||
|
|||||||
@ -9,7 +9,7 @@ resource exhaustion:
|
|||||||
```cpp
|
```cpp
|
||||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||||
if(spec.precision>100000) {
|
if(spec.precision>100000) {
|
||||||
throw std::runtime_error("fuzz mode - avoiding large precision");
|
FMT_THROW(std::runtime_error("fuzz mode - avoiding large precision"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user