From dd0c5843c3afe966b20147e60266f9f3c2dedb2e Mon Sep 17 00:00:00 2001 From: Knock Date: Thu, 5 Dec 2019 13:42:24 +0100 Subject: [PATCH 1/2] fix https://github.com/basiliscos/cpp-bredis/issues/37 --- include/bredis/impl/protocol.ipp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/bredis/impl/protocol.ipp b/include/bredis/impl/protocol.ipp index 9c6e939a..f0e5c82b 100644 --- a/include/bredis/impl/protocol.ipp +++ b/include/bredis/impl/protocol.ipp @@ -442,7 +442,7 @@ inline std::size_t size_for_int(std::size_t arg) { ++r; arg /= 10; } - return r; + return std::max(1, r); /* if r == 0 we clamp max to 1 to allow minimum containing "0" as char */ } inline std::size_t command_size(const single_command_t &cmd) { @@ -477,9 +477,11 @@ inline void Protocol::serialize(DynamicBuffer &buff, it += bytes; total += bytes; - buffer_copy(it, buffer(arg.data(), arg.size())); - it += arg.size(); - total += arg.size(); + if(!arg.empty()) { + buffer_copy(it, buffer(arg.data(), arg.size())); + it += arg.size(); + total += arg.size(); + } buffer_copy(it, buffer("\r\n", terminator.size)); total += terminator.size; From 9df81dbbbcead6b54fe3ac9d3e936ebd226b78bc Mon Sep 17 00:00:00 2001 From: Ronny Nowak Date: Fri, 6 Dec 2019 11:30:40 +0100 Subject: [PATCH 2/2] Update README.md update change log and contributors --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 1afeefa0..4ad7ee3f 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ Boost::ASIO low-level redis client (connector) ## Changelog +### 0.09 +- [bugfix] critical bug in protcol serialization on empty values + ### 0.08 - relaxed c++ compiler requirements: c++11 can be used instead of c++14 @@ -764,6 +767,7 @@ MIT - [Vinnie Falco](https://github.com/vinniefalco) - [Stephen Coleman](https://github.com/omegacoleman) - [maxtorm miximtor](https://github.com/miximtor) +- [Ronny Nowak](https://github.com/dargun) ## See also - https://github.com/Cylix/cpp_redis