summaryrefslogtreecommitdiffstats
path: root/runtime/jdwp/jdwp_handler.cc
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2014-03-18 12:19:52 +0100
committerSebastien Hertz <shertz@google.com>2014-03-18 16:56:07 +0100
commit43c8d729556844d1a74449a8a300c795d6a5406a (patch)
treed163695ff0efc74429653587c116d179228fd26d /runtime/jdwp/jdwp_handler.cc
parent341a84af890a328a6c8f719beb3f670dd1a369b4 (diff)
downloadandroid_art-43c8d729556844d1a74449a8a300c795d6a5406a.tar.gz
android_art-43c8d729556844d1a74449a8a300c795d6a5406a.tar.bz2
android_art-43c8d729556844d1a74449a8a300c795d6a5406a.zip
Do not send JDWP data in case of error.
When sending JDWP reply packet with an error, we want to ignore any data in the buffer. While we reflect that in the packet's length (first 4 bytes), we used to send all data in the buffer. This causes the receiver to read malformed JDWP packet. This CL adds "length" argument to JdwpNetStateBase::WritePacket so we control the amount of data we send. If the reply has no error, it is set to the length of the buffer. Otherwise it is the length of JDWP packet header indicating no data is available. Bug: 13366758 Change-Id: Ib72c10d5faf065fb44901c34b2732496b6667efa
Diffstat (limited to 'runtime/jdwp/jdwp_handler.cc')
-rw-r--r--runtime/jdwp/jdwp_handler.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/runtime/jdwp/jdwp_handler.cc b/runtime/jdwp/jdwp_handler.cc
index 5f21098a8f..c2a2b5415d 100644
--- a/runtime/jdwp/jdwp_handler.cc
+++ b/runtime/jdwp/jdwp_handler.cc
@@ -1659,7 +1659,7 @@ static std::string DescribeCommand(Request& request) {
*
* On entry, the JDWP thread is in VMWAIT.
*/
-void JdwpState::ProcessRequest(Request& request, ExpandBuf* pReply) {
+size_t JdwpState::ProcessRequest(Request& request, ExpandBuf* pReply) {
JdwpError result = ERR_NONE;
if (request.GetCommandSet() != kJDWPDdmCmdSet) {
@@ -1728,14 +1728,11 @@ void JdwpState::ProcessRequest(Request& request, ExpandBuf* pReply) {
* If we encountered an error, only send the header back.
*/
uint8_t* replyBuf = expandBufGetBuffer(pReply);
+ size_t replyLength = (result == ERR_NONE) ? expandBufGetLength(pReply) : kJDWPHeaderLen;
+ Set4BE(replyBuf + 0, replyLength);
Set4BE(replyBuf + 4, request.GetId());
Set1(replyBuf + 8, kJDWPFlagReply);
Set2BE(replyBuf + 9, result);
- if (result == ERR_NONE) {
- Set4BE(replyBuf + 0, expandBufGetLength(pReply));
- } else {
- Set4BE(replyBuf + 0, kJDWPHeaderLen);
- }
CHECK_GT(expandBufGetLength(pReply), 0U) << GetCommandName(request) << " " << request.GetId();
@@ -1757,6 +1754,8 @@ void JdwpState::ProcessRequest(Request& request, ExpandBuf* pReply) {
/* tell the VM that GC is okay again */
self->TransitionFromRunnableToSuspended(old_state);
+
+ return replyLength;
}
/*