mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-22 04:05:39 +00:00
GP-1976: Accept only the first GADP connection
This commit is contained in:
parent
738e662e82
commit
9774aa9f0e
@ -89,7 +89,7 @@ public class GdbGadpDebuggerModelFactory extends AbstractGadpLocalDebuggerModelF
|
||||
if (!existing && gdbCmdLine.size() >= 2) {
|
||||
cmd.addAll(gdbCmdLine.subList(1, gdbCmdLine.size()));
|
||||
}
|
||||
cmd.add("--gadp-args");
|
||||
cmd.add("--agent-args");
|
||||
cmd.addAll(List.of("-H", host));
|
||||
cmd.addAll(List.of("-p", Integer.toString(port))); // Available ephemeral port
|
||||
if (!existing && gdbCmdLine.size() >= 1) {
|
||||
|
@ -61,9 +61,27 @@ public abstract class AbstractGadpServer
|
||||
|
||||
@Override
|
||||
protected GadpClientHandler newHandler(AsynchronousSocketChannel sock) {
|
||||
try {
|
||||
// Accept only the first connection
|
||||
closeServerSocket();
|
||||
}
|
||||
catch (IOException e) {
|
||||
Msg.error(this, "Could not close server socket", e);
|
||||
}
|
||||
return new GadpClientHandler(this, sock);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeHandler(GadpClientHandler handler) {
|
||||
super.removeHandler(handler);
|
||||
try {
|
||||
terminate();
|
||||
}
|
||||
catch (IOException e) {
|
||||
Msg.error(this, "Could not terminate upon disconnect");
|
||||
}
|
||||
}
|
||||
|
||||
protected AddressRange getAddressRange(Gadp.AddressRange range) {
|
||||
AddressSpace space = model.getAddressSpace(range.getSpace());
|
||||
if (space == null) {
|
||||
|
@ -129,6 +129,15 @@ public abstract class AbstractAsyncServer<S extends AbstractAsyncServer<S, H>, H
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept no more connections, but continue servicing existing connections
|
||||
*
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void closeServerSocket() throws IOException {
|
||||
ssock.close();
|
||||
}
|
||||
|
||||
protected CompletableFuture<Void> allHandlers(Function<H, CompletableFuture<?>> action) {
|
||||
AsyncFence fence = new AsyncFence();
|
||||
for (H h : handlers) {
|
||||
|
Loading…
Reference in New Issue
Block a user