
Hello
The program below decompresses a std::string using Boost.IOStream. The target is an array sink of fixed size.
The users know the decompressed size in advance but for security reasons I need to check the number of bytes written to the sink.
If the array is too small, a "write area exhausted" exception is thrown, which is fine.
If the array is too big, decompression succeeds. I would like to check the number of bytes written to the sink and throw an exception.
How can I determine how many bytes have been written to the sink?
Btw: I cannot use the "counter" filter because of the overhead involved in line counting and because the return value of its characters() method is "int". The buffers involved in my application require a 64 bit data type.
Private base class basic_zlib_decompressor of class basic_gzip_decompressor has method total_out() which seems to return the value in question but its return type is also only an "int".
Regards, Peter.
#include <iostream>
#include <stdexcept>
#include <iomanip>
#include