diff options
author | Jack Lloyd <[email protected]> | 2017-12-14 14:28:05 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-12-14 14:28:05 -0500 |
commit | 5c7f3b45198655bd0fae435c428b1f9256610ac5 (patch) | |
tree | 0bc240708b1b8e2370a26df53e79bd284d0bcc50 /src/lib/compression/zlib | |
parent | 5e50a685750091849f59194fed9c5bef0685284c (diff) |
Default to not setting a timestamp in the gzip header
But allow it to be set via a constructor arg.
Diffstat (limited to 'src/lib/compression/zlib')
-rw-r--r-- | src/lib/compression/zlib/zlib.cpp | 7 | ||||
-rw-r--r-- | src/lib/compression/zlib/zlib.h | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/compression/zlib/zlib.cpp b/src/lib/compression/zlib/zlib.cpp index 14bc12b27..57494e225 100644 --- a/src/lib/compression/zlib/zlib.cpp +++ b/src/lib/compression/zlib/zlib.cpp @@ -10,7 +10,6 @@ #include <botan/zlib.h> #include <botan/internal/compress_utils.h> #include <botan/exceptn.h> -#include <ctime> #include <zlib.h> namespace Botan { @@ -123,12 +122,12 @@ class Deflate_Decompression_Stream final : public Zlib_Decompression_Stream class Gzip_Compression_Stream final : public Zlib_Compression_Stream { public: - Gzip_Compression_Stream(size_t level, int wbits, uint8_t os_code) : + Gzip_Compression_Stream(size_t level, int wbits, uint8_t os_code, uint64_t hdr_time) : Zlib_Compression_Stream(level, wbits, 16) { clear_mem(&m_header, 1); m_header.os = os_code; - m_header.time = std::time(nullptr); + m_header.time = static_cast<uLong>(hdr_time); int rc = deflateSetHeader(streamp(), &m_header); if(rc != Z_OK) @@ -169,7 +168,7 @@ Compression_Stream* Deflate_Decompression::make_stream() const Compression_Stream* Gzip_Compression::make_stream(size_t level) const { - return new Gzip_Compression_Stream(level, 15, m_os_code); + return new Gzip_Compression_Stream(level, 15, m_os_code, m_hdr_time); } Compression_Stream* Gzip_Decompression::make_stream() const diff --git a/src/lib/compression/zlib/zlib.h b/src/lib/compression/zlib/zlib.h index 2dd897981..cc0060344 100644 --- a/src/lib/compression/zlib/zlib.h +++ b/src/lib/compression/zlib/zlib.h @@ -63,11 +63,13 @@ class BOTAN_PUBLIC_API(2,0) Deflate_Decompression final : public Stream_Decompre class BOTAN_PUBLIC_API(2,0) Gzip_Compression final : public Stream_Compression { public: - explicit Gzip_Compression(uint8_t os_code = 255) : m_os_code(os_code) {} + explicit Gzip_Compression(uint8_t os_code = 255, uint64_t hdr_time = 0) : + m_hdr_time(hdr_time), m_os_code(os_code) {} std::string name() const override { return "Gzip_Compression"; } private: Compression_Stream* make_stream(size_t level) const override; + const uint64_t m_hdr_time; const uint8_t m_os_code; }; |