summaryrefslogtreecommitdiff
path: root/extensions/app_sip
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/app_sip')
-rw-r--r--extensions/app_sip/TODO4
-rw-r--r--extensions/app_sip/app_sip.h2
-rw-r--r--extensions/app_sip/libapp_sip.c48
-rw-r--r--extensions/app_sip/md5.c3
-rw-r--r--extensions/app_sip/multimediaauth.c26
-rw-r--r--extensions/app_sip/registrationtermination.c2
6 files changed, 19 insertions, 66 deletions
diff --git a/extensions/app_sip/TODO b/extensions/app_sip/TODO
index 661face..bef88f7 100644
--- a/extensions/app_sip/TODO
+++ b/extensions/app_sip/TODO
@@ -49,6 +49,10 @@ TODO List
* add mutex on mysql writing
* check multithreading of mysql!
* get destination host in database for RTR and PPR
+* libapp_sip.c: fix username_pure memory leaks
+* app_sip_MAR_cb:
+ - too much mysql_real_escape_string() use, both within the function and functions it calls
+ - on error, leaks allocated: sipuri, username, query.
diff --git a/extensions/app_sip/app_sip.h b/extensions/app_sip/app_sip.h
index a6532b7..09960c6 100644
--- a/extensions/app_sip/app_sip.h
+++ b/extensions/app_sip/app_sip.h
@@ -110,8 +110,6 @@ void DigestCalcHA1(char * pszAlg,char * pszUserName,char * pszRealm,char * pszPa
void DigestCalcResponse(HASHHEX HA1,char * pszNonce,char * pszNonceCount,char * pszCNonce,char * pszQop,char * pszMethod,char * pszDigestUri,HASHHEX HEntity,HASHHEX Response);
void DigestCalcResponseAuth(HASHHEX HA1,char * pszNonce,char * pszNonceCount,char * pszCNonce,char * pszQop,char * pszMethod,char * pszDigestUri,HASHHEX HEntity,HASHHEX Response);
-int fd_avp_search_avp ( struct avp * groupedavp, struct dict_object * what, struct avp ** avp );
-
//thread procedure
void *rtr_socket(void *);
void *ppr_socket(void *);
diff --git a/extensions/app_sip/libapp_sip.c b/extensions/app_sip/libapp_sip.c
index 6442ff4..ffe1c80 100644
--- a/extensions/app_sip/libapp_sip.c
+++ b/extensions/app_sip/libapp_sip.c
@@ -66,54 +66,6 @@ void calc_md5(char *clearDigest, char * data)
return;
}
-
-/* Search a given AVP model in an AVP (extracted from libfreediameter/message.c ) */
-int fd_avp_search_avp ( struct avp * groupedavp, struct dict_object * what, struct avp ** avp )
-{
- struct avp * nextavp;
- struct avp_hdr * nextavphdr;
- struct dict_avp_data dictdata;
-
-
- TRACE_ENTRY("%p %p %p", groupedavp, what, avp);
-
- CHECK_FCT( fd_dict_getval(what, &dictdata) );
-
- // Loop only in the group AVP
- CHECK_FCT( fd_msg_browse(groupedavp, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL) );
- CHECK_FCT( fd_msg_avp_hdr( nextavp, &nextavphdr ) );
-
- while (nextavphdr) {
-
- if ( (nextavphdr->avp_code == dictdata.avp_code) && (nextavphdr->avp_vendor == dictdata.avp_vendor) ) // always 0 if no Vendor flag
- {
- break;
- }
-
- // Otherwise move to next AVP in the grouped AVP
- CHECK_FCT( fd_msg_browse(nextavp, MSG_BRW_NEXT, (void *)&nextavp, NULL) );
-
- if(nextavp!=NULL)
- {
- CHECK_FCT( fd_msg_avp_hdr( nextavp, &nextavphdr ) );
- }
- else
- nextavphdr=NULL;
- }
- if (avp)
- *avp = nextavp;
-
- if (avp && nextavp) {
- struct dictionary * dict;
- CHECK_FCT( fd_dict_getdict( what, &dict) );
- CHECK_FCT_DO( fd_msg_parse_dict( nextavp, dict, NULL ), );
- }
-
- if (avp || nextavp)
- return 0;
- else
- return ENOENT;
-}
struct avp_hdr *walk_digest(struct avp *avp, int avp_code)
{
struct avp_hdr *temphdr=NULL;
diff --git a/extensions/app_sip/md5.c b/extensions/app_sip/md5.c
index 4079bda..11b18f5 100644
--- a/extensions/app_sip/md5.c
+++ b/extensions/app_sip/md5.c
@@ -309,8 +309,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
- ((u32 *) ctx->in)[14] = ctx->bits[0];
- ((u32 *) ctx->in)[15] = ctx->bits[1];
+ os_memcpy(&ctx->in[56], &ctx->bits[0], 8);
MD5Transform(ctx->buf, (u32 *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
diff --git a/extensions/app_sip/multimediaauth.c b/extensions/app_sip/multimediaauth.c
index 12c1bcb..cb368da 100644
--- a/extensions/app_sip/multimediaauth.c
+++ b/extensions/app_sip/multimediaauth.c
@@ -50,7 +50,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
union avp_value val;
int found_cnonce=0;
struct avp * tempavp=NULL,*sipAuthentication=NULL,*sipAuthenticate=NULL;
- char * result;
+ char * result = NULL;
char password[51];
int idx=0, number_of_auth_items=0,i=0, ret=0;
//Flags and variables for Database
@@ -148,7 +148,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
if(not_found)
{
- TRACE_DEBUG(FULL,"The user %s doesn't exist!",username);
+ TRACE_DEBUG(FULL,"The user %s doesn't exist!", avphdr->avp_value->os.data);
result="DIAMETER_ERROR_USER_UNKNOWN";
free(username);
goto out;
@@ -320,7 +320,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
//CHECK_FCT(fd_msg_browse ( avp, MSG_BRW_WALK, &avp, NULL) );
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_CNonce, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_CNonce, &a2 ));
if(a2!=NULL)
found_cnonce=1;
@@ -457,7 +457,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
char * digest_username=NULL, *digest_uri=NULL, *digest_response=NULL, *digest_realm=NULL, *digest_nonce=NULL, *digest_method=NULL, *digest_qop=NULL, *digest_algorithm=NULL, *digest_cnonce=NULL, *digest_noncecount=NULL;
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Nonce, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Nonce, &a2 ));
if(a2!=NULL)
{
CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );
@@ -486,7 +486,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
}
}
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Response, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Response, &a2 ));
if(a2!=NULL)
{
CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );
@@ -500,7 +500,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
}
}
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Realm, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Realm, &a2 ));
if(a2!=NULL)
{
CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );
@@ -514,7 +514,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
}
}
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Method, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Method, &a2 ));
if(a2!=NULL)
{
CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );
@@ -530,7 +530,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
else
digest_method="";
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_URI, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_URI, &a2 ));
if(a2!=NULL)
{
CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );
@@ -544,7 +544,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
}
}
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_QOP, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_QOP, &a2 ));
if(a2!=NULL)
{
CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );
@@ -559,7 +559,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
}
else
digest_qop=NULL;
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Algorithm, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Algorithm, &a2 ));
if(a2!=NULL)
{
CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );
@@ -574,7 +574,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
}
else
digest_algorithm=NULL;
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_CNonce, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_CNonce, &a2 ));
if(a2!=NULL)
{
CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );
@@ -589,7 +589,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
}
else
digest_cnonce="";
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Nonce_Count, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Nonce_Count, &a2 ));
if(a2!=NULL)
{
CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );
@@ -604,7 +604,7 @@ int app_sip_MAR_cb( struct msg ** msg, struct avp * paramavp, struct session * s
}
else
digest_noncecount="";
- CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Username, &a2 ));
+ CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Username, &a2 ));
if(a2!=NULL)
{
CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );
diff --git a/extensions/app_sip/registrationtermination.c b/extensions/app_sip/registrationtermination.c
index 9300467..7f43c28 100644
--- a/extensions/app_sip/registrationtermination.c
+++ b/extensions/app_sip/registrationtermination.c
@@ -114,7 +114,7 @@ int app_sip_RTR_cb(struct rtrsipaor *structure)
}
}
- if(structure->strreason!='\0')
+ if(structure->strreason[0]!='\0')
got_streason=1;