commit | 65f1d9d660df9f0b6a2fe13c007e7f915b65defa | [log] [tgz] |
---|---|---|
author | Phil Burk <philburk@google.com> | Wed Oct 07 10:02:22 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Wed Oct 07 10:02:22 2020 +0000 |
tree | 55d404a837db76a5ae3089be2a8e086739fb2f76 | |
parent | 42905770f5102fbce9e64312e88167e01d13c639 [diff] | |
parent | 2652aae1f9d0a766b5aef0064a444c2f0760e2a2 [diff] |
[automerger skipped] spdif: fix possible buffer overflow am: 1b72d76412 am: 86ca73cbd3 -s ours am: 32b99befb3 -s ours am: d7c086743a -s ours am: e8a7e84274 -s ours am: 11f5386fec -s ours am: 10b636389f -s ours am: 2652aae1f9 -s ours am skip reason: Change-Id Ifc7f8c8946388e19f39f35d649a5936568f8b9b2 with SHA-1 762fbb3e09 is in history Original change: https://googleplex-android-review.googlesource.com/c/platform/system/media/+/12638670 Change-Id: I6a20569487e681c8d3ba42fb29e59504370dbc2e
diff --git a/audio_utils/spdif/SPDIFEncoder.cpp b/audio_utils/spdif/SPDIFEncoder.cpp index 4a8a02a..60b8425 100644 --- a/audio_utils/spdif/SPDIFEncoder.cpp +++ b/audio_utils/spdif/SPDIFEncoder.cpp
@@ -140,6 +140,12 @@ clearBurstBuffer(); return; } + + // Avoid reading first word past end of mBurstBuffer. + if (numBytes == 0) { + return; + } + // Pack bytes into short buffer. uint16_t pad = mBurstBuffer[mByteCursor >> 1]; for (size_t i = 0; i < numBytes; i++) { if (mByteCursor & 1 ) {