[Kamailio-Devel] [ openser-Bugs-2202188 ] "strncmp" should not be used to match header names

SourceForge.net noreply at sourceforge.net
Tue Jan 6 23:45:13 CET 2009


Bugs item #2202188, was opened at 2008-10-28 01:23
Message generated for change (Comment added) made by miconda
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2202188&group_id=139143

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: ver devel
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Iñaki Baz (ibc_sf)
>Assigned to: Daniel-Constantin Mierla (miconda)
Summary: "strncmp" should not be used to match header names

Initial Comment:
All those results are bugs since they expect header names being case sensitive 
while SIP syntax is case insensitive in header names:

/usr/src/kamailio-trunk$ grep -ri "strncmp(h" * | grep -v svn
sources/modules/peering/verify.c:       if (strncmp(hf->name.s, "P-Request-Hash",
sources/modules/pua_bla/notify.c:               if(strncmp(hdr->name.s, "Subscription-State",18)==0 )
sources/modules/rls/subscribe.c:                if(strncmp(hdr->name.s, "Support", 7)== 0)
sources/modules/rls/subscribe.c:                        if(strncmp(hdr->body.s+ i, "eventlist", 9)== 0)
sources/modules/rls/resource_notify.c:          if(strncmp(hdr->name.s, "Subscription-State", 18)==0)
sources/modules/pua_mi/mi_func.c:                       if(strncmp(hdr->name.s, "SIP-ETag",8)==0 )
sources/modules/pua/send_publish.c:             if(strncmp(hdr->name.s, "SIP-ETag",8)==0 )
sources/modules/pua_xmpp/simple2xmpp.c:                 if(strncmp(hdr->name.s, "Subscription-State",18)==0 )
sources/modules/pua_xmpp/simple2xmpp.c:                         if(strncmp(hdr->name.s, "Subscription-State",18)==0 )
sources/modules/pua_xmpp/simple2xmpp.c:                 if(hdr && strncmp(hdr->body.s,"terminated", 10)== 0)
sources/modules/presence/publish.c:             if(strncmp(hdr->name.s, "SIP-If-Match",12)==0||
sources/modules/presence/publish.c:                             strncmp(hdr->name.s,"Sip-If-Match",12)==0 )
sources/msg_translator.c:               if (he && (strncmp(he->h_name, name->s, name->len)==0))
sources/msg_translator.c:                       if (strncmp(he->h_aliases[i],name->s, name->len)==0)

----------------------------------------------------------------------

>Comment By: Daniel-Constantin Mierla (miconda)
Date: 2009-01-07 00:45

Message:
Trunk is using dedicated function to match headers by string name. Please
reopen and point the file if some occurrence was forgotten.

----------------------------------------------------------------------

Comment By: Daniel-Constantin Mierla (miconda)
Date: 2008-10-30 20:43

Message:
the textops module has the is_present_hf() function that do the matching
properly.

There is another item on the tracker regarding similar issues regarding
matching part of SIP message. I think it is better to introduce some APIs
to be used everywhere. For headers will be:
- compare header name
- get header structure
- get next header with same name structure
- add/insert header
- remove header

Now there are a lot of different implementations, hard to track and
maintain.

Daniel

----------------------------------------------------------------------

Comment By: Klaus Darilion (klaus_darilion)
Date: 2008-10-28 15:17

Message:
probably we should fix this like Bogdan in opensips in a generic way - to
verify also the length of the header name.
http://opensips.svn.sourceforge.net/opensips/?rev=4833&view=rev

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2202188&group_id=139143



More information about the Devel mailing list