< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] Parse bug in NameAddr


The code in question...

*snip*
      if (!pb.eof() && *pb.position() == Symbols::DOUBLE_QUOTE[0])
      {
         start = pb.skipChar(Symbols::DOUBLE_QUOTE[0]);
         pb.skipToEndQuote();
         pb.data(mDisplayName, start);
         pb.skipChar(Symbols::DOUBLE_QUOTE[0]);
         laQuote = true;
         pb.skipToChar(Symbols::LA_QUOTE[0]);
         if (pb.eof())
         {
            throw ParseException("Expected '<'", __FILE__, __LINE__);
         }
         else
         {
            pb.skipChar(Symbols::LA_QUOTE[0]);
         }
      }
      else if (!pb.eof() && *pb.position() == Symbols::LA_QUOTE[0])
      {
         pb.skipChar(Symbols::LA_QUOTE[0]);
         laQuote = true;
      }
      else
      {
         start = pb.position();
         pb.skipToChar(Symbols::LA_QUOTE[0]);
         pb.skipBackWhitespace();
         if (pb.eof())
         {
            pb.reset(start);
         }
         else
         {
            laQuote = true;
            pb.data(mDisplayName, start);
            pb.skipToChar(Symbols::LA_QUOTE[0]);
            pb.skipChar(Symbols::LA_QUOTE[0]);
         }
      }
      pb.skipWhitespace();
      mUri.parse(pb);

*snip*

This code appears to be attempting to distinguish between a name-addr and an addr-spec as specified in 3261, by searching for a "<". Unfortunately, we never end up at eof in the addr-spec case because we skip back over the "\r\n". It looks like the skipBackWhitespace() call belongs inside the else clause immediately following the check for pb.eof(), right before we grab the display-name.

Best regards,
Byron Campen

Attachment: smime.p7s
Description: S/MIME cryptographic signature