diff options
author | Philippe Lieser <[email protected]> | 2017-04-10 16:56:06 +0200 |
---|---|---|
committer | Philippe Lieser <[email protected]> | 2017-04-10 16:56:06 +0200 |
commit | 2b0a0c3b323d3b8fa09a31420738e0663a4590e8 (patch) | |
tree | 44d24a88ad2c393987e4ee2eeee4cc87d0e561f5 | |
parent | 2f1b5f55d736715c6c15a117bcb70ae582cc7920 (diff) |
fix missing flush in DataSink_Stream::end_msg
-rw-r--r-- | authors.txt | 1 | ||||
-rw-r--r-- | news.rst | 2 | ||||
-rw-r--r-- | src/lib/filters/data_snk.cpp | 9 | ||||
-rw-r--r-- | src/lib/filters/data_snk.h | 3 | ||||
-rw-r--r-- | src/tests/test_filters.cpp | 27 |
5 files changed, 42 insertions, 0 deletions
diff --git a/authors.txt b/authors.txt index 437b68906..ee6a10e9d 100644 --- a/authors.txt +++ b/authors.txt @@ -40,3 +40,4 @@ Kai Michaelis (Rohde & Schwarz Cybersecurity) Philipp Weber (Rohde & Schwarz Cybersecurity) Tobias @neverhub Alexander Bluhm (genua GmbH) +Philippe Lieser (Rohde & Schwarz Cybersecurity) @@ -6,6 +6,8 @@ Version 2.2.0, Not Yet Released * Add the SM3 hash function +* Fix missing flush in DataSink_Stream::end_msg. (GH #972) + Version 2.1.0, 2017-04-04 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/lib/filters/data_snk.cpp b/src/lib/filters/data_snk.cpp index 7a213cfeb..38734f0e3 100644 --- a/src/lib/filters/data_snk.cpp +++ b/src/lib/filters/data_snk.cpp @@ -2,6 +2,7 @@ * DataSink * (C) 1999-2007 Jack Lloyd * 2005 Matthew Gregan +* 2017 Philippe Lieser * * Botan is released under the Simplified BSD License (see license.txt) */ @@ -27,6 +28,14 @@ void DataSink_Stream::write(const uint8_t out[], size_t length) } /* +* Flush the stream +*/ +void DataSink_Stream::end_msg() + { + m_sink.flush(); + } + +/* * DataSink_Stream Constructor */ DataSink_Stream::DataSink_Stream(std::ostream& out, diff --git a/src/lib/filters/data_snk.h b/src/lib/filters/data_snk.h index 7accef358..b3e5e06cf 100644 --- a/src/lib/filters/data_snk.h +++ b/src/lib/filters/data_snk.h @@ -1,6 +1,7 @@ /* * DataSink * (C) 1999-2007 Jack Lloyd +* 2017 Philippe Lieser * * Botan is released under the Simplified BSD License (see license.txt) */ @@ -58,6 +59,8 @@ class BOTAN_DLL DataSink_Stream : public DataSink void write(const uint8_t[], size_t) override; + void end_msg() override; + ~DataSink_Stream(); private: diff --git a/src/tests/test_filters.cpp b/src/tests/test_filters.cpp index ee3e68c1a..b9bd15ced 100644 --- a/src/tests/test_filters.cpp +++ b/src/tests/test_filters.cpp @@ -2,6 +2,7 @@ * (C) 2016 Daniel Neus * 2016 Jack Lloyd * 2017 René Korthaus +* 2017 Philippe Lieser * * Botan is released under the Simplified BSD License (see license.txt) */ @@ -35,6 +36,7 @@ class Filter_Tests : public Test results.push_back(test_secqueue()); results.push_back(test_data_src_sink()); + results.push_back(test_data_src_sink_flush()); results.push_back(test_pipe_io()); results.push_back(test_pipe_errors()); results.push_back(test_pipe_hash()); @@ -114,6 +116,31 @@ class Filter_Tests : public Test return result; } + Test::Result test_data_src_sink_flush() + { + Test::Result result("DataSinkFlush"); + +#if defined(BOTAN_HAS_CODEC_FILTERS) + std::string tmp_name("botan_test_data_src_sink_flush.tmp"); + std::ofstream outfile(tmp_name); + + Botan::Pipe pipe(new Botan::Hex_Decoder, new Botan::DataSink_Stream(outfile)); + + Botan::DataSource_Memory input_mem("65666768"); + pipe.process_msg(input_mem); + + std::ifstream outfile_read(tmp_name); + std::stringstream ss; + ss << outfile_read.rdbuf(); + std::string foo = ss.str(); + + result.test_eq("output string", ss.str(), "efgh"); + + std::remove(tmp_name.c_str()); +#endif + return result; + } + Test::Result test_pipe_io() { Test::Result result("Pipe I/O operators"); |