From 98f6c00dad96d3150a9b969a0ee67addc78ac5f0 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Wed, 21 Oct 2020 15:29:28 -0400 Subject: Protect numeric conversion against user's locale (fixes #459) --- include/qpdf/QIntC.hh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') 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 #include #include +#include #include // This namespace provides safe integer conversion that detects @@ -67,6 +68,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion if (i > std::numeric_limits::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::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::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 " -- cgit v1.2.3-54-g00ecf