From 5155a2db7e58d0e18d6e61ec912e114cc8f12091 Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Mon, 22 Jan 2024 19:19:16 +0100 Subject: [PATCH] Update error handling --- cpp/s2pexec/s2pexec_core.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cpp/s2pexec/s2pexec_core.cpp b/cpp/s2pexec/s2pexec_core.cpp index 1956f970..7b3839fa 100644 --- a/cpp/s2pexec/s2pexec_core.cpp +++ b/cpp/s2pexec/s2pexec_core.cpp @@ -310,7 +310,7 @@ string S2pExec::ExecuteCommand() } catch (const parser_exception&) { - return "Error: Invalid CDB: '" + command + "'"; + return "Error: Invalid CDB data input format: '" + command + "'"; } vector cdb; @@ -417,7 +417,15 @@ string S2pExec::ReadData() stringstream ss; ss << in.rdbuf(); if (!in.fail()) { - for (const byte b : HexToBytes(ss.str())) { + vector bytes; + try { + bytes = HexToBytes(ss.str()); + } + catch (const parser_exception&) { + return "Invalid command data input data format"; + } + + for (const byte b : bytes) { buffer.emplace_back(static_cast(b)); } }