Changes in libfdproto/messages.c [1305:84a3c9c4b834:1248:c9a160b815ea] in freeDiameter
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdproto/messages.c
r1305 r1248 3 3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * 4 4 * * 5 * Copyright (c) 201 5, WIDE Project and NICT *5 * Copyright (c) 2013, WIDE Project and NICT * 6 6 * All rights reserved. * 7 7 * * … … 232 232 struct dict_avp_data dictdata; 233 233 234 CHECK_FCT _DO( fd_dict_getval(model, &dictdata), { free(new); return __ret__; });234 CHECK_FCT( fd_dict_getval(model, &dictdata) ); 235 235 236 236 new->avp_model = model; … … 248 248 new->avp_rawlen = (*avp)->avp_public.avp_len - GETAVPHDRSZ( (*avp)->avp_public.avp_flags ); 249 249 if (new->avp_rawlen) { 250 CHECK_MALLOC _DO( new->avp_rawdata = malloc(new->avp_rawlen), { free(new); return __ret__; });250 CHECK_MALLOC( new->avp_rawdata = malloc(new->avp_rawlen) ); 251 251 memset(new->avp_rawdata, 0x00, new->avp_rawlen); 252 252 } … … 286 286 struct dict_object *dictappl; 287 287 288 CHECK_FCT _DO( fd_dict_getdict(model, &dict), { free(new); return __ret__; });289 CHECK_FCT _DO( fd_dict_getval(model, &dictdata), { free(new); return __ret__; });288 CHECK_FCT( fd_dict_getdict(model, &dict) ); 289 CHECK_FCT( fd_dict_getval(model, &dictdata) ); 290 290 291 291 new->msg_model = model; … … 294 294 295 295 /* Initialize application from the parent, if any */ 296 CHECK_FCT _DO( fd_dict_search( dict, DICT_APPLICATION, APPLICATION_OF_COMMAND, model, &dictappl, 0), { free(new); return __ret__; });296 CHECK_FCT( fd_dict_search( dict, DICT_APPLICATION, APPLICATION_OF_COMMAND, model, &dictappl, 0) ); 297 297 if (dictappl != NULL) { 298 298 struct dict_application_data appdata; 299 CHECK_FCT _DO( fd_dict_getval(dictappl, &appdata), { free(new); return __ret__; });299 CHECK_FCT( fd_dict_getval(dictappl, &appdata) ); 300 300 new->msg_public.msg_appl = appdata.application_id; 301 301 } … … 365 365 366 366 if (!sess_id_avp) { 367 CHECK_FCT _DO( fd_dict_search( dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &sess_id_avp, ENOENT), { free(ans); return __ret__; });368 } 369 CHECK_FCT _DO( fd_sess_getsid ( sess, &sid, &sidlen ), { free(ans); return __ret__; });370 CHECK_FCT _DO( fd_msg_avp_new ( sess_id_avp, 0, &avp ), { free(ans); return __ret__; });367 CHECK_FCT( fd_dict_search( dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &sess_id_avp, ENOENT) ); 368 } 369 CHECK_FCT( fd_sess_getsid ( sess, &sid, &sidlen ) ); 370 CHECK_FCT( fd_msg_avp_new ( sess_id_avp, 0, &avp ) ); 371 371 val.os.data = sid; 372 372 val.os.len = sidlen; 373 CHECK_FCT _DO( fd_msg_avp_setvalue( avp, &val ), { free(avp); free(ans); return __ret__; });374 CHECK_FCT _DO( fd_msg_avp_add( ans, MSG_BRW_FIRST_CHILD, avp ), { free(avp); free(ans); return __ret__; });373 CHECK_FCT( fd_msg_avp_setvalue( avp, &val ) ); 374 CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_FIRST_CHILD, avp ) ); 375 375 ans->msg_sess = sess; 376 CHECK_FCT _DO( fd_sess_ref_msg(sess), { free(ans); return __ret__; });376 CHECK_FCT( fd_sess_ref_msg(sess) ); 377 377 } 378 378 … … 383 383 struct fd_list avpcpylist = FD_LIST_INITIALIZER(avpcpylist); 384 384 385 CHECK_FCT _DO( fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL) , { free(ans); return __ret__; });385 CHECK_FCT( fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL) ); 386 386 while (avp) { 387 387 if ( (avp->avp_public.avp_code == AC_PROXY_INFO) … … 394 394 395 395 /* Create a buffer with the content of the AVP. This is easier than going through the list */ 396 CHECK_FCT _DO( fd_msg_update_length(avp), { free(ans); return __ret__; });397 CHECK_MALLOC _DO( buf = malloc(avp->avp_public.avp_len), { free(ans); return __ret__; });398 CHECK_FCT _DO( bufferize_avp(buf, avp->avp_public.avp_len, &offset, avp), { free(buf); free(ans); return __ret__; });396 CHECK_FCT( fd_msg_update_length(avp) ); 397 CHECK_MALLOC( buf = malloc(avp->avp_public.avp_len) ); 398 CHECK_FCT( bufferize_avp(buf, avp->avp_public.avp_len, &offset, avp) ); 399 399 400 400 /* Now we parse this buffer to create a copy AVP */ 401 CHECK_FCT _DO( parsebuf_list(buf, avp->avp_public.avp_len, &avpcpylist), { free(buf); free(ans); return __ret__; });401 CHECK_FCT( parsebuf_list(buf, avp->avp_public.avp_len, &avpcpylist) ); 402 402 403 403 /* Parse dictionary objects now to remove the dependency on the buffer */ 404 CHECK_FCT _DO( parsedict_do_chain(dict, &avpcpylist, 0, &pei), { /* leaking the avpcpylist -- this should never happen anyway */ free(buf); free(ans); return __ret__; });404 CHECK_FCT( parsedict_do_chain(dict, &avpcpylist, 0, &pei) ); 405 405 406 406 /* Done for this AVP */ … … 411 411 } 412 412 /* move to next AVP in the message, we can have several Proxy-Info instances */ 413 CHECK_FCT _DO( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL), { free(ans); return __ret__; });413 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL) ); 414 414 } 415 415 } … … 2037 2037 { 2038 2038 struct dict_avp_data dictdata; 2039 struct dict_type_data derivedtypedata;2040 struct dict_object * avp_derived_type = NULL;2041 2039 uint8_t * source; 2042 2040 … … 2219 2217 break; 2220 2218 2221 }2222 2223 /* Is there a derived type check function ? */2224 CHECK_FCT ( fd_dict_search ( dict, DICT_TYPE, TYPE_OF_AVP, avp->avp_model, &avp_derived_type, 0) );2225 if (avp_derived_type) {2226 CHECK_FCT( fd_dict_getval(avp_derived_type, &derivedtypedata) );2227 if (derivedtypedata.type_check != NULL) {2228 char * err;2229 int ret = (*derivedtypedata.type_check)( derivedtypedata.type_check_param, &avp->avp_storage, &err );2230 2231 if (ret != 0) {2232 TRACE_DEBUG(INFO, "The AVP failed to pass the dictionary validation");2233 if (error_info) {2234 error_info->pei_errcode = "DIAMETER_INVALID_AVP_VALUE";2235 error_info->pei_avp = avp;2236 strncpy(error_message, err, sizeof(error_message));2237 error_info->pei_message = error_message;2238 } else {2239 char * buf = NULL;2240 size_t buflen;2241 CHECK_MALLOC(fd_msg_dump_treeview(&buf, &buflen, NULL, avp, NULL, 0, 0));2242 LOG_E("Invalid AVP: %s", buf);2243 free(buf);2244 }2245 return ret; /* should we just return EBADMSG? */2246 }2247 }2248 2219 } 2249 2220
Note: See TracChangeset
for help on using the changeset viewer.