From 9a0319b4835d7e541807a31c9be98c006bd51609 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 --- pdns/misc.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pdns/misc.cc b/pdns/misc.cc index 78ec742b9b674..9d566f4d7c1db 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()) + "; data was \""+str+"\""); + } if (result > std::numeric_limits::max()) { throw std::out_of_range("stou"); }