Mercurial > hg > freeDiameter
diff libfdproto/messages.c @ 1230:e72c9dad62ac
Fix issue with generating Failed-AVP when the error is DIAMETER_MISSING_AVP. Also fix a memory leak in that case
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Sun, 21 Jul 2013 11:57:39 +0200 |
parents | 4e52f009861a |
children | c9a160b815ea |
line wrap: on
line diff
--- a/libfdproto/messages.c Thu Jul 18 16:08:54 2013 +0200 +++ b/libfdproto/messages.c Sun Jul 21 11:57:39 2013 +0200 @@ -2370,12 +2370,16 @@ /* Type of the AVP */ CHECK_FCT_DO( fd_dict_getval(model_avp, &avp_info), return NULL ); + /* Set an initial size */ + avp->avp_public.avp_len = GETAVPHDRSZ( avp->avp_public.avp_flags ) + avp_value_sizes[avp_info.avp_basetype]; + /* Prepare the empty value */ memset(&val, 0, sizeof(val)); switch (avp_info.avp_basetype) { case AVP_TYPE_OCTETSTRING: val.os.data = os; val.os.len = sizeof(os); + avp->avp_public.avp_len += val.os.len; case AVP_TYPE_INTEGER32: case AVP_TYPE_INTEGER64: case AVP_TYPE_UNSIGNED32: @@ -2439,6 +2443,7 @@ if (pr_data->pei) { pr_data->pei->pei_errcode = "DIAMETER_MISSING_AVP"; pr_data->pei->pei_avp = empty_avp(rule->rule_avp); + pr_data->pei->pei_avp_free = 1; } return EBADMSG; } @@ -2452,6 +2457,7 @@ else pr_data->pei->pei_errcode = "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES"; pr_data->pei->pei_avp = empty_avp(rule->rule_avp); /* Well we are supposed to return the (max + 1)th instance of the AVP instead... Pfff... */ TODO("Improve..."); + pr_data->pei->pei_avp_free = 1; } return EBADMSG; } @@ -2471,6 +2477,7 @@ pr_data->pei->pei_errcode = "DIAMETER_MISSING_AVP"; pr_data->pei->pei_message = "AVP was not in its fixed position"; pr_data->pei->pei_avp = empty_avp(rule->rule_avp); + pr_data->pei->pei_avp_free = 1; } return EBADMSG; } @@ -2484,6 +2491,7 @@ pr_data->pei->pei_errcode = "DIAMETER_MISSING_AVP"; pr_data->pei->pei_message = "AVP was not in its fixed position"; pr_data->pei->pei_avp = empty_avp(rule->rule_avp); + pr_data->pei->pei_avp_free = 1; } return EBADMSG; }