Navigation



Ignore:
Timestamp:
Jul 8, 2010, 4:19:28 PM (14 years ago)
Author:
Alexandre Westfahl <awestfahl@freediameter.net>
Branch:
default
Phase:
public
Message:

Fix for ticket 8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_sip/multimediaauth.c

    r368 r409  
    4141        struct msg *ans, *qry;
    4242        struct avp *avp, *a2, *authdataitem;
    43         struct msg_hdr * header = NULL;
     43        //struct msg_hdr * header = NULL;
    4444        struct avp_hdr * avphdr=NULL, *avpheader=NULL, *avpheader_auth=NULL,*digestheader=NULL;
    4545        union avp_value val;
     
    4848        char * result;
    4949        char password[51];
    50         int idx=0, idx2=0, number_of_auth_items=0,i=0;
     50        int idx=0, number_of_auth_items=0,i=0;
    5151        //Flags and variables for Database
    5252        int sipurinotstored=0, authenticationpending=0, querylen=0, usernamelen=0;
     
    7070
    7171
    72         /* Add the appropriate command code & Auth-Application-Id */
     72        /* Add the appropriate command code & Auth-Application-Id
    7373        {
    7474               
     
    7979               
    8080               
    81                 /* Add the Auth-Application-Id */
     81                // Add the Auth-Application-Id
    8282                {
    8383                        CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Application_Id, 0, &avp ) );
     
    8787                        CHECK_FCT( fd_msg_avp_add ( ans, MSG_BRW_LAST_CHILD, avp) );
    8888                }
    89         }
     89        }*/
    9090       
    9191       
     
    125125                        username=malloc(avphdr->avp_value->os.len*2+1);
    126126                        //We purify username not to have forbidden characters
    127                         usernamelen=mysql_real_escape_string(conn, username, avphdr->avp_value->os.data, avphdr->avp_value->os.len);
    128                        
    129                        
    130                         if((strncmp(avpheader->avp_value->os.data,"REGISTER",avpheader->avp_value->os.len)==0))
     127                        usernamelen=mysql_real_escape_string(conn, username, (const char *)avphdr->avp_value->os.data, avphdr->avp_value->os.len);
     128                       
     129                       
     130                        if((strncmp((const char *)avpheader->avp_value->os.data,"REGISTER",avpheader->avp_value->os.len)==0))
    131131                        {
    132132                                not_found=1;
     
    153153                                while ((row = mysql_fetch_row(res)) != NULL)
    154154                                {
    155                                         if(row[0]!="")
     155                                        if(strlen(row[0])>0)
    156156                                        {
    157157                                                strcpy(password,row[0]);
     
    195195                                while ((row = mysql_fetch_row(res)) != NULL)
    196196                                {
    197                                         if(strncmp(avphdr->avp_value->os.data,row[0],avphdr->avp_value->os.len)==0)
     197                                        if(strncmp((const char *)avphdr->avp_value->os.data,row[0],avphdr->avp_value->os.len)==0)
    198198                                        {
    199199                                                not_found=0;
     
    225225                                sipuri=malloc(avphdr->avp_value->os.len*2+1);
    226226                                //We purify SIP-URI not to have forbidden characters
    227                                 sipurilen=mysql_real_escape_string(conn, sipuri, avphdr->avp_value->os.data, avphdr->avp_value->os.len);
     227                                sipurilen=mysql_real_escape_string(conn, sipuri, (const char *)avphdr->avp_value->os.data, avphdr->avp_value->os.len);
    228228                               
    229229                               
     
    245245                                while ((row = mysql_fetch_row(res)) != NULL)
    246246                                {
    247                                         if(strncmp(avphdr->avp_value->os.data,row[0],avphdr->avp_value->os.len)==0)
     247                                        if(strncmp((const char *)avphdr->avp_value->os.data,row[0],avphdr->avp_value->os.len)==0)
    248248                                        {
    249249                                                not_found=0;
     
    361361                                                                {
    362362                                                                        CHECK_FCT( fd_msg_avp_new ( sip_dict.Digest_QOP, 0, &a2 ) );
    363                                                                         val.os.data="auth";
    364                                                                         val.os.len=strlen(val.os.data);
     363                                                                        val.os.data=(unsigned char *)"auth";
     364                                                                        val.os.len=strlen((const char *)val.os.data);
    365365                                                                        CHECK_FCT( fd_msg_avp_setvalue( a2, &val ) );
    366366                                                                        CHECK_FCT( fd_msg_avp_add( sipAuthenticate, MSG_BRW_LAST_CHILD, a2 ) );
     
    387387                                                                        CHECK_FCT( fd_sess_state_store ( ds_sess_hdl, sess, &storednonce )); 
    388388                                                                       
    389                                                                         val.os.data=nonce;
     389                                                                        val.os.data=(unsigned char *)nonce;
    390390                                                                        val.os.len=NONCE_SIZE * 2;
    391391                                                                       
     
    396396                                                                {
    397397                                                                        CHECK_FCT( fd_msg_avp_new ( sip_dict.Digest_Algorithm, 0, &a2 ) );
    398                                                                         val.os.data="MD5";
    399                                                                         val.os.len=strlen(val.os.data);
     398                                                                        val.os.data=(unsigned char *)"MD5";
     399                                                                        val.os.len=strlen((const char *)val.os.data);
    400400                                                                        CHECK_FCT( fd_msg_avp_setvalue( a2, &val ) );
    401401                                                                        CHECK_FCT( fd_msg_avp_add( sipAuthenticate, MSG_BRW_LAST_CHILD, a2 ) );
     
    464464                                                                        //uint8_t bufferresp[DIGEST_LEN];
    465465                                                                        //char response[DIGEST_LEN*2+1];
    466                                                                         int i=0;
     466                                                                       
    467467                                                                       
    468468                                                                        //We extract all the data we need
     
    640640                                                                       
    641641                                                                        DigestCalcHA1(digest_algorithm, digest_username, digest_realm, password, digest_nonce,digest_cnonce, HA1);
    642                                                                        
    643                                                         DigestCalcResponse(HA1, digest_nonce, digest_noncecount, digest_cnonce, digest_qop,digest_method, digest_uri, HA2, response);
     642                                                                DigestCalcResponse(HA1, digest_nonce, digest_noncecount, digest_cnonce, digest_qop,digest_method, digest_uri, HA2, response);
    644643                                                                       
    645644               
     
    677676                                                                                //Digest-HA1 MUST be used instead of Digest-Response-Auth if Digest-Qop is 'auth-int'.
    678677                                                                                CHECK_FCT( fd_msg_avp_new ( sip_dict.Digest_HA1, 0, &a2 ) );
    679                                                                                 val.os.data=HA1;
     678                                                                                val.os.data=(unsigned char *)HA1;
    680679                                                                                val.os.len=HASHHEXLEN+1;
    681680                                                                                CHECK_FCT( fd_msg_avp_setvalue( a2, &val ) );
     
    686685                                                                                //Digest-Response-Auth MUST be used instead of Digest-HA1 if Digest-Qop is 'auth'.
    687686                                                                                CHECK_FCT( fd_msg_avp_new ( sip_dict.Digest_Response_Auth, 0, &a2 ) );
    688                                                                                 val.os.data=responseauth;
     687                                                                                val.os.data=(unsigned char *)responseauth;
    689688                                                                                val.os.len=DIGEST_LEN*2;
    690689                                                                                CHECK_FCT( fd_msg_avp_setvalue( a2, &val ) );
Note: See TracChangeset for help on using the changeset viewer.