From c542a5ae0371895ee776b68de94e315dc1b453a8 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Wed, 1 Nov 2017 11:24:33 -0400 Subject: [PATCH] net: Remove extra spaces from WinHttp log messages I recently (90054edf6202) removed the extra spaces from ntdll log messages. The winhttp messages have the same problem. Context: https://groups.google.com/a/chromium.org/d/topic/crashpad-dev/kD3a9Jekzx0 Change-Id: I49682ba99c3dfe1cd4c49507806cf8adf154bc9f Reviewed-on: https://chromium-review.googlesource.com/749305 Reviewed-by: Scott Graham --- util/net/http_transport_win.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/net/http_transport_win.cc b/util/net/http_transport_win.cc index 9698df30..dc3eeeb7 100644 --- a/util/net/http_transport_win.cc +++ b/util/net/http_transport_win.cc @@ -101,6 +101,12 @@ std::string WinHttpMessage(const char* extra) { GetLastError(), error_code); } + + // Most system messages end in a space. Remove the space if it’s there, + // because the StringPrintf() below includes one. + if (len >= 1 && msgbuf[len - 1] == ' ') { + msgbuf[len - 1] = '\0'; + } return base::StringPrintf("%s: %s (0x%lx)", extra, msgbuf, error_code); }