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

[reSIProcate] multiple values in single-value headers are allowed


SipMessage will allow multiple header-field-values in a single-value header, and will re-encode these extra headers. Furthermore, the SipMessage::header() interface cannot be used to discover whether these extra header-field-values are present.

*snip*
In case multi01:
Original text:
INVITE sip:user@xxxxxxxxxxx SIP/2.0
Via: SIP/2.0/UDP 192.0.2.25;branch=z9hG4bKkdjuw
Max-Forwards: 70
CSeq: 5 INVITE
CSeq: 59 INVITE
From: sip:caller@xxxxxxxxxxx;tag=3413415
From: sip:caller@xxxxxxxxxxx;tag=2923420123
Content-Type: application/sdp
l: 154
Max-Forwards: 5

v=0
o=mhandley 29739 7272939 IN IP4 192.0.2.25
s=-
c=IN IP4 192.0.2.25
t=0 0
m=audio 49217 RTP/AVP 0 12
m=video 3227 RTP/AVP 31
a=rtpmap:31 LPC


Encoded form:
INVITE sip:user@xxxxxxxxxxx SIP/2.0
Via: SIP/2.0/UDP 192.0.2.25;branch=z9hG4bKkdjuw
Max-Forwards: 70
Max-Forwards: 5
From: <sip:caller@xxxxxxxxxxx>;tag=3413415
From: <sip:caller@xxxxxxxxxxx>;tag=2923420123
CSeq: 5 INVITE
CSeq: 59 INVITE
Content-Type: application/sdp
Content-Length: 154

v=0
o=mhandley 29739 7272939 IN IP4 192.0.2.25
s=-
c=IN IP4 192.0.2.25
t=0 0
m=audio 49217 RTP/AVP 0 12
m=video 3227 RTP/AVP 31
a=rtpmap:31 LPC
*snip*

Relevant code:

in SipMessage::addHeader()
*snip*
   if (header != Headers::UNKNOWN)
   {
      if (mHeaders[header] == 0)
      {
         mHeaders[header] = new HeaderFieldValueList;
      }
      if (len)
      {
         mHeaders[header]->push_back(new HeaderFieldValue(start, len));
      }
   }
*snip*

In HeaderFieldValueList::encode()
*snip*
      if (!headerName.empty())
      {
         str << headerName << Symbols::COLON[0] << Symbols::SPACE[0];
      }

      for (HeaderFieldValueList::const_iterator j = begin();
           j != end(); j++)
      {
         if (j != begin())
         {
            if (Headers::isCommaEncoding(static_cast<Headers::Type>(headerEnum)))
            {
               str << Symbols::COMMA[0] << Symbols::SPACE[0];
            }
            else
            {
               str << Symbols::CRLF << headerName << Symbols::COLON << Symbols::SPACE;
            }
         }
         (*j)->encode(str);
      }
      str << Symbols::CRLF;

*snip*


I suggest that we prevent these extraneous headers from being added successfully.

Best regards,
Byron Campen

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