From 9e12cff317b7427a212a397062ff9aff7760227c Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 8 Oct 2018 15:03:41 -0400 Subject: [PATCH] fix #1253 handle incorrect values of SIGNATURE_TYPE and CRYPTO_TYPE --- libi2pd_client/SAM.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libi2pd_client/SAM.cpp b/libi2pd_client/SAM.cpp index ac2dd853..b7bf6002 100644 --- a/libi2pd_client/SAM.cpp +++ b/libi2pd_client/SAM.cpp @@ -1027,11 +1027,29 @@ namespace client { auto it = params->find (SAM_PARAM_SIGNATURE_TYPE); if (it != params->end ()) + { // TODO: extract string values - signatureType = std::stoi(it->second); + try + { + signatureType = std::stoi(it->second); + } + catch (const std::exception& ex) + { + LogPrint (eLogWarning, "SAM: ", SAM_PARAM_SIGNATURE_TYPE, "error: ", ex.what ()); + } + } it = params->find (SAM_PARAM_CRYPTO_TYPE); if (it != params->end ()) - cryptoType = std::stoi(it->second); + { + try + { + cryptoType = std::stoi(it->second); + } + catch (const std::exception& ex) + { + LogPrint (eLogWarning, "SAM: ", SAM_PARAM_CRYPTO_TYPE, "error: ", ex.what ()); + } + } } localDestination = i2p::client::context.CreateNewLocalDestination (true, signatureType, cryptoType, params); }