Merge pull request #2643 from pobregat0/bob-command-port-parse

guard std::stoi in BOB outport, inport and newkeys handlers
This commit is contained in:
orignal authored and GitHub committed 2026-11-20 18:46:34 -05:00
commit 6a3e2028ac
1 file changed
+5 -3
+5 -3
View File
@@ -612,7 +612,7 @@ namespace client
}
signatureType = std::stoi(operand);
}
catch (std::invalid_argument& ex)
catch (std::exception& ex) // also catches out_of_range on a too long number
{
LogPrint (eLogWarning, "BOB: Error on newkeys: ", ex.what ());
}
@@ -667,7 +667,8 @@ namespace client
LogPrint (eLogDebug, "BOB: outport ", operand);
if (*operand)
{
int port = std::stoi(operand);
int port = -1;
try { port = std::stoi(operand); } catch (std::exception&) {} // invalid port stays -1, rejected below
if (port >= 0 && port < 65536)
{
m_OutPort = port;
@@ -697,7 +698,8 @@ namespace client
LogPrint (eLogDebug, "BOB: inport ", operand);
if (*operand)
{
int port = std::stoi(operand);
int port = -1;
try { port = std::stoi(operand); } catch (std::exception&) {} // invalid port stays -1, rejected below
if (port >= 0 && port < 65536)
{
m_InPort = port;