Bug 1284302 - fix crash in nsImapServerResponseParser::ParseIMAPServerResponse. r=jorgk
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Wed, 13 Dec 2017 22:31:48 +0200
changeset 29771 8111785ba27ec36701b5f216dc80509c8960ea3a
parent 29770 d81799e4dedf7968c514c18376a49174ebb9a972
child 29772 cdceb81023b89971e63cd7916fbe394d3497dc1f
push id2108
push userclokep@gmail.com
push dateMon, 22 Jan 2018 17:53:55 +0000
treeherdercomm-beta@c44930d8ad9b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1284302
Bug 1284302 - fix crash in nsImapServerResponseParser::ParseIMAPServerResponse. r=jorgk
mailnews/imap/src/nsImapServerResponseParser.cpp
--- a/mailnews/imap/src/nsImapServerResponseParser.cpp
+++ b/mailnews/imap/src/nsImapServerResponseParser.cpp
@@ -194,30 +194,30 @@ void nsImapServerResponseParser::ParseIM
         PR_FREEIF(fCurrentLine);
         fCurrentLine = aGreetingWithCapability;
       }
 
       do {
         AdvanceToNextToken();
 
         // untagged responses [RFC3501, Sec. 2.2.2]
-        while (ContinueParse() && !PL_strcmp(fNextToken, "*") )
+        while (ContinueParse() && fNextToken && *fNextToken == '*')
         {
           response_data();
           if (ContinueParse())
           {
             if (!fAtEndOfLine)
               SetSyntaxError(true);
             else if (!inIdle && !fCurrentCommandFailed && !aGreetingWithCapability)
               AdvanceToNextToken();
           }
         }
 
         // command continuation request [RFC3501, Sec. 7.5]
-        if (ContinueParse() && *fNextToken == '+')	// never pipeline APPEND or AUTHENTICATE
+        if (ContinueParse() && fNextToken && *fNextToken == '+')	// never pipeline APPEND or AUTHENTICATE
         {
           NS_ASSERTION((fNumberOfTaggedResponsesExpected - numberOfTaggedResponsesReceived) == 1,
             " didn't get the number of tagged responses we expected");
           numberOfTaggedResponsesReceived = fNumberOfTaggedResponsesExpected;
           if (commandToken && !PL_strcasecmp(commandToken, "authenticate") && placeInTokenString &&
             (!PL_strncasecmp(placeInTokenString, "CRAM-MD5", strlen("CRAM-MD5"))
              || !PL_strncasecmp(placeInTokenString, "NTLM", strlen("NTLM"))
              || !PL_strncasecmp(placeInTokenString, "GSSAPI", strlen("GSSAPI"))
@@ -234,17 +234,17 @@ void nsImapServerResponseParser::ParseIM
           response_tagged();
 
       } while (ContinueParse() && !inIdle && (numberOfTaggedResponsesReceived < fNumberOfTaggedResponsesExpected));
 
       // check and see if the server is waiting for more input
       // it's possible that we ate this + while parsing certain responses (like cram data),
       // in these cases, the parsing routine for that specific command will manually set
       // fWaitingForMoreClientInput so we don't lose that information....
-      if ((fNextToken && (*fNextToken == '+')) || inIdle)
+      if ((fNextToken && *fNextToken == '+') || inIdle)
       {
         fWaitingForMoreClientInput = true;
       }
       // if we aren't still waiting for more input....
       else if (!fWaitingForMoreClientInput && !aGreetingWithCapability)
       {
         if (ContinueParse())
           response_done();