From 14f73197c7fb421261834997ada0b457cd4bff05 Mon Sep 17 00:00:00 2001 From: benank Date: Tue, 10 Dec 2019 23:10:50 -0800 Subject: [PATCH] Fix occasional response corruption Due to a non null terminated buffer being used in string stream --- source/internal/win_http_client.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/internal/win_http_client.cpp b/source/internal/win_http_client.cpp index 6cc4ba7..08f4148 100644 --- a/source/internal/win_http_client.cpp +++ b/source/internal/win_http_client.cpp @@ -157,8 +157,9 @@ int win_http_client::make_request(const std::string& uri, const std::string& ver char buffer[1024]; memset(buffer, 0, ARRAYSIZE(buffer)); DWORD bytesRead = 0; - while (winHttpApi.win_http_read_data(request.get(), buffer, ARRAYSIZE(buffer), &bytesRead) && bytesRead) + while (winHttpApi.win_http_read_data(request.get(), buffer, ARRAYSIZE(buffer) - 1, &bytesRead) && bytesRead) { + buffer[bytesRead] = '\0'; responseStream << buffer; bytesRead = 0; memset(buffer, 0, ARRAYSIZE(buffer));