diff options
author | Jay Berkenbilt <ejb@ql.org> | 2020-10-21 21:29:28 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2020-10-21 22:42:51 +0200 |
commit | 98f6c00dad96d3150a9b969a0ee67addc78ac5f0 (patch) | |
tree | 2c1455f3b208275aecc1395453f3396a85eb7800 /include | |
parent | ef127001b36b42042874812e0d06dccf92cdb229 (diff) | |
download | qpdf-98f6c00dad96d3150a9b969a0ee67addc78ac5f0.tar.zst |
Protect numeric conversion against user's locale (fixes #459)
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QIntC.hh | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/qpdf/QIntC.hh b/include/qpdf/QIntC.hh index 906eff77..6f1f4b63 100644 --- a/include/qpdf/QIntC.hh +++ b/include/qpdf/QIntC.hh @@ -29,6 +29,7 @@ #include <limits> #include <sstream> #include <cassert> +#include <locale> #include <type_traits> // This namespace provides safe integer conversion that detects @@ -67,6 +68,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion if (i > std::numeric_limits<To>::max()) { std::ostringstream msg; + msg.imbue(std::locale::classic()); msg << "integer out of range converting " << i << " from a " << sizeof(From) << "-byte unsigned type to a " @@ -88,6 +90,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion (i > std::numeric_limits<To>::max())) { std::ostringstream msg; + msg.imbue(std::locale::classic()); msg << "integer out of range converting " << i << " from a " << sizeof(From) << "-byte signed type to a " @@ -111,6 +114,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion if ((i < 0) || (ii > std::numeric_limits<To>::max())) { std::ostringstream msg; + msg.imbue(std::locale::classic()); msg << "integer out of range converting " << i << " from a " << sizeof(From) << "-byte signed type to a " @@ -134,6 +138,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion if (i > maxval) { std::ostringstream msg; + msg.imbue(std::locale::classic()); msg << "integer out of range converting " << i << " from a " << sizeof(From) << "-byte unsigned type to a " |