Bug 707078 - Check end of buffer instead of null in message header because nsByteArray is not initialized with 0. r=mbanner
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Sat, 04 Aug 2012 10:06:26 -0400
changeset 13194 1c833d465ab7c9eca1a7045ab12e1bff6354bacc
parent 13193 daad5da46f9566ed4e64217d58dc427cbb0bd0d9
child 13195 cc9bb408f84efe540ecf612905909d45b2fa61e7
push idunknown
push userunknown
push dateunknown
reviewersmbanner
bugs707078
Bug 707078 - Check end of buffer instead of null in message header because nsByteArray is not initialized with 0. r=mbanner
mailnews/local/src/nsParseMailbox.cpp
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -1048,17 +1048,17 @@ int nsParseMailMessageState::ParseHeader
     }
 
     buf = colon + 1;
     PRUint32 writeOffset = 0; // number of characters replaced with a folded space
 
 SEARCH_NEWLINE:
     // move past any non terminating characters, rewriting them if folding white space
     // exists
-    while (*buf != 0 && *buf != '\r' && *buf != '\n')
+    while (buf < buf_end && *buf != '\r' && *buf != '\n')
     {
       if (writeOffset)
         *(buf - writeOffset) = *buf;
       buf++;
     }
 
     /* If "\r\n " or "\r\n\t" is next, that doesn't terminate the header. */
     if ((buf + 2 < buf_end && (buf[0] == '\r' && buf[1] == '\n') &&