From 9666bfa6263ff77b828f34ddf8bc2ab23c04b1da Mon Sep 17 00:00:00 2001 From: PobreGato <315121269+pobregat0@users.noreply.github.com> Date: Fri, 20 Nov 2026 18:07:49 -0500 Subject: [PATCH] guard std::stoi in BOB outport, inport and newkeys handlers --- libi2pd_client/BOB.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libi2pd_client/BOB.cpp b/libi2pd_client/BOB.cpp index 22615bb1..57fdb6da 100644 --- a/libi2pd_client/BOB.cpp +++ b/libi2pd_client/BOB.cpp @@ -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;