mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
Merge #21631: i2p: always check the return value of Sock::Wait()
1c1467f51b
i2p: cancel the Accept() method if waiting on the socket errors (Vasil Dimov) Pull request description: If `Sock::Wait()` fails, then cancel the `Accept()` method. Not checking the return value may cause an uninitialized read a few lines below when we read the `occurred` variable. [Spotted](https://github.com/bitcoin/bitcoin/pull/21630#issuecomment-814765659) by MarcoFalke, thanks! ACKs for top commit: laanwj: Code review ACK1c1467f51b
practicalswift: cr ACK1c1467f51b
: patch looks correct and agree with laanwj that `[[nodiscard]]` can be taken in a follow-up PR :) Tree-SHA512: 57fa8a03a4e055999e23121cd9ed1566a585ece0cf68b74223d8c902804cb6890218c9356d60e0560ccacc6c8542a526356c226ebd48e7b299b4572be312d49b
This commit is contained in:
commit
1f50f0bb38
1 changed files with 3 additions and 1 deletions
|
@ -147,7 +147,9 @@ bool Session::Accept(Connection& conn)
|
|||
try {
|
||||
while (!*m_interrupt) {
|
||||
Sock::Event occurred;
|
||||
conn.sock->Wait(MAX_WAIT_FOR_IO, Sock::RECV, &occurred);
|
||||
if (!conn.sock->Wait(MAX_WAIT_FOR_IO, Sock::RECV, &occurred)) {
|
||||
throw std::runtime_error("wait on socket failed");
|
||||
}
|
||||
|
||||
if ((occurred & Sock::RECV) == 0) {
|
||||
// Timeout, no incoming connections within MAX_WAIT_FOR_IO.
|
||||
|
|
Loading…
Add table
Reference in a new issue