(/home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/voip_calls.c) |
| |
| 2317 | | | MGCPcalls_packet( void *ptr _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const void *MGCPinfo) |
| 2318 | | | { |
| 2319 | | | voip_calls_tapinfo_t *tapinfo = &the_tapinfo_struct; |
| 2320 | | | |
| 2321 | | | voip_calls_info_t *tmp_listinfo; |
| 2322 | | | voip_calls_info_t *callsinfo = NULL; |
| 2323 | | | mgcp_calls_info_t *tmp_mgcpinfo = NULL; |
| 2324 | | | GList *list; |
| 2325 | | | GList *listGraph; |
| 2326 | | | gchar *frame_label = NULL; |
| 2327 | | | gchar * = NULL; |
| 2328 | | | graph_analysis_item_t *gai; |
| 2329 | | | gboolean new = FALSE; |
| 2330 | | | gboolean fromEndpoint = FALSE; |
| 2331 | | | gdouble diff_time; |
| 2332 | | | |
| 2333 | | | const mgcp_info_t *pi = MGCPinfo; |
| 2334 | | | |
| 2335 | | | |
| 2336 | | | if ((pi->mgcp_type == MGCP_REQUEST) && !pi->is_duplicate ){ |
| 2337 | | | |
| 2338 | | | list = g_list_first(tapinfo->callsinfo_list); |
| 2339 | | | while (list) |
| 2340 | | | { |
| 2341 | | | tmp_listinfo=list->data; |
| 2342 | | | if ((tmp_listinfo->protocol == VOIP_MGCP) && (tmp_listinfo->call_active_state == VOIP_ACTIVE)){ |
| 2343 | | | tmp_mgcpinfo = tmp_listinfo->prot_info; |
| 2344 | | | if (pi->endpointId != NULL){ |
| 2345 | | | if (g_ascii_strcasecmp(tmp_mgcpinfo->endpointId,pi->endpointId) == 0){ |
| 2346 | | | |
| 2347 | | | |
| 2348 | | | |
| 2349 | | | |
| 2350 | | | diff_time = nstime_to_sec(&pinfo->fd->rel_ts) - tmp_listinfo->stop_sec - (double)tmp_listinfo->stop_usec/1000000; |
| 2351 | | | if ( ((tmp_listinfo->call_state == VOIP_CANCELLED) || |
| 2352 | | | (tmp_listinfo->call_state == VOIP_COMPLETED) || |
| 2353 | | | (tmp_listinfo->call_state == VOIP_REJECTED)) && |
| 2354 | | | (diff_time > 2) ) |
| 2355 | | | { |
| 2356 | | | tmp_listinfo->call_active_state = VOIP_INACTIVE; |
| 2357 | | | } else { |
| 2358 | | | callsinfo = (voip_calls_info_t*)(list->data); |
| 2359 | | | break; |
| 2360 | | | } |
| 2361 | | | } |
| 2362 | | | } |
| 2363 | | | } |
| 2364 | | | list = g_list_next (list);
x /usr/include/glib-2.0/glib/glist.h |
| |
113 | #define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL) |
| |
|
| 2365 | | | } |
| 2366 | | | |
| 2367 | | | |
| 2368 | | | if (callsinfo == NULL){ |
| 2369 | | | if ( (strcmp(pi->code, "NTFY") == 0) && isSignal("hd", pi->observedEvents) ){ |
| 2370 | | | |
| 2371 | | | fromEndpoint = TRUE; |
| 2372 | | | new = TRUE; |
| 2373 | | | } else if (strcmp(pi->code, "CRCX") == 0){ |
| 2374 | | | |
| 2375 | | | fromEndpoint = FALSE; |
| 2376 | | | new = TRUE; |
| 2377 | | | } |
| 2378 | | | if (!new) return 0; |
| 2379 | | | } |
| 2380 | | | } else if ( ((pi->mgcp_type == MGCP_RESPONSE) && pi->request_available) || |
| 2381 | | | ((pi->mgcp_type == MGCP_REQUEST) && pi->is_duplicate) ) { |
Redundant Condition
pi->is_duplicate always evaluates to true. This may be because: - There is a constant assignment to one or more of the variables involved.
- An earlier conditional statement has already ensured that pi->is_duplicate cannot be false.
- A crashing bug occurs on every path where pi->is_duplicate could have evaluated to false. Look for a preceding Null Pointer Dereference or Division By Zero warning.
|
|
| 2382 | | | |
| 2383 | | | |
| 2384 | | | listGraph = g_list_first(tapinfo->graph_analysis->list); |
| 2385 | | | while (listGraph) |
| 2386 | | | { |
| 2387 | | | gai = listGraph->data; |
| 2388 | | | if (gai->frame_num == pi->req_num){ |
| 2389 | | | |
| 2390 | | | list = g_list_first(tapinfo->callsinfo_list); |
| 2391 | | | while (list) |
| 2392 | | | { |
| 2393 | | | tmp_listinfo=list->data; |
| 2394 | | | if (tmp_listinfo->protocol == VOIP_MGCP){ |
| 2395 | | | if (tmp_listinfo->call_num == gai->conv_num){ |
| 2396 | | | tmp_mgcpinfo = tmp_listinfo->prot_info; |
| 2397 | | | callsinfo = (voip_calls_info_t*)(list->data); |
| 2398 | | | break; |
| 2399 | | | } |
| 2400 | | | } |
| 2401 | | | list = g_list_next (list);
x /usr/include/glib-2.0/glib/glist.h |
| |
113 | #define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL) |
| |
|
| 2402 | | | } |
| 2403 | | | if (callsinfo != NULL) break; |
| 2404 | | | } |
| 2405 | | | listGraph = g_list_next(listGraph);
x /usr/include/glib-2.0/glib/glist.h |
| |
113 | #define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL) |
| |
|
| 2406 | | | } |
| 2407 | | | |
| 2408 | | | if (callsinfo == NULL) return 0; |
| 2409 | | | } else return 0; |
| 2410 | | | |
| 2411 | | | |
| 2412 | | | if (callsinfo==NULL){ |
| 2413 | | | callsinfo = g_malloc0(sizeof(voip_calls_info_t)); |
| 2414 | | | callsinfo->call_active_state = VOIP_ACTIVE; |
| 2415 | | | callsinfo->call_state = VOIP_CALL_SETUP; |
| 2416 | | | if (fromEndpoint) { |
| 2417 | | | callsinfo->from_identity=g_strdup(pi->endpointId); |
| 2418 | | | callsinfo->to_identity=g_strdup(""); |
| 2419 | | | } else { |
| 2420 | | | callsinfo->from_identity=g_strdup(""); |
| 2421 | | | callsinfo->to_identity=g_strdup(pi->endpointId); |
| 2422 | | | } |
| 2423 | | | COPY_ADDRESS(&(callsinfo->initial_speaker),&(pinfo->src));
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
107 | #define COPY_ADDRESS(to, from) { \ |
108 | guint8 *COPY_ADDRESS_data; \ |
109 | (to)->type = (from)->type; \ |
110 | (to)->len = (from)->len; \ |
111 | COPY_ADDRESS_data = g_malloc((from)->len); \ |
112 | memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \ |
113 | (to)->data = COPY_ADDRESS_data; \ |
114 | } |
| |
|
| 2424 | | | callsinfo->first_frame_num=pinfo->fd->num; |
| 2425 | | | callsinfo->selected=FALSE; |
| 2426 | | | callsinfo->start_sec=(gint32) (pinfo->fd->rel_ts.secs); |
| 2427 | | | callsinfo->start_usec=pinfo->fd->rel_ts.nsecs/1000; |
| 2428 | | | callsinfo->protocol=VOIP_MGCP; |
| 2429 | | | callsinfo->prot_info=g_malloc(sizeof(mgcp_calls_info_t)); |
| 2430 | | | callsinfo->free_prot_info = g_free; |
| 2431 | | | tmp_mgcpinfo=callsinfo->prot_info; |
| 2432 | | | tmp_mgcpinfo->endpointId = g_strdup(pi->endpointId); |
| 2433 | | | tmp_mgcpinfo->fromEndpoint = fromEndpoint; |
| 2434 | | | callsinfo->npackets = 0; |
| 2435 | | | callsinfo->call_num = tapinfo->ncalls++; |
| 2436 | | | tapinfo->callsinfo_list = g_list_append(tapinfo->callsinfo_list, callsinfo); |
| 2437 | | | } |
| 2438 | | | |
| 2439 | | | g_assert(tmp_mgcpinfo != NULL);
x /usr/include/glib-2.0/glib/gtestutils.h |
| |
74 | #define g_assert(expr) do { if G_LIKELY (expr) ; else \ |
75 | g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ |
76 | #expr); } while (0) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
277 | #define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
268 | #define _G_BOOLEAN_EXPR(expr) \ |
269 | __extension__ ({ \ |
270 | int _g_boolean_var_; \ |
271 | if (expr) \ |
272 | _g_boolean_var_ = 1; \ |
273 | else \ |
274 | _g_boolean_var_ = 0; \ |
275 | _g_boolean_var_; \ |
276 | }) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
160 | # define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__)) |
| |
|
| 2440 | | | |
| 2441 | | | |
| 2442 | | | switch (pi->mgcp_type) |
| 2443 | | | { |
| 2444 | | | case MGCP_REQUEST: |
| 2445 | | | if ( (strcmp(pi->code, "NTFY") == 0) && (pi->observedEvents != NULL) ){ |
| 2446 | | | frame_label = g_strdup_printf("%s ObsEvt:%s",pi->code, pi->observedEvents); |
| 2447 | | | |
| 2448 | | | if (tmp_mgcpinfo->fromEndpoint){ |
| 2449 | | | |
| 2450 | | | if (callsinfo->to_identity[0] == '\0') mgcpDialedDigits(pi->observedEvents, &(callsinfo->to_identity)); |
| 2451 | | | |
| 2452 | | | |
| 2453 | | | } else if (isSignal("hd", pi->observedEvents)) |
| 2454 | | | callsinfo->call_state=VOIP_IN_CALL; |
| 2455 | | | |
| 2456 | | | |
| 2457 | | | if (isSignal("hu", pi->observedEvents)) { |
| 2458 | | | if ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state == VOIP_RINGING)){ |
| 2459 | | | callsinfo->call_state = VOIP_CANCELLED; |
| 2460 | | | } else { |
| 2461 | | | callsinfo->call_state = VOIP_COMPLETED; |
| 2462 | | | } |
| 2463 | | | } |
| 2464 | | | |
| 2465 | | | } else if (strcmp(pi->code, "RQNT") == 0) { |
| 2466 | | | |
| 2467 | | | if ( tmp_mgcpinfo->fromEndpoint && isSignal("", pi->signalReq) && (callsinfo->call_state == VOIP_RINGING) ) { |
| 2468 | | | callsinfo->call_state = VOIP_IN_CALL; |
| 2469 | | | } |
| 2470 | | | |
| 2471 | | | |
| 2472 | | | if ( isSignal("rg", pi->signalReq) || isSignal("rt", pi->signalReq) ) { |
| 2473 | | | callsinfo->call_state = VOIP_RINGING; |
| 2474 | | | } |
| 2475 | | | |
| 2476 | | | |
| 2477 | | | if ( (isSignal("ro", pi->signalReq) || isSignal("bz", pi->signalReq)) && ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state = VOIP_RINGING)) ) { |
| 2478 | | | callsinfo->call_state = VOIP_REJECTED; |
| 2479 | | | } |
| 2480 | | | |
| 2481 | | | if (pi->signalReq != NULL) |
| 2482 | | | frame_label = g_strdup_printf("%s%sSigReq:%s",pi->code, (pi->hasDigitMap == TRUE)?" DigitMap ":"", pi->signalReq); |
| 2483 | | | else |
| 2484 | | | frame_label = g_strdup_printf("%s%s",pi->code, (pi->hasDigitMap == TRUE)?" DigitMap ":""); |
| 2485 | | | |
| 2486 | | | |
| 2487 | | | if (!tmp_mgcpinfo->fromEndpoint) mgcpCallerID(pi->signalReq, &(callsinfo->from_identity)); |
| 2488 | | | |
| 2489 | | | } else if (strcmp(pi->code, "DLCX") == 0) { |
| 2490 | | | |
| 2491 | | | |
| 2492 | | | |
| 2493 | | | |
| 2494 | | | if (!tmp_mgcpinfo->fromEndpoint){ |
| 2495 | | | if ((callsinfo->call_state == VOIP_CALL_SETUP) || (callsinfo->call_state == VOIP_RINGING)){ |
| 2496 | | | callsinfo->call_state = VOIP_CANCELLED; |
| 2497 | | | } |
| 2498 | | | } |
| 2499 | | | } |
| 2500 | | | |
| 2501 | | | if (frame_label == NULL) frame_label = g_strdup(pi->code); |
| 2502 | | | break; |
| 2503 | | | case MGCP_RESPONSE: |
| 2504 | | | frame_label = g_strdup_printf("%u (%s)",pi->rspcode, pi->code); |
| 2505 | | | break; |
| 2506 | | | case MGCP_OTHERS: |
| 2507 | | | |
| 2508 | | | break; |
| 2509 | | | } |
| 2510 | | | |
| 2511 | | | |
| 2512 | | | = g_strdup_printf("MGCP %s %s%s", tmp_mgcpinfo->endpointId, (pi->mgcp_type == MGCP_REQUEST)?"Request":"Response", pi->is_duplicate?" Duplicate":""); |
| 2513 | | | |
| 2514 | | | callsinfo->stop_sec=(gint32) (pinfo->fd->rel_ts.secs); |
| 2515 | | | callsinfo->stop_usec=pinfo->fd->rel_ts.nsecs/1000; |
| 2516 | | | callsinfo->last_frame_num=pinfo->fd->num; |
| 2517 | | | ++(callsinfo->npackets); |
| 2518 | | | |
| 2519 | | | ++(tapinfo->npackets); |
| 2520 | | | |
| 2521 | | | |
| 2522 | | | add_to_graph(tapinfo, pinfo, frame_label, , callsinfo->call_num, &(pinfo->src), &(pinfo->dst), 1); |
| 2523 | | | g_free(); |
| 2524 | | | g_free(frame_label); |
| 2525 | | | |
| 2526 | | | |
| 2527 | | | if ( (sdp_summary != NULL) && (sdp_frame_num == pinfo->fd->num) ){ |
| 2528 | | | append_to_frame_graph(tapinfo, pinfo->fd->num, sdp_summary, NULL); |
| 2529 | | | g_free(sdp_summary); |
| 2530 | | | sdp_summary = NULL; |
| 2531 | | | } |
| 2532 | | | |
| 2533 | | | tapinfo->redraw = TRUE; |
| 2534 | | | |
| 2535 | | | return 1; |
| 2536 | | | } |
| |