diff options
author | Jay Berkenbilt <ejb@ql.org> | 2021-12-10 21:14:26 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2021-12-10 21:37:35 +0100 |
commit | af2a71aa2c0ab7a441cb4210295e3912800df9d0 (patch) | |
tree | ce42e6dcb4ab161ac703c67aad846b274abaea48 /libqpdf/bits.icc | |
parent | 1c62c2a3427e92846ddaaae44f864022b2aade4f (diff) | |
download | qpdf-af2a71aa2c0ab7a441cb4210295e3912800df9d0.tar.zst |
Handle bitstream overflow errors more gracefully (fixes #581)
* Make it a runtime error, not a logic error
* Include additional information
* Capture it properly in checkLinearization
Diffstat (limited to 'libqpdf/bits.icc')
-rw-r--r-- | libqpdf/bits.icc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libqpdf/bits.icc b/libqpdf/bits.icc index 1cbbebcc..3fb9dfa1 100644 --- a/libqpdf/bits.icc +++ b/libqpdf/bits.icc @@ -6,6 +6,7 @@ #include <stdexcept> #include <qpdf/QTC.hh> #include <qpdf/Pipeline.hh> +#include <qpdf/QUtil.hh> // These functions may be run at places where the function call // overhead from test coverage testing would be too high. Therefore, @@ -28,7 +29,10 @@ read_bits(unsigned char const*& p, size_t& bit_offset, if (bits_wanted > bits_available) { - throw std::length_error("overflow reading bit stream"); + throw std::runtime_error( + "overflow reading bit stream: wanted = " + + QUtil::uint_to_string(bits_wanted) + "; available = " + + QUtil::uint_to_string(bits_available)); } if (bits_wanted > 32) { |