Skip to content

Fix UDPInput thread death, TCPOutput double-free, and compile warnings#62

Open
yuhengzhang-google wants to merge 3 commits into
hexene:masterfrom
yuhengzhang-google:yuheng-fixes
Open

Fix UDPInput thread death, TCPOutput double-free, and compile warnings#62
yuhengzhang-google wants to merge 3 commits into
hexene:masterfrom
yuhengzhang-google:yuheng-fixes

Conversation

@yuhengzhang-google

Copy link
Copy Markdown

This PR addresses a few critical bugs and resolves several compilation warnings to improve the stability and reusability of the LocalVPN stack.

🐛 Bug Fixes

  • Fixes a FATAL EXCEPTION double-free memory corruption in TCPOutput.java. The closeCleanly method previously released a ByteBuffer that was already released in the main loop, causing pool corruption.
  • Fixes UDPInput thread death caused by unhandled IOExceptions (such as PortUnreachableException). The read operation is now wrapped in a try-catch block so the infinite loop can safely continue instead of crashing the receiver thread.

♻️ Refactoring & Warnings

  • Decouples TCPOutput and UDPOutput from the specific LocalVPNService wrapper. Broadened the constructor signatures to accept the standard Android android.net.VpnService, allowing other developers to easily reuse this networking stack in their own custom implementations.
  • Enforces immutability for the TransportProtocol enum in Packet.java by making protocolNumber final.
  • Fixes raw type warnings in LRUCache.java by adding the missing generic type parameters <K, V> to CleanupCallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant