aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-09-07 13:12:00 -0400
committerJack Lloyd <[email protected]>2017-09-07 13:12:00 -0400
commitacff905dfeb2055f0e78d5b5ea0763896e9577d3 (patch)
tree702dd4823ed310b26885506546e0660c27498711
parent9d143683c8cdb5feb941ff19e1004540d4a028ab (diff)
Fix bad write if a socket error occurred using --dump-traces
Found by Coverity
-rw-r--r--src/cli/tls_server.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cli/tls_server.cpp b/src/cli/tls_server.cpp
index fba0aa95f..92d227673 100644
--- a/src/cli/tls_server.cpp
+++ b/src/cli/tls_server.cpp
@@ -200,11 +200,6 @@ class TLS_Server final : public Command
uint8_t buf[4 * 1024] = { 0 };
ssize_t got = ::read(fd, buf, sizeof(buf));
- if(dump_stream)
- {
- dump_stream->write(reinterpret_cast<const char*>(buf), got);
- }
-
if(got == -1)
{
error_output() << "Error in socket read - " << strerror(errno) << std::endl;
@@ -217,6 +212,11 @@ class TLS_Server final : public Command
break;
}
+ if(dump_stream)
+ {
+ dump_stream->write(reinterpret_cast<const char*>(buf), got);
+ }
+
server.received_data(buf, got);
while(server.is_active() && !pending_output.empty())