From b8a21272b340984a3084d5bad838f0be626e9165 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Mon, 26 Mar 2018 20:37:50 +0200 Subject: [PATCH] report unparseable data in stoul invalid_argument exception (cherry picked from commit 2f975181d5d660e25cc4cd41f1e30788da56df96) --- pdns/misc.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pdns/misc.cc b/pdns/misc.cc index 464345069..16b3908f5 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -1306,7 +1306,13 @@ gid_t strToGID(const string &str) unsigned int pdns_stou(const std::string& str, size_t * idx, int base) { if (str.empty()) return 0; // compatibility - unsigned long result = std::stoul(str, idx, base); + unsigned long result; + try { + result = std::stoul(str, idx, base); + } + catch(std::invalid_argument& e) { + throw std::invalid_argument(string(e.what()) + "; (invalid argument during std::stoul); data was \""+str+"\""); + } if (result > std::numeric_limits::max()) { throw std::out_of_range("stou"); } -- 2.40.0