Navigation


Changeset 1549:19ab8ac08a36 in freeDiameter


Ignore:
Timestamp:
Jul 7, 2020, 2:41:54 AM (4 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Parents:
1548:edfb2b662b91 (diff), 1403:6a35c5470ef4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/messages.c

    r1403 r1549  
    597597}
    598598
    599 /* Search a given AVP model in a message */
    600 int fd_msg_search_avp ( struct msg * msg, struct dict_object * what, struct avp ** avp )
     599/* Search a given AVP model in a message or AVP */
     600int fd_msg_search_avp ( msg_or_avp * reference, struct dict_object * what, struct avp ** avp )
    601601{
    602602        struct avp * nextavp;
     
    604604        enum dict_object_type   dicttype;
    605605       
    606         TRACE_ENTRY("%p %p %p", msg, what, avp);
    607        
    608         CHECK_PARAMS( CHECK_MSG(msg) && what );
     606        TRACE_ENTRY("%p %p %p", reference, what, avp);
     607       
     608        CHECK_PARAMS( VALIDATE_OBJ(reference) && what );
    609609       
    610610        CHECK_PARAMS( (fd_dict_gettype(what, &dicttype) == 0) && (dicttype == DICT_AVP) );
    611611        CHECK_FCT(  fd_dict_getval(what, &dictdata)  );
    612612       
    613         /* Loop on all top AVPs */
    614         CHECK_FCT(  fd_msg_browse(msg, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL)  );
     613        /* Loop on all top AVPs in message or AVP */
     614        CHECK_FCT(  fd_msg_browse(reference, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL)  );
    615615        while (nextavp) {
    616616               
     
    619619                        break;
    620620               
    621                 /* Otherwise move to next AVP in the message */
     621                /* Otherwise move to next AVP in the message or AVP */
    622622                CHECK_FCT( fd_msg_browse(nextavp, MSG_BRW_NEXT, (void *)&nextavp, NULL) );
    623623        }
     
    22472247                                                error_info->pei_errcode = "DIAMETER_INVALID_AVP_VALUE";
    22482248                                                error_info->pei_avp = avp;
    2249                                                 strncpy(error_message, err, sizeof(error_message));
     2249                                                snprintf(error_message, sizeof(error_message), "%s", err);
    22502250                                                error_info->pei_message = error_message;
    22512251                                } else {
     
    22972297        if (msg->msg_model != NULL) {
    22982298                /* Check if this model is still valid for the message data */
     2299#ifndef NDEBUG
    22992300                enum dict_object_type    dicttype;
     2301#endif
    23002302                struct dict_cmd_data     data;
    23012303                ASSERT(((fd_dict_gettype(msg->msg_model, &dicttype) == 0) && (dicttype == DICT_COMMAND)));
  • libfdproto/messages.c

    r1539 r1549  
    19471947                }
    19481948               
     1949                /* Check the length is valid */
     1950                if ( avp->avp_public.avp_len < GETAVPHDRSZ(avp->avp_public.avp_flags) ) {
     1951                        TRACE_DEBUG(INFO, "Invalid AVP size %d",
     1952                                        avp->avp_public.avp_len);
     1953                        free(avp);
     1954                        return EBADMSG;
     1955                }
     1956
    19491957                /* Check there is enough remaining data in the buffer */
    19501958                if ( (avp->avp_public.avp_len > GETAVPHDRSZ(avp->avp_public.avp_flags))
     
    19922000                TRACE_DEBUG(INFO, "Truncated message (%zd / %d)", buflen, msglen );
    19932001                return EBADMSG;
     2002        }
     2003        if ( msglen < GETMSGHDRSZ() ) {
     2004                TRACE_DEBUG(INFO, "Invalid message length (%d)", msglen );
     2005                return EBADMSG;
    19942006        }
    19952007       
Note: See TracChangeset for help on using the changeset viewer.