Navigation


Changeset 1230:e72c9dad62ac in freeDiameter


Ignore:
Timestamp:
Jul 21, 2013, 6:57:39 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Fix issue with generating Failed-AVP when the error is DIAMETER_MISSING_AVP. Also fix a memory leak in that case

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdproto.h

    r1213 r1230  
    26992699        char *          pei_errcode;    /* name of the error code to use */
    27002700        struct avp *    pei_avp;        /* pointer to invalid (in original message) or missing AVP (to be freed) */
     2701        int             pei_avp_free;   /* Set to 1 if the pei_avp must be freed */
    27012702        char *          pei_message;    /* Overwrite default message if needed */
    27022703        int             pei_protoerr;   /* do we set the 'E' bit in the error message ? */
  • libfdcore/messages.c

    r1228 r1230  
    388388                /* Set the error code */
    389389                CHECK_FCT( fd_msg_rescode_set(m, pei.pei_errcode, pei.pei_message, pei.pei_avp, 1 ) );
     390               
     391                /* free the pei AVP to avoid memory leak */
     392                if (pei.pei_avp_free) {
     393                        fd_msg_free(pei.pei_avp);
     394                }
    390395               
    391396                *msg = NULL;
  • libfdcore/p_ce.c

    r1191 r1230  
    637637        CHECK_FCT_DO( fd_out_send(cer, *recv_cnx, NULL), goto destroy );
    638638       
     639        if (error->pei_avp_free) {
     640                fd_msg_free(error->pei_avp);
     641        }
     642       
    639643        /* And now destroy this connection */
    640644destroy:
  • libfdcore/routing_dispatch.c

    r1216 r1230  
    610610                                                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr));
    611611                                                                        CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
     612                                                                        if (error_info.pei_avp_free) { fd_msg_free(error_info.pei_avp); }
    612613                                                                        return 0;
    613614                                                                } else {
     
    632633                                                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr));
    633634                                                                        CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
     635                                                                        if (error_info.pei_avp_free) { fd_msg_free(error_info.pei_avp); }
    634636                                                                        return 0;
    635637                                                                } else {
     
    656658                                                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr));
    657659                                                                        CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
     660                                                                        if (error_info.pei_avp_free) { fd_msg_free(error_info.pei_avp); }
    658661                                                                        return 0;
    659662                                                                } else {
     
    674677                                                                        fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr));
    675678                                                                        CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
     679                                                                        if (error_info.pei_avp_free) { fd_msg_free(error_info.pei_avp); }
    676680                                                                        return 0;
    677681                                                                } else {
     
    932936                                                if (error_info.pei_errcode) {
    933937                                                        CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
     938                                                        if (error_info.pei_avp_free) { fd_msg_free(error_info.pei_avp); }
    934939                                                        return 0;
    935940                                                } else {
  • libfdproto/messages.c

    r1229 r1230  
    23712371        CHECK_FCT_DO( fd_dict_getval(model_avp, &avp_info), return NULL );
    23722372       
     2373        /* Set an initial size */
     2374        avp->avp_public.avp_len = GETAVPHDRSZ( avp->avp_public.avp_flags ) + avp_value_sizes[avp_info.avp_basetype];
     2375       
    23732376        /* Prepare the empty value */
    23742377        memset(&val, 0, sizeof(val));
     
    23772380                        val.os.data = os;
    23782381                        val.os.len  = sizeof(os);
     2382                        avp->avp_public.avp_len += val.os.len;
    23792383                case AVP_TYPE_INTEGER32:
    23802384                case AVP_TYPE_INTEGER64:
     
    24402444                        pr_data->pei->pei_errcode = "DIAMETER_MISSING_AVP";
    24412445                        pr_data->pei->pei_avp = empty_avp(rule->rule_avp);
     2446                        pr_data->pei->pei_avp_free = 1;
    24422447                }
    24432448                return EBADMSG;
     
    24532458                                pr_data->pei->pei_errcode = "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES";
    24542459                        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...");
     2460                        pr_data->pei->pei_avp_free = 1;
    24552461                }
    24562462                return EBADMSG;
     
    24722478                                        pr_data->pei->pei_message = "AVP was not in its fixed position";
    24732479                                        pr_data->pei->pei_avp = empty_avp(rule->rule_avp);
     2480                                        pr_data->pei->pei_avp_free = 1;
    24742481                                }
    24752482                                return EBADMSG;
     
    24852492                                        pr_data->pei->pei_message = "AVP was not in its fixed position";
    24862493                                        pr_data->pei->pei_avp = empty_avp(rule->rule_avp);
     2494                                        pr_data->pei->pei_avp_free = 1;
    24872495                                }
    24882496                                return EBADMSG;
Note: See TracChangeset for help on using the changeset viewer.