interface: PaddedRSTransport: keep in sync with e-x: flush on close
What changed, and why it matters
This commit fixes a bug in Electrum's network connection code where buffered data could be discarded when a connection closes. The fix ensures any pending reply is sent before disconnecting. It is a reliability/correctness fix that could affect protocol behavior, but the supplied materials do not describe it as a security vulnerability.
Treat as a normal bugfix. Review whether dropped replies before this change could cause any denial-of-service or protocol-level weakness, but no immediate security action is indicated by the supplied materials.
Security signals we found
Buffer flush on close prevents truncated/dropped protocol replies
Cross-reference to upstream ElectrumX commit suggests protocol correctness fix
No explicit security claim in commit message or diff
Evidence from the diff
The patch overrides PaddedRSTransport.close() to set self._force_send = True and call self._maybe_consume_sbuffer() before awaiting the parent’s close. This flushes the send buffer before the underlying transport is closed. The commit message references an ElectrumX commit (f62f986b3308a9a0493e7560d194926c05f3ea51) and mentions this makes ‘ReplyAndDisconnect’ work. No security impact is stated in the commit or supplied references.
Changed components
electrum/interface.pyPaddedRSTransport.close()Inspect captured patch +7 / −0
diff --git a/electrum/interface.py b/electrum/interface.py
index 1e42fce..ecd6f99 100644
--- a/electrum/interface.py
+++ b/electrum/interface.py
@@ -428,6 +428,13 @@ class PaddedRSTransport(RSTransport):
# No polling here, we always force-empty the buffer.
self._force_send = True
+ async def close(self, *args, **kwargs):
+ '''Close the connection and return when closed.'''
+ # Flush buffer before disconnecting. This makes ReplyAndDisconnect work:
+ self._force_send = True
+ self._maybe_consume_sbuffer()
+ await super().close(*args, **kwargs)
+
class ServerAddr:
Why this scored 35/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.