Navigation



Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/messages.c

    r924 r903  
    106106#define _A(_x) ((struct avp *)(_x))
    107107/* Check the type and eyecatcher */
    108 #define CHECK_AVP(_x) ((_x) && (_C(_x)->type == MSG_AVP) && (_A(_x)->avp_eyec == MSG_AVP_EYEC))
     108#define CHECK_AVP(_x) ((_C(_x)->type == MSG_AVP) && (_A(_x)->avp_eyec == MSG_AVP_EYEC))
    109109
    110110/* The following structure represents an instance of a message (command and children AVPs). */
     
    239239                if (new->avp_rawlen) {
    240240                        CHECK_MALLOC(  new->avp_rawdata = malloc(new->avp_rawlen)  );
    241                         memset(new->avp_rawdata, 0x00, new->avp_rawlen);
     241                        memset(new->avp_rawdata, 0xFF, new->avp_rawlen);
    242242                }
    243243        }
     
    12161216}
    12171217
    1218 /* Associate a session with a message, use only when the session was just created */
    1219 int fd_msg_sess_set(struct msg * msg, struct session * session)
    1220 {
    1221         TRACE_ENTRY("%p %p", msg, session);
    1222        
    1223         /* Check we received valid parameters */
    1224         CHECK_PARAMS( CHECK_MSG(msg) );
    1225         CHECK_PARAMS( session );
    1226         CHECK_PARAMS( msg->msg_sess == NULL );
    1227        
    1228         msg->msg_sess = session;
    1229         return 0;
    1230 }
    1231 
    12321218
    12331219/* Retrieve the session of the message */
     
    12751261       
    12761262        /* Resolve the session and we are done */
    1277         if (avp->avp_public.avp_value->os.len > 0) {
    1278                 CHECK_FCT( fd_sess_fromsid_msg ( avp->avp_public.avp_value->os.data, avp->avp_public.avp_value->os.len, &msg->msg_sess, new) );
    1279                 *session = msg->msg_sess;
    1280         } else {
    1281                 TRACE_DEBUG(FULL, "Session-Id AVP with 0-byte length found in message %p", msg);
    1282                 *session = NULL;
    1283         }
     1263        CHECK_FCT( fd_sess_fromsid_msg ( avp->avp_public.avp_value->os.data, avp->avp_public.avp_value->os.len, &msg->msg_sess, new) );
     1264        *session = msg->msg_sess;
    12841265       
    12851266        return 0;
     
    16671648                struct avp * avp;
    16681649               
    1669                 if (buflen - offset < AVPHDRSZ_NOVEND) {
     1650                if (buflen - offset <= AVPHDRSZ_NOVEND) {
    16701651                        TRACE_DEBUG(INFO, "truncated buffer: remaining only %d bytes", buflen - offset);
    16711652                        return EBADMSG;
     
    16851666               
    16861667                if (avp->avp_public.avp_flags & AVP_FLAG_VENDOR) {
    1687                         if (buflen - offset < 4) {
     1668                        if (buflen - offset <= 4) {
    16881669                                TRACE_DEBUG(INFO, "truncated buffer: remaining only %d bytes for vendor and data", buflen - offset);
    16891670                                free(avp);
     
    16951676               
    16961677                /* Check there is enough remaining data in the buffer */
    1697                 if ( (avp->avp_public.avp_len > GETAVPHDRSZ(avp->avp_public.avp_flags))
    1698                 && (buflen - offset < avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags))) {
     1678                if (buflen - offset < avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags)) {
    16991679                        TRACE_DEBUG(INFO, "truncated buffer: remaining only %d bytes for data, and avp data size is %d",
    17001680                                        buflen - offset,
Note: See TracChangeset for help on using the changeset viewer.