linphone-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Linphone-developers] coreapi/sal_eXosip2_sdp.c keywordcmp bug


From: Ghislain Mary
Subject: Re: [Linphone-developers] coreapi/sal_eXosip2_sdp.c keywordcmp bug
Date: Fri, 15 Mar 2013 10:23:44 +0100

Hi Sami,

Thanks for pointing out this issue. I just pushed a fix for it.

Cheers,
Ghislain

On 12 March 2013 20:29, Sami Farin <address@hidden> wrote:
#define keywordcmp(key,b) strncmp(key,b,sizeof(key))

two callers pass a pointer to it, giving sizeof 4 or 8.

my suggestion is something like this.

diff --git a/coreapi/sal_eXosip2_sdp.c b/coreapi/sal_eXosip2_sdp.c
index 9297077..2c7b843 100644
--- a/coreapi/sal_eXosip2_sdp.c
+++ b/coreapi/sal_eXosip2_sdp.c
@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include <eXosip2/eXosip.h>

 #define keywordcmp(key,b) strncmp(key,b,sizeof(key))
+#define keywordcmp_ptr(key,b) strncmp(key,b,strlen(key)+1)

 #ifdef FOR_LATER

@@ -63,7 +64,7 @@ static const char *sdp_message_a_attr_value_get_with_pt(sdp_message_t *sdp,int p
        char *tmp;
        sdp_attribute_t *attr;
        for (i=0;(attr=sdp_message_attribute_get(sdp,pos,i))!=NULL;i++){
-               if (keywordcmp(field,attr->a_att_field)==0 && attr->a_att_value!=NULL){
+               if (keywordcmp_ptr(field,attr->a_att_field)==0 && attr->a_att_value!=NULL){
                        int nb = sscanf(attr->a_att_value,"%i %n",&tmppt,&scanned);
                        /* the return value may depend on how %n is interpreted by the libc: see manpage*/
                        if (nb == 1 || nb==2 ){
@@ -85,7 +86,7 @@ static const char *sdp_message_a_attr_value_get(sdp_message_t *sdp,int pos,const
        int i;
        sdp_attribute_t *attr;
        for (i=0;(attr=sdp_message_attribute_get(sdp,pos,i))!=NULL;i++){
-               if (keywordcmp(field,attr->a_att_field)==0 && attr->a_att_value!=NULL){
+               if (keywordcmp_ptr(field,attr->a_att_field)==0 && attr->a_att_value!=NULL){
                        return attr->a_att_value;
                }
        }


--
Do what you love because life is too short for anything else.


_______________________________________________
Linphone-developers mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/linphone-developers


reply via email to

[Prev in Thread] Current Thread [Next in Thread]