From a9b91aa00a5b9a2ec6c46f1c4cdd377794a57c74 Mon Sep 17 00:00:00 2001 From: Patrick McManus Date: Wed, 5 Sep 2012 21:31:35 -0400 Subject: [PATCH] bug 334700 - DEBUG null deref in LogHeaders r=biesi --HG-- extra : rebase_source : 315a625dcaffd9f284eb9e0d30a177456e606400 --- netwerk/protocol/http/nsHttpTransaction.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index a4ce0dfd5c9..0d26813af94 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -53,18 +53,20 @@ static NS_DEFINE_CID(kMultiplexInputStream, NS_MULTIPLEXINPUTSTREAM_CID); #if defined(PR_LOGGING) static void -LogHeaders(const char *lines) +LogHeaders(const char *lineStart) { nsAutoCString buf; - char *p; - while ((p = PL_strstr(lines, "\r\n")) != nullptr) { - buf.Assign(lines, p - lines); - if (PL_strcasestr(buf.get(), "authorization: ") != nullptr) { - char *p = PL_strchr(PL_strchr(buf.get(), ' ')+1, ' '); - while (*++p) *p = '*'; + char *endOfLine; + while ((endOfLine = PL_strstr(lineStart, "\r\n"))) { + buf.Assign(lineStart, endOfLine - lineStart); + if (PL_strcasestr(buf.get(), "authorization: ") || + PL_strcasestr(buf.get(), "proxy-authorization: ")) { + char *p = PL_strchr(PL_strchr(buf.get(), ' ') + 1, ' '); + while (p && *++p) + *p = '*'; } LOG3((" %s\n", buf.get())); - lines = p + 2; + lineStart = endOfLine + 2; } } #endif