Log entire line when curldbg lacks a newline (#2526)

Previously -o curldbg=body would read uninitialized memory.
This commit is contained in:
Andrew Gaul 2024-09-28 11:35:49 +09:00 committed by GitHub
parent 6faaff10ee
commit 5691071ac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1920,6 +1920,10 @@ int S3fsCurl::RawCurlDebugFunc(const CURL* hcurl, curl_infotype type, char* data
int newline = 0; int newline = 0;
if (eol == nullptr) { if (eol == nullptr) {
eol = reinterpret_cast<char*>(memchr(p, '\r', remaining)); eol = reinterpret_cast<char*>(memchr(p, '\r', remaining));
if (eol == nullptr) {
// No newlines, just emit entire line.
eol = p + remaining;
}
} else { } else {
if (eol > p && *(eol - 1) == '\r') { if (eol > p && *(eol - 1) == '\r') {
newline++; newline++;