Bug 517456 - Use PL_strnchr instead of PL_strchr since the buffer is not null-terminated. Examined by Wayne Mery. r=mbanner
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -930,20 +930,21 @@ nsresult nsParseMailMessageState::StartN
return ParseEnvelope (line, lineLength);
}
/* largely lifted from mimehtml.c, which does similar parsing, sigh...
*/
nsresult nsParseMailMessageState::ParseHeaders ()
{
char *buf = m_headers.GetBuffer();
- char *buf_end = buf + m_headers.GetBufferPos();
+ uint32_t buf_length = m_headers.GetBufferPos();
+ char *buf_end = buf + buf_length;
while (buf < buf_end)
{
- char *colon = PL_strchr (buf, ':');
+ char *colon = PL_strnchr(buf, ':', buf_length);
char *end;
char *value = 0;
struct message_header *header = 0;
struct message_header receivedBy;
if (! colon)
break;