From 1c62eaec25aeb11c3d778e90c2f04734e084d368 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Fri, 13 Sep 2019 03:16:18 -0700 Subject: [PATCH] Fix one_hot fuzzer timeout when input is way too long. This makes an upper limit on buffer input, any request for more is just silently ignored PiperOrigin-RevId: 268871697 --- tensorflow/core/kernels/fuzzing/one_hot_fuzz.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tensorflow/core/kernels/fuzzing/one_hot_fuzz.cc b/tensorflow/core/kernels/fuzzing/one_hot_fuzz.cc index 85cbe51ba8b..94ce3035044 100644 --- a/tensorflow/core/kernels/fuzzing/one_hot_fuzz.cc +++ b/tensorflow/core/kernels/fuzzing/one_hot_fuzz.cc @@ -20,6 +20,9 @@ limitations under the License. namespace tensorflow { namespace fuzzing { +// Don't generate tensors that are too large as we don't test that branch here +constexpr size_t kMaxSize = 1024; + class FuzzOneHot : public FuzzSession { void BuildGraph(const Scope& scope) override { auto input = @@ -39,6 +42,11 @@ class FuzzOneHot : public FuzzSession { const uint8_t* input_data; if (size > 3) { + // Since we only care about the one hot decoding and not about the size of + // the tensor, limit `size` to at most `kMaxSize`. + if (size > kMaxSize) { + size = kMaxSize; + } depth = static_cast(data[0]); on = data[1]; off = data[2];