bug 334700 - DEBUG null deref in LogHeaders r=biesi

--HG--
extra : rebase_source : 315a625dcaffd9f284eb9e0d30a177456e606400
This commit is contained in:
Patrick McManus 2012-09-05 21:31:35 -04:00
parent 109d797a76
commit a9b91aa00a

View File

@ -53,18 +53,20 @@ static NS_DEFINE_CID(kMultiplexInputStream, NS_MULTIPLEXINPUTSTREAM_CID);
#if defined(PR_LOGGING) #if defined(PR_LOGGING)
static void static void
LogHeaders(const char *lines) LogHeaders(const char *lineStart)
{ {
nsAutoCString buf; nsAutoCString buf;
char *p; char *endOfLine;
while ((p = PL_strstr(lines, "\r\n")) != nullptr) { while ((endOfLine = PL_strstr(lineStart, "\r\n"))) {
buf.Assign(lines, p - lines); buf.Assign(lineStart, endOfLine - lineStart);
if (PL_strcasestr(buf.get(), "authorization: ") != nullptr) { if (PL_strcasestr(buf.get(), "authorization: ") ||
char *p = PL_strchr(PL_strchr(buf.get(), ' ')+1, ' '); PL_strcasestr(buf.get(), "proxy-authorization: ")) {
while (*++p) *p = '*'; char *p = PL_strchr(PL_strchr(buf.get(), ' ') + 1, ' ');
while (p && *++p)
*p = '*';
} }
LOG3((" %s\n", buf.get())); LOG3((" %s\n", buf.get()));
lines = p + 2; lineStart = endOfLine + 2;
} }
} }
#endif #endif