diff --git a/src/modules/auth_diameter/auth_diameter.c b/src/modules/auth_diameter/auth_diameter.c index 27ae30b2b1d..067df251e67 100644 --- a/src/modules/auth_diameter/auth_diameter.c +++ b/src/modules/auth_diameter/auth_diameter.c @@ -140,7 +140,7 @@ static int mod_child_init(int r) rb = (rd_buf_t*)pkg_malloc(sizeof(rd_buf_t)); if(!rb) { - LM_DBG("no more free pkg memory\n"); + PKG_MEM_ERROR; return -1; } rb->buf = 0; @@ -241,7 +241,7 @@ static int group_fixup(void** param, int param_no) s = (str*)pkg_malloc(sizeof(str)); if (!s) { - LM_ERR("no pkg memory left\n"); + PKG_MEM_ERROR; return E_UNSPEC; } s->s = (char*)*param; diff --git a/src/modules/auth_diameter/authorize.c b/src/modules/auth_diameter/authorize.c index c9dbd1b0448..7ca3c3e4d59 100644 --- a/src/modules/auth_diameter/authorize.c +++ b/src/modules/auth_diameter/authorize.c @@ -318,6 +318,11 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, { user_name.len += 2; user_name.s = (char*)ad_malloc(user_name.len*sizeof(char)); + if(!(user_name.s)) + { + PKG_MEM_ERROR; + return -1; + } memset(user_name.s, 0, user_name.len); memcpy(user_name.s, uri->user.s, uri->user.len); @@ -333,7 +338,7 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, if( (avp=AAACreateAVP(AVP_User_Name, 0, 0, user_name.s, user_name.len, AVP_FREE_DATA)) == 0) { - LM_ERR("no more pkg memory left!\n"); + LM_ERR("could not create AVP\n"); if(user_name.len>0) pkg_free(user_name.s); goto error; @@ -352,7 +357,7 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, if( (avp=AAACreateAVP(AVP_User_Name, 0, 0, cred->username.whole.s, cred->username.whole.len, AVP_DUPLICATE_DATA)) == 0) { - LM_ERR("no more pkg memory left!\n"); + LM_ERR("could not create AVP\n"); goto error; } @@ -371,7 +376,7 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, user_name.s = ad_malloc(user_name.len); if (!user_name.s) { - LM_ERR(" no more pkg memory left\n"); + PKG_MEM_ERROR; goto error; } memcpy(user_name.s, cred->username.whole.s, @@ -389,7 +394,7 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, if( (avp=AAACreateAVP(AVP_User_Name, 0, 0, user_name.s, user_name.len, AVP_FREE_DATA)) == 0) { - LM_ERR(" no more pkg memory left!\n"); + LM_ERR("could not create AVP\n"); if(user_name.len>0) pkg_free(user_name.s); goto error; @@ -409,7 +414,7 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, if( (avp=AAACreateAVP(AVP_SIP_MSGID, 0, 0, (char*)(&tmp), sizeof(m_id), AVP_DUPLICATE_DATA)) == 0) { - LM_ERR(" no more pkg memory left!\n"); + LM_ERR("could not create AVP\n"); goto error; } if( AAAAddAVPToMessage(req, avp, 0)!= AAA_ERR_SUCCESS) @@ -422,7 +427,7 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, if( (avp=AAACreateAVP(AVP_Service_Type, 0, 0, SIP_AUTHENTICATION, SERVICE_LEN, AVP_DUPLICATE_DATA)) == 0) { - LM_ERR(" no more pkg memory left!\n"); + LM_ERR("could not create AVP\n"); goto error; } if( AAAAddAVPToMessage(req, avp, 0)!= AAA_ERR_SUCCESS) @@ -435,7 +440,7 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, if( (avp=AAACreateAVP(AVP_Destination_Realm, 0, 0, uri->host.s, uri->host.len, AVP_DUPLICATE_DATA)) == 0) { - LM_ERR(" no more pkg memory left!\n"); + LM_ERR("could not create AVP\n"); goto error; } @@ -452,6 +457,11 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, /* Resource AVP */ user_name.len = ruri->user.len + ruri->host.len + ruri->port.len + 2; user_name.s = (char*)ad_malloc(user_name.len*sizeof(char)); + if(!(user_name.s)) + { + PKG_MEM_ERROR; + return -1; + } memset(user_name.s, 0, user_name.len); memcpy(user_name.s, ruri->user.s, ruri->user.len); @@ -479,7 +489,7 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, if( (avp=AAACreateAVP(AVP_Resource, 0, 0, user_name.s, user_name.len, AVP_FREE_DATA)) == 0) { - LM_ERR(" no more pkg memory left!\n"); + LM_ERR("could not create AVP\n"); if(user_name.s) pkg_free(user_name.s); goto error; @@ -496,7 +506,7 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, if( (avp=AAACreateAVP(AVP_Response, 0, 0, hdr->body.s, hdr->body.len, AVP_DUPLICATE_DATA)) == 0) { - LM_ERR(" no more pkg memory left!\n"); + LM_ERR("could not create AVP\n"); goto error; } @@ -512,7 +522,7 @@ int diameter_authorize(struct hdr_field* hdr, str* p_method, sip_uri_t *uri, if( (avp=AAACreateAVP(AVP_Method, 0, 0, p_method->s, p_method->len, AVP_DUPLICATE_DATA)) == 0) { - LM_ERR(" no more pkg memory left!\n"); + LM_ERR("could not create AVP\n"); goto error; } @@ -603,6 +613,11 @@ int srv_response(struct sip_msg* msg, rd_buf_t * rb, int hftype) { auth_hf_len = WWW_AUTH_CHALLENGE_LEN+rb->chall_len; auth_hf = (char*)ad_malloc(auth_hf_len*(sizeof(char))); + if(!(auth_hf)) + { + PKG_MEM_ERROR; + return -1; + } memset(auth_hf, 0, auth_hf_len); memcpy(auth_hf,WWW_AUTH_CHALLENGE, WWW_AUTH_CHALLENGE_LEN); memcpy(auth_hf+WWW_AUTH_CHALLENGE_LEN, rb->chall, @@ -615,6 +630,11 @@ int srv_response(struct sip_msg* msg, rd_buf_t * rb, int hftype) { auth_hf_len = PROXY_AUTH_CHALLENGE_LEN+rb->chall_len; auth_hf = (char*)ad_malloc(auth_hf_len*(sizeof(char))); + if(!(auth_hf)) + { + PKG_MEM_ERROR; + return -1; + } memset(auth_hf, 0, auth_hf_len); memcpy(auth_hf, PROXY_AUTH_CHALLENGE, PROXY_AUTH_CHALLENGE_LEN); memcpy(auth_hf + PROXY_AUTH_CHALLENGE_LEN, rb->chall, diff --git a/src/modules/auth_diameter/avp.c b/src/modules/auth_diameter/avp.c index d61a9200dc8..9d5e03f0fdd 100644 --- a/src/modules/auth_diameter/avp.c +++ b/src/modules/auth_diameter/avp.c @@ -141,7 +141,7 @@ AAA_AVP* AAACreateAVP( return avp; error: - LM_ERR("no more pkg memory left!\n"); + PKG_MEM_ERROR; if(avp) ad_free(avp); return 0; } @@ -420,7 +420,7 @@ AAA_AVP* AAACloneAVP( AAA_AVP *avp , unsigned char clone_data) /* clone the avp structure */ n_avp = (AAA_AVP*)ad_malloc( sizeof(AAA_AVP) ); if (!n_avp) { - LM_ERR(" cannot get free pkg memory!!\n"); + PKG_MEM_ERROR; goto error; } memcpy( n_avp, avp, sizeof(AAA_AVP)); @@ -430,7 +430,7 @@ AAA_AVP* AAACloneAVP( AAA_AVP *avp , unsigned char clone_data) /* clone the avp data */ n_avp->data.s = (char*)ad_malloc( avp->data.len ); if (!(n_avp->data.s)) { - LM_ERR("cannot get free pkg memory!!\n"); + PKG_MEM_ERROR; ad_free( n_avp ); goto error; } diff --git a/src/modules/auth_diameter/message.c b/src/modules/auth_diameter/message.c index 47f0738cacc..0ac2b945490 100644 --- a/src/modules/auth_diameter/message.c +++ b/src/modules/auth_diameter/message.c @@ -67,7 +67,7 @@ AAAReturnCode AAABuildMsgBuffer( AAAMessage *msg ) /* allocate some memory */ msg->buf.s = (char*)ad_malloc( msg->buf.len ); if (!msg->buf.s) { - LM_ERR(" no more pkg memory!\n"); + PKG_MEM_ERROR; goto error; } memset(msg->buf.s, 0, msg->buf.len); @@ -209,7 +209,7 @@ AAAMessage* AAATranslateMessage( unsigned char* source, unsigned int sourceLen, /* alloc a new message structure */ msg = (AAAMessage*)ad_malloc(sizeof(AAAMessage)); if (!msg) { - LM_ERR(" no more free memory!!\n"); + PKG_MEM_ERROR; goto error; } memset(msg,0,sizeof(AAAMessage)); @@ -325,7 +325,7 @@ AAAMessage* AAAInMessage(AAACommandCode commandCode, AAAApplicationId appId) msg = (AAAMessage*)ad_malloc(sizeof(AAAMessage)); if (!msg) { - LM_ERR("no more pkg memory!\n"); + PKG_MEM_ERROR; return NULL; } memset(msg, 0, sizeof(AAAMessage)); diff --git a/src/modules/auth_diameter/tcp_comm.c b/src/modules/auth_diameter/tcp_comm.c index c12bd1f136c..6347a67a8ca 100644 --- a/src/modules/auth_diameter/tcp_comm.c +++ b/src/modules/auth_diameter/tcp_comm.c @@ -145,7 +145,7 @@ int do_read( int socket, rd_buf_t *p) //LM_DBG("message length = %d(%x)\n",len,len); if ( (p->buf=pkg_malloc(len))==0 ) { - LM_ERR("no more pkg memory\n"); + PKG_MEM_ERROR; goto error; } *((unsigned int*)p->buf) = p->first_4bytes; @@ -307,7 +307,7 @@ int tcp_send_recv(int sockfd, char* buf, int len, rd_buf_t* rb, rb->chall = (unsigned char*)pkg_malloc(avp->data.len*sizeof(unsigned char)); if(rb->chall == NULL) { - LM_ERR("no more pkg memory\n"); + PKG_MEM_ERROR; rb->ret_code = AAA_SRVERR; break; } diff --git a/src/modules/auth_diameter/user_in.c b/src/modules/auth_diameter/user_in.c index e0acd482f73..7d9d51e2cef 100644 --- a/src/modules/auth_diameter/user_in.c +++ b/src/modules/auth_diameter/user_in.c @@ -171,7 +171,7 @@ int diameter_is_user_in(struct sip_msg* _m, char* _hf, char* _group) p = (char*)pkg_malloc(user_name.len); if (!p) { - LM_ERR("no pkg memory left\n"); + PKG_MEM_ERROR; return -6; } user_name.s = p;