(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-clnp.c) |
| |
| 191 | | | static void dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) |
| 192 | | | { |
| 193 | | | proto_tree *clnp_tree = NULL; |
| 194 | | | proto_item *ti; |
| 195 | | | guint8 cnf_proto_id; |
| 196 | | | guint8 cnf_hdr_len; |
| 197 | | | guint8 cnf_vers; |
| 198 | | | guint8 cnf_ttl; |
| 199 | | | guint8 cnf_type; |
| 200 | | | char flag_string[6+1]; |
| 201 | | | const char *pdu_type_string; |
| 202 | | | proto_tree *type_tree; |
| 203 | | | guint16 segment_length; |
| 204 | | | guint16 du_id = 0; |
| 205 | | | guint16 segment_offset = 0; |
| 206 | | | guint16 cnf_cksum; |
| 207 | | | cksum_status_t cksum_status; |
| 208 | | | int offset; |
| 209 | | | guchar src_len, dst_len, nsel, opt_len = 0; |
| 210 | | | const guint8 *dst_addr, *src_addr; |
| 211 | | | gint len; |
| 212 | | | guint next_length; |
| 213 | | | proto_tree *discpdu_tree; |
| 214 | | | gboolean save_in_error_pkt; |
| 215 | | | fragment_data *fd_head; |
| 216 | | | tvbuff_t *next_tvb; |
| 217 | | | gboolean update_col_info = TRUE; |
| 218 | | | gboolean save_fragmented; |
| 219 | | | |
| 220 | | | if (check_col(pinfo->cinfo, COL_PROTOCOL)) |
| 221 | | | col_set_str(pinfo->cinfo, COL_PROTOCOL, "CLNP"); |
| 222 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 223 | | | col_clear(pinfo->cinfo, COL_INFO); |
| 224 | | | |
| 225 | | | cnf_proto_id = tvb_get_guint8(tvb, P_CLNP_PROTO_ID); |
| 226 | | | if (cnf_proto_id == NLPID_NULL) { |
| 227 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 228 | | | col_set_str(pinfo->cinfo, COL_INFO, "Inactive subset"); |
| 229 | | | if (tree) { |
| 230 | | | ti = proto_tree_add_item(tree, proto_clnp, tvb, P_CLNP_PROTO_ID, 1, FALSE); |
| 231 | | | clnp_tree = proto_item_add_subtree(ti, ett_clnp); |
| 232 | | | proto_tree_add_uint_format(clnp_tree, hf_clnp_id, tvb, P_CLNP_PROTO_ID, 1, |
| 233 | | | cnf_proto_id, |
| 234 | | | "Inactive subset"); |
| 235 | | | } |
| 236 | | | next_tvb = tvb_new_subset(tvb, 1, -1, -1); |
| 237 | | | if (call_dissector(ositp_inactive_handle, next_tvb, pinfo, tree) == 0) |
| 238 | | | call_dissector(data_handle,tvb, pinfo, tree); |
| 239 | | | return; |
| 240 | | | } |
| 241 | | | |
| 242 | | | |
| 243 | | | cnf_vers = tvb_get_guint8(tvb, P_CLNP_VERS); |
| 244 | | | if (cnf_vers != ISO8473_V1) { |
| 245 | | | call_dissector(data_handle,tvb, pinfo, tree); |
| 246 | | | return; |
| 247 | | | } |
| 248 | | | |
| 249 | | | |
| 250 | | | cnf_hdr_len = tvb_get_guint8(tvb, P_CLNP_HDR_LEN); |
| 251 | | | opt_len = cnf_hdr_len; |
| 252 | | | |
| 253 | | | if (tree) { |
| 254 | | | ti = proto_tree_add_item(tree, proto_clnp, tvb, 0, cnf_hdr_len, FALSE); |
| 255 | | | clnp_tree = proto_item_add_subtree(ti, ett_clnp); |
| 256 | | | proto_tree_add_uint(clnp_tree, hf_clnp_id, tvb, P_CLNP_PROTO_ID, 1, |
| 257 | | | cnf_proto_id); |
| 258 | | | proto_tree_add_uint(clnp_tree, hf_clnp_length, tvb, P_CLNP_HDR_LEN, 1, |
| 259 | | | cnf_hdr_len); |
| 260 | | | proto_tree_add_uint(clnp_tree, hf_clnp_version, tvb, P_CLNP_VERS, 1, |
| 261 | | | cnf_vers); |
| 262 | | | cnf_ttl = tvb_get_guint8(tvb, P_CLNP_TTL); |
| 263 | | | proto_tree_add_uint_format(clnp_tree, hf_clnp_ttl, tvb, P_CLNP_TTL, 1, |
| 264 | | | cnf_ttl, |
| 265 | | | "Holding Time : %u (%u.%u secs)", |
| 266 | | | cnf_ttl, cnf_ttl / 2, (cnf_ttl % 2) * 5); |
| 267 | | | } |
| 268 | | | |
| 269 | | | cnf_type = tvb_get_guint8(tvb, P_CLNP_TYPE); |
| 270 | | | pdu_type_string = val_to_str(cnf_type & CNF_TYPE, npdu_type_abbrev_vals, |
| 271 | | | "Unknown (0x%02x)"); |
Ignored Return Value
The return value of val_to_str() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- The return value of val_to_str() is checked 98% of the time in this project. CodeSonar is configured to enforce Ignored Return Value checks for any function whose return value is checked at least 96% of the time, unless the function is used fewer than 20 times. (To modify these thresholds, use configuration file parameters RETURN_CHECKER_SAMPLE_SIZE and RETURN_CHECKER_RATIO. To exempt val_to_str() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 272 | | | flag_string[0] = '\0'; |
| 273 | | | if (cnf_type & CNF_SEG_OK) |
Event 2:
Taking true branch. cnf_type & 128 evaluates to true.
hide
|
|
| 274 | | | g_strlcat(flag_string, "S ", 7); |
| 275 | | | if (cnf_type & CNF_MORE_SEGS) |
Event 3:
Taking true branch. cnf_type & 64 evaluates to true.
hide
|
|
| 276 | | | g_strlcat(flag_string, "M ", 7); |
| 277 | | | if (cnf_type & CNF_ERR_OK) |
Event 4:
Taking true branch. cnf_type & 32 evaluates to true.
hide
|
|
| 278 | | | g_strlcat(flag_string, "E ", 7); |
| 279 | | | if (tree) { |
Event 5:
Skipping " if". tree evaluates to false.
hide
|
|
| 280 | | | ti = proto_tree_add_uint_format(clnp_tree, hf_clnp_type, tvb, P_CLNP_TYPE, 1, |
| 281 | | | cnf_type, |
| 282 | | | "PDU Type : 0x%02x (%s%s)", |
| 283 | | | cnf_type, |
| 284 | | | flag_string, |
| 285 | | | pdu_type_string); |
| 286 | | | type_tree = proto_item_add_subtree(ti, ett_clnp_type); |
| 287 | | | proto_tree_add_text(type_tree, tvb, P_CLNP_TYPE, 1, "%s", |
| 288 | | | decode_boolean_bitfield(cnf_type, CNF_SEG_OK, 8, |
| 289 | | | "Segmentation permitted", |
| 290 | | | "Segmentation not permitted")); |
| 291 | | | proto_tree_add_text(type_tree, tvb, P_CLNP_TYPE, 1, "%s", |
| 292 | | | decode_boolean_bitfield(cnf_type, CNF_MORE_SEGS, 8, |
| 293 | | | "More segments", |
| 294 | | | "Last segment")); |
| 295 | | | proto_tree_add_text(type_tree, tvb, P_CLNP_TYPE, 1, "%s", |
| 296 | | | decode_boolean_bitfield(cnf_type, CNF_ERR_OK, 8, |
| 297 | | | "Report error if PDU discarded", |
| 298 | | | "Don't report error if PDU discarded")); |
| 299 | | | proto_tree_add_text(type_tree, tvb, P_CLNP_TYPE, 1, "%s", |
| 300 | | | decode_enumerated_bitfield(cnf_type, CNF_TYPE, 8, |
| 301 | | | npdu_type_vals, "%s")); |
| 302 | | | } |
| 303 | | | |
| 304 | | | |
| 305 | | | |
| 306 | | | |
| 307 | | | |
| 308 | | | |
| 309 | | | if (tvb_length(tvb) < cnf_hdr_len) { |
Event 6:
Taking true branch. tvb_length(tvb) < cnf_hdr_len evaluates to true.
hide
|
|
| 310 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
Event 7:
Skipping " if". check_col(...) evaluates to false.
hide
|
|
| 311 | | | col_add_fstr(pinfo->cinfo, COL_INFO, "%s NPDU %s", pdu_type_string, flag_string); |
| 312 | | | } |
| 313 | | | |
| 314 | | | segment_length = tvb_get_ntohs(tvb, P_CLNP_SEGLEN); |
| 315 | | | cnf_cksum = tvb_get_ntohs(tvb, P_CLNP_CKSUM); |
| 316 | | | cksum_status = calc_checksum(tvb, 0, cnf_hdr_len, cnf_cksum); |
| 317 | | | if (tree) { |
Event 8:
Skipping " if". tree evaluates to false.
hide
|
|
| 318 | | | proto_tree_add_uint(clnp_tree, hf_clnp_pdu_length, tvb, P_CLNP_SEGLEN, 2, |
| 319 | | | segment_length); |
| 320 | | | switch (cksum_status) { |
| 321 | | | |
| 322 | | | default: |
| 323 | | | |
| 324 | | | |
| 325 | | | |
| 326 | | | |
| 327 | | | proto_tree_add_uint_format(clnp_tree, hf_clnp_checksum, tvb, |
| 328 | | | P_CLNP_CKSUM, 2, |
| 329 | | | cnf_cksum, |
| 330 | | | "Checksum : 0x%04x", |
| 331 | | | cnf_cksum); |
| 332 | | | break; |
| 333 | | | |
| 334 | | | case CKSUM_OK: |
| 335 | | | |
| 336 | | | |
| 337 | | | |
| 338 | | | proto_tree_add_uint_format(clnp_tree, hf_clnp_checksum, tvb, |
| 339 | | | P_CLNP_CKSUM, 2, |
| 340 | | | cnf_cksum, |
| 341 | | | "Checksum : 0x%04x (correct)", |
| 342 | | | cnf_cksum); |
| 343 | | | break; |
| 344 | | | |
| 345 | | | case CKSUM_NOT_OK: |
| 346 | | | |
| 347 | | | |
| 348 | | | |
| 349 | | | proto_tree_add_uint_format(clnp_tree, hf_clnp_checksum, tvb, |
| 350 | | | P_CLNP_CKSUM, 2, |
| 351 | | | cnf_cksum, |
| 352 | | | "Checksum : 0x%04x (incorrect)", |
| 353 | | | cnf_cksum); |
| 354 | | | break; |
| 355 | | | } |
| 356 | | | opt_len -= 9; |
| 357 | | | } |
| 358 | | | |
| 359 | | | |
| 360 | | | |
| 361 | | | offset = P_CLNP_ADDRESS_PART; |
| 362 | | | dst_len = tvb_get_guint8(tvb, offset); |
| 363 | | | dst_addr = tvb_get_ptr(tvb, offset + 1, dst_len); |
| 364 | | | nsel = tvb_get_guint8(tvb, offset + dst_len); |
| 365 | | | src_len = tvb_get_guint8(tvb, offset + dst_len + 1); |
| 366 | | | src_addr = tvb_get_ptr(tvb, offset + dst_len + 2, src_len); |
| 367 | | | |
| 368 | | | if (tree) { |
Event 9:
Skipping " if". tree evaluates to false.
hide
|
|
| 369 | | | proto_tree_add_uint(clnp_tree, hf_clnp_dest_length, tvb, offset, 1, |
| 370 | | | dst_len); |
| 371 | | | proto_tree_add_bytes_format(clnp_tree, hf_clnp_dest, tvb, offset + 1 , dst_len, |
| 372 | | | dst_addr, |
| 373 | | | " DA : %s", |
| 374 | | | print_nsap_net(dst_addr, dst_len)); |
| 375 | | | proto_tree_add_uint(clnp_tree, hf_clnp_src_length, tvb, |
| 376 | | | offset + 1 + dst_len, 1, src_len); |
| 377 | | | proto_tree_add_bytes_format(clnp_tree, hf_clnp_src, tvb, |
| 378 | | | offset + dst_len + 2, src_len, |
| 379 | | | src_addr, |
| 380 | | | " SA : %s", |
| 381 | | | print_nsap_net(src_addr, src_len)); |
| 382 | | | |
| 383 | | | opt_len -= dst_len + src_len +2; |
| 384 | | | } |
| 385 | | | |
| 386 | | | SET_ADDRESS(&pinfo->net_src, AT_OSI, src_len, src_addr);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
66 | #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \ |
67 | (addr)->type = (addr_type); \ |
68 | (addr)->len = (addr_len); \ |
69 | (addr)->data = (addr_data); \ |
70 | } |
| |
|
| 387 | | | SET_ADDRESS(&pinfo->src, AT_OSI, src_len, src_addr);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
66 | #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \ |
67 | (addr)->type = (addr_type); \ |
68 | (addr)->len = (addr_len); \ |
69 | (addr)->data = (addr_data); \ |
70 | } |
| |
|
| 388 | | | SET_ADDRESS(&pinfo->net_dst, AT_OSI, dst_len, dst_addr);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
66 | #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \ |
67 | (addr)->type = (addr_type); \ |
68 | (addr)->len = (addr_len); \ |
69 | (addr)->data = (addr_data); \ |
70 | } |
| |
|
| 389 | | | SET_ADDRESS(&pinfo->dst, AT_OSI, dst_len, dst_addr);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
66 | #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \ |
67 | (addr)->type = (addr_type); \ |
68 | (addr)->len = (addr_len); \ |
69 | (addr)->data = (addr_data); \ |
70 | } |
| |
|
| 390 | | | |
| 391 | | | |
| 392 | | | |
| 393 | | | offset += dst_len + src_len + 2; |
| 394 | | | |
| 395 | | | if (cnf_type & CNF_SEG_OK) { |
Event 10:
Taking true branch. cnf_type & 128 evaluates to true.
hide
|
|
| 396 | | | struct clnp_segment seg; |
| 397 | | | tvb_memcpy(tvb, (guint8 *)&seg, offset, sizeof(seg)); |
| 398 | | | |
| 399 | | | segment_offset = tvb_get_ntohs(tvb, offset + 2); |
| 400 | | | du_id = tvb_get_ntohs(tvb, offset); |
| 401 | | | if (tree) { |
Event 11:
Skipping " if". tree evaluates to false.
hide
|
|
| 402 | | | proto_tree_add_text(clnp_tree, tvb, offset, 2, |
| 403 | | | "Data unit identifier: %06u", |
| 404 | | | du_id); |
| 405 | | | proto_tree_add_text(clnp_tree, tvb, offset + 2 , 2, |
| 406 | | | "Segment offset : %6u", |
| 407 | | | segment_offset); |
| 408 | | | proto_tree_add_text(clnp_tree, tvb, offset + 4 , 2, |
| 409 | | | "Total length : %6u", |
| 410 | | | tvb_get_ntohs(tvb, offset + 4)); |
| 411 | | | } |
| 412 | | | |
| 413 | | | offset += 6; |
| 414 | | | opt_len -= 6; |
| 415 | | | } |
| 416 | | | |
| 417 | | | if (tree) { |
Event 12:
Skipping " if". tree evaluates to false.
hide
|
|
| 418 | | | |
| 419 | | | |
| 420 | | | |
| 421 | | | |
| 422 | | | |
| 423 | | | |
| 424 | | | |
| 425 | | | |
| 426 | | | dissect_osi_options( opt_len, |
| 427 | | | tvb, offset, clnp_tree ); |
| 428 | | | } |
| 429 | | | |
| 430 | | | |
| 431 | | | len = segment_length; |
| 432 | | | |
| 433 | | | offset = cnf_hdr_len; |
| 434 | | | |
| 435 | | | |
| 436 | | | |
| 437 | | | |
| 438 | | | |
| 439 | | | save_fragmented = pinfo->fragmented; |
| 440 | | | if (clnp_reassemble && (cnf_type & CNF_SEG_OK) && |
| 441 | | | ((cnf_type & CNF_MORE_SEGS) || segment_offset != 0) && |
| 442 | | | tvb_bytes_exist(tvb, offset, segment_length - cnf_hdr_len) && |
| 443 | | | segment_length > cnf_hdr_len && |
| 444 | | | cksum_status != CKSUM_NOT_OK) { |
| 445 | | | fd_head = fragment_add_check(tvb, offset, pinfo, du_id, clnp_segment_table, |
| 446 | | | clnp_reassembled_table, segment_offset, |
| 447 | | | segment_length - cnf_hdr_len, |
| 448 | | | cnf_type & CNF_MORE_SEGS); |
| 449 | | | |
| 450 | | | next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled CLNP", |
| 451 | | | fd_head, &clnp_frag_items, &update_col_info, clnp_tree); |
| 452 | | | } else { |
| 453 | | | |
| 454 | | | |
| 455 | | | |
| 456 | | | |
| 457 | | | |
| 458 | | | if ((cnf_type & CNF_SEG_OK) && segment_offset != 0) { |
Event 14:
Taking false branch. cnf_type & 128 evaluates to false.
hide
|
|
| 459 | | | |
| 460 | | | next_tvb = NULL; |
| 461 | | | } else { |
| 462 | | | |
| 463 | | | |
| 464 | | | |
| 465 | | | next_tvb = tvb_new_subset(tvb, offset, -1, -1); |
| 466 | | | |
| 467 | | | |
| 468 | | | |
| 469 | | | |
| 470 | | | |
| 471 | | | if ((cnf_type & (CNF_SEG_OK|CNF_MORE_SEGS)) == (CNF_SEG_OK|CNF_MORE_SEGS)) |
Event 15:
Taking true branch. (cnf_type & (128 | 64)) == (128 | 64) evaluates to true.
hide
|
|
| 472 | | | pinfo->fragmented = TRUE; |
Event 16:
!0 evaluates to true.
hide
|
|
| 473 | | | else |
| 474 | | | pinfo->fragmented = FALSE; |
| 475 | | | } |
| 476 | | | } |
| 477 | | | |
| 478 | | | if (next_tvb == NULL) { |
Event 17:
Skipping " if". next_tvb == (void *)0 evaluates to false.
hide
|
|
| 479 | | | |
| 480 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 481 | | | col_add_fstr(pinfo->cinfo, COL_INFO, "Fragmented %s NPDU %s(off=%u)", |
| 482 | | | pdu_type_string, flag_string, segment_offset); |
| 483 | | | |
| 484 | | | |
| 485 | | | |
| 486 | | | call_dissector(data_handle, tvb_new_subset(tvb, offset, -1, -1), pinfo, |
| 487 | | | tree); |
| 488 | | | pinfo->fragmented = save_fragmented; |
| 489 | | | return; |
| 490 | | | } |
| 491 | | | |
| 492 | | | if (tvb_offset_exists(tvb, offset)) { |
Event 18:
Taking true branch. tvb_offset_exists(tvb, offset) evaluates to true.
hide
|
|
| 493 | | | switch (cnf_type & CNF_TYPE) { |
Event 19:
cnf_type & 31 evaluates to 28.
hide
|
|
| 494 | | | |
| 495 | | | case DT_NPDU: |
| 496 | | | case MD_NPDU: |
| 497 | | | |
| 498 | | | |
| 499 | | | |
| 500 | | | |
| 501 | | | if (nsel == (char)tp_nsap_selector || always_decode_transport) { |
Event 20:
Taking true branch. nsel == (char)tp_nsap_selector evaluates to true.
hide
|
|
| 502 | | | if (call_dissector(ositp_handle, next_tvb, pinfo, tree) != 0) { |
Event 21:
Skipping " if". call_dissector(...) != 0 evaluates to false.
hide
|
|
| 503 | | | pinfo->fragmented = save_fragmented; |
| 504 | | | return; |
| 505 | | | } |
| 506 | | | } |
| 507 | | | if (dissector_try_heuristic(clnp_heur_subdissector_list, next_tvb, |
| 508 | | | pinfo, tree)) { |
Event 22:
Skipping " if". dissector_try_heuristic(...) evaluates to false.
hide
|
|
| 509 | | | pinfo->fragmented = save_fragmented; |
| 510 | | | return; |
| 511 | | | } |
| 512 | | | |
| 513 | | | break; |
| 514 | | | |
| 515 | | | case ER_NPDU: |
| 516 | | | |
| 517 | | | |
| 518 | | | |
| 519 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 520 | | | col_add_fstr(pinfo->cinfo, COL_INFO, "%s NPDU %s", pdu_type_string, flag_string); |
| 521 | | | if (tree) { |
| 522 | | | next_length = tvb_length_remaining(tvb, offset); |
| 523 | | | if (next_length != 0) { |
| 524 | | | |
| 525 | | | ti = proto_tree_add_text(clnp_tree, tvb, offset, next_length, |
| 526 | | | "Discarded PDU"); |
| 527 | | | discpdu_tree = proto_item_add_subtree(ti, ett_clnp_disc_pdu); |
| 528 | | | |
| 529 | | | |
| 530 | | | |
| 531 | | | |
| 532 | | | |
| 533 | | | save_in_error_pkt = pinfo->in_error_pkt; |
| 534 | | | pinfo->in_error_pkt = TRUE; |
| 535 | | | |
| 536 | | | call_dissector(clnp_handle, next_tvb, pinfo, discpdu_tree); |
| 537 | | | |
| 538 | | | |
| 539 | | | pinfo->in_error_pkt = save_in_error_pkt; |
| 540 | | | } |
| 541 | | | } |
| 542 | | | pinfo->fragmented = save_fragmented; |
| 543 | | | return; |
| 544 | | | |
| 545 | | | case ERQ_NPDU: |
| 546 | | | case ERP_NPDU: |
| 547 | | | |
| 548 | | | break; |
| 549 | | | } |
| 550 | | | } |
| 551 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
Event 23:
Skipping " if". check_col(...) evaluates to false.
hide
|
|
| 552 | | | col_add_fstr(pinfo->cinfo, COL_INFO, "%s NPDU %s", pdu_type_string, flag_string); |
| 553 | | | call_dissector(data_handle,next_tvb, pinfo, tree); |
| 554 | | | pinfo->fragmented = save_fragmented; |
| 555 | | | } |
| |