■ ■ ■ ■ ■ ■
jadx-gui/src/main/java/jadx/gui/device/debugger/SmaliDebugger.java
| skipped 631 lines |
632 | 632 | | throw new SmaliDebuggerException("Failed to init JDWP."); |
633 | 633 | | } |
634 | 634 | | |
635 | | - | @SuppressWarnings("ResultOfMethodCallIgnored") |
636 | 635 | | private static void handShake(OutputStream outputStream, InputStream inputStream) throws SmaliDebuggerException { |
637 | | - | byte[] buf = new byte[14]; |
| 636 | + | byte[] buf; |
638 | 637 | | try { |
639 | 638 | | outputStream.write(JDWP.encodeHandShakePacket()); |
640 | | - | inputStream.read(buf); |
| 639 | + | buf = readBytes(inputStream, 14); |
641 | 640 | | } catch (Exception e) { |
642 | 641 | | throw new SmaliDebuggerException("jdwp handshake failed", e); |
643 | 642 | | } |
644 | | - | if (!JDWP.decodeHandShakePacket(buf)) { |
645 | | - | throw new SmaliDebuggerException("jdwp handshake failed."); |
| 643 | + | if (buf == null || !JDWP.decodeHandShakePacket(buf)) { |
| 644 | + | throw new SmaliDebuggerException("jdwp handshake bad reply"); |
646 | 645 | | } |
647 | 646 | | } |
648 | 647 | | |
| skipped 521 lines |
1170 | 1169 | | return tempBuf; |
1171 | 1170 | | } |
1172 | 1171 | | |
1173 | | - | private static void tryThrowError(Packet res) throws SmaliDebuggerException { |
| 1172 | + | private static void tryThrowError(@Nullable Packet res) throws SmaliDebuggerException { |
| 1173 | + | if (res == null) { |
| 1174 | + | throw new SmaliDebuggerException("Stream ended"); |
| 1175 | + | } |
1174 | 1176 | | if (res.isError()) { |
1175 | 1177 | | throw new SmaliDebuggerException("(JDWP Error Code:" + res.getErrorCode() + ") " |
1176 | 1178 | | + res.getErrorText(), res.getErrorCode()); |
| skipped 464 lines |