summaryrefslogtreecommitdiff
path: root/media/native/midi/midi.cpp
diff options
context:
space:
mode:
authorMikhail Naganov <mnaganov@google.com>2018-11-07 09:26:30 -0800
committerMikhail Naganov <mnaganov@google.com>2018-11-07 09:41:45 -0800
commit25f51c6ab9e4b97001bda2d8bc6c8a5f144903dd (patch)
tree55caa1b32fe600fd7540aff987a5c98cfa3b02a3 /media/native/midi/midi.cpp
parent78515967f08dbb91a43c8d0f27d3712a3ce676d3 (diff)
NativeMIDI: Fix access to unaligned 64-bit data
Accessing unaligned 64-bit data in 32-bit ARM code leads to SIGBUS / BUS_ADRALN fault. Since the timestamp position in the message buffer is arbitrary, use memcpy to copy it to the output argument. Bug: 114123427 Test: 32-bit android.nativemidi.cts.NativeMidiEchoTest Change-Id: I0cb08cb0b124e3f4a05ea19bf91f40081a584a2e
Diffstat (limited to 'media/native/midi/midi.cpp')
-rw-r--r--media/native/midi/midi.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/media/native/midi/midi.cpp b/media/native/midi/midi.cpp
index 78ca0ab2486e..a5bdba8569b8 100644
--- a/media/native/midi/midi.cpp
+++ b/media/native/midi/midi.cpp
@@ -338,7 +338,8 @@ public:
numMessageBytes = std::min(maxBytes, numMessageBytes);
memcpy(buffer, readBuffer + 1, numMessageBytes);
if (timestampPtr != nullptr) {
- *timestampPtr = *(uint64_t*)(readBuffer + readCount - sizeof(uint64_t));
+ memcpy(timestampPtr, readBuffer + readCount - sizeof(uint64_t),
+ sizeof(*timestampPtr));
}
}
*numBytesReceivedPtr = numMessageBytes;