From: Peter van Dijk Date: Mon, 26 Mar 2018 18:37:50 +0000 (+0200) Subject: report unparseable data in stoul invalid_argument exception X-Git-Tag: dnsdist-1.3.0~21^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f975181d5d660e25cc4cd41f1e30788da56df96;p=thirdparty%2Fpdns.git report unparseable data in stoul invalid_argument exception --- diff --git a/pdns/misc.cc b/pdns/misc.cc index 78ec742b9b..8a6388816b 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -1360,7 +1360,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"); }