1 | #include <Poco/FileStream.h> |
2 | #include <Poco/NullStream.h> |
3 | #include <Poco/StreamCopier.h> |
4 | #include <Poco/DeflatingStream.h> |
5 | |
6 | /** This script reproduces the bug in zlib-ng library. |
7 | * Put the following content to "data.bin" file: |
8 | abcdefghijklmn!@Aab#AAabcdefghijklmn$% |
9 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
10 | * There are two lines. First line make sense. Second line contains padding to make file size large enough. |
11 | * Compile with |
12 | * cmake -D SANITIZE=address |
13 | * and run: |
14 | |
15 | ./zlib_ng_bug data2.bin |
16 | ================================================================= |
17 | ==204952==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6310000147ff at pc 0x000000596d7a bp 0x7ffd139edd50 sp 0x7ffd139edd48 |
18 | READ of size 1 at 0x6310000147ff thread T0 |
19 | */ |
20 | |
21 | int main(int argc, char ** argv) |
22 | { |
23 | using namespace Poco; |
24 | |
25 | std::string filename(argc >= 2 ? argv[1] : "data.bin" ); |
26 | FileInputStream istr(filename); |
27 | NullOutputStream ostr; |
28 | DeflatingOutputStream deflater(ostr, DeflatingStreamBuf::STREAM_GZIP); |
29 | StreamCopier::copyStream(istr, deflater); |
30 | |
31 | return 0; |
32 | } |
33 | |