diff options
author | 2018-04-24 18:10:22 -0700 | |
---|---|---|
committer | 2018-04-24 18:13:07 -0700 | |
commit | 29ac285556cba696a15a4b6cd40034f9eb82e1fd (patch) | |
tree | de9c1538fd780ce21ed9e84a27f27d92b66cec91 /tensorflow/core/lib/wav | |
parent | 44c9c3a170e8919d075d3e8a7c5c5ac7ac5dee43 (diff) |
Add a fuzzer for DecodeWav.
Fix an OOM error in which a wav file could claim to be
larger than it really is, resulting in a large memory
allocation prior to the size mismatch being detected later.
PiperOrigin-RevId: 194176822
Diffstat (limited to 'tensorflow/core/lib/wav')
-rw-r--r-- | tensorflow/core/lib/wav/wav_io.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tensorflow/core/lib/wav/wav_io.cc b/tensorflow/core/lib/wav/wav_io.cc index 3f7dbcee85..36d939e061 100644 --- a/tensorflow/core/lib/wav/wav_io.cc +++ b/tensorflow/core/lib/wav/wav_io.cc @@ -285,6 +285,12 @@ Status DecodeLin16WaveAsFloatVector(const string& wav_string, was_data_found = true; *sample_count = chunk_size / bytes_per_sample; const uint32 data_count = *sample_count * *channel_count; + int unused_new_offset = 0; + // Validate that the data exists before allocating space for it + // (prevent easy OOM errors). + TF_RETURN_IF_ERROR(IncrementOffset(offset, sizeof(int16) * data_count, + wav_string.size(), + &unused_new_offset)); float_values->resize(data_count); for (int i = 0; i < data_count; ++i) { int16 single_channel_value = 0; |