未验证 提交 ba8ba504 编写于 作者: S Skylot

fix(debugger): small improve for jdwp handshake (#1412)

上级 481b5abf
...@@ -632,17 +632,16 @@ public class SmaliDebugger { ...@@ -632,17 +632,16 @@ public class SmaliDebugger {
throw new SmaliDebuggerException("Failed to init JDWP."); throw new SmaliDebuggerException("Failed to init JDWP.");
} }
@SuppressWarnings("ResultOfMethodCallIgnored")
private static void handShake(OutputStream outputStream, InputStream inputStream) throws SmaliDebuggerException { private static void handShake(OutputStream outputStream, InputStream inputStream) throws SmaliDebuggerException {
byte[] buf = new byte[14]; byte[] buf;
try { try {
outputStream.write(JDWP.encodeHandShakePacket()); outputStream.write(JDWP.encodeHandShakePacket());
inputStream.read(buf); buf = readBytes(inputStream, 14);
} catch (Exception e) { } catch (Exception e) {
throw new SmaliDebuggerException("jdwp handshake failed", e); throw new SmaliDebuggerException("jdwp handshake failed", e);
} }
if (!JDWP.decodeHandShakePacket(buf)) { if (buf == null || !JDWP.decodeHandShakePacket(buf)) {
throw new SmaliDebuggerException("jdwp handshake failed."); throw new SmaliDebuggerException("jdwp handshake bad reply");
} }
} }
...@@ -1170,7 +1169,10 @@ public class SmaliDebugger { ...@@ -1170,7 +1169,10 @@ public class SmaliDebugger {
return tempBuf; return tempBuf;
} }
private static void tryThrowError(Packet res) throws SmaliDebuggerException { private static void tryThrowError(@Nullable Packet res) throws SmaliDebuggerException {
if (res == null) {
throw new SmaliDebuggerException("Stream ended");
}
if (res.isError()) { if (res.isError()) {
throw new SmaliDebuggerException("(JDWP Error Code:" + res.getErrorCode() + ") " throw new SmaliDebuggerException("(JDWP Error Code:" + res.getErrorCode() + ") "
+ res.getErrorText(), res.getErrorCode()); + res.getErrorText(), res.getErrorCode());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册