From af2a71aa2c0ab7a441cb4210295e3912800df9d0 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 10 Dec 2021 15:14:26 -0500 Subject: 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 --- libqpdf/bits.icc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libqpdf/bits.icc') 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 #include #include +#include // 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) { -- cgit v1.2.3-54-g00ecf