Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Control Flow  at packet-ismacryp.c:585

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

dissect_auheader

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ismacryp.c)expand/collapse
Show more  
 420  static offset_struct* dissect_auheader( tvbuff_t *tvb, offset_struct *poffset, packet_info *pinfo, proto_tree *ismacryp_tree, guint set_version )
 421  {
 422          proto_item *ismacryp_item;
 423          proto_tree *ismacryp_header_tree;
 424          proto_tree *ismacryp_header_byte_tree;
 425           
 426          guint16 header_len_bytes = 0; /* total length of non-first AU header in bytes (rounded up) */
 427          gint header_len = 0; /* length of AU headers in bits */
 428          gint cts_flag =0;
 429          gint dts_flag =0;
 430          gboolean first_au_flag=FALSE;
 431          gint bit_offset = 0;
 432           
 433          /*first determine total AU header length */
 434          /* calculate each AU header length in bits first */
 435          switch (set_version) {
 436                  case V11:
 437                          if (selective_encryption)
 438                                  header_len+=8; /* add one byte to header length */
 439                          break;
 440                  case V20:
 441                          if (selective_encryption || slice_indication || padding_indication)
 442                                  header_len+=8; /* add one byte to header length */
 443                          break;
 444                  default:
 445                          DISSECTOR_ASSERT_NOT_REACHED();
 446                          break;
 447          }       /* end switch */
 448          header_len+=au_size_length; /* add au size length */
 449                           
 450          if (poffset->offset_bytes==AU_HEADERS_LENGTH_SIZE){     /*first AU */
 451                  header_len+=8*(iv_length);                      /* add IV length */
 452                  header_len+=8*key_indicator_length;             /* add key indicator length */
 453                  header_len+=au_index_length;                    /* add AU index length */
 454                  first_au_flag = TRUE;
 455          }
 456          else { /* not the first AU */
 457                  if (key_indicator_per_au_flag == TRUE)  
 458                          header_len+=8*key_indicator_length; /* add key indicator length */
 459                  header_len+=8*(delta_iv_length);                /* add delta IV length */
 460                  header_len+=au_index_delta_length;              /* add AU delta index length */
 461          }
 462          /* CTS flag is present? */
 463          if (cts_delta_length != 0){    /* need to test whether cts_delta_flag is TRUE or FALSE */
 464                  cts_flag=tvb_get_bits8(tvb, AU_HEADERS_LENGTH_SIZE*8+header_len, 1); /*fetch 1 bit CTS flag  */
 465                  header_len+=1;         /* add CTS flag bit */
 466                  if (cts_flag==1)
 467                          header_len+=cts_delta_length; /* add CTS delta length bits if CTS flag SET */
 468          }
 469          /* DTS flag is present? */
 470          if (dts_delta_length != 0){ /* need to test whether dts_delta_flag is TRUE or FALSE */
 471                  dts_flag=tvb_get_bits8(tvb, AU_HEADERS_LENGTH_SIZE*8+header_len, 1); /*fetch 1 bit DTS flag */
 472                  header_len+=1;      /* add DTS flag bit */
 473                  if (dts_flag==1)
 474                          header_len+=dts_delta_length; /* add DTS delta length bits if DTS flag SET */
 475          }
 476          /* RAP flag present? */
 477          if (random_access_indication != FALSE)
 478                  header_len+=1;      /* add 1 bit RAP flag */
 479           
 480          /* stream state indication present */
 481          if (stream_state_indication !=0)
 482                  header_len+=stream_state_indication; /* add stream state indication bits */
 483           
 484          /* convert header_len to bytes (rounded up) */
 485          if (header_len% 8!=0)
 486          {
 487                  header_len_bytes=((header_len)/8)+1; /*add 1 */
 488          }
 489          else 
 490                  header_len_bytes=((header_len)/8);
 491                   
 492          /* add AU header tree  */
 493          ismacryp_item = proto_tree_add_item(ismacryp_tree, hf_ismacryp_header, tvb, poffset->offset_bytes, header_len_bytes, FALSE );
 494          proto_item_append_text(ismacryp_item, ": Length=%d bits", header_len); /* add text to Header tree indicating length */
 495          /* sanity check if actual AU header length is zero bits, which indicates an error */
 496          if ( header_len == 0) /* something wrong */
 497          {
 498                  proto_item_append_text(ismacryp_item, " Error - zero bit AU header size - check parameters!");
 499          }
 500          ismacryp_header_tree = proto_item_add_subtree(ismacryp_item, ett_ismacryp_header);
 501                                           
 502          /* ismacryp header analysis */
 503          /* we are being asked for details  */
 504                   
 505          /* Extra 1 Byte Header? */
 506           
 507          if ((set_version==V20 && (selective_encryption || slice_indication || padding_indication))
 508                  || (set_version==V11 && selective_encryption)){
 509                                                           
 510                  /* add  header byte tree        */
 511                  ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_header_byte,
 512                                                      tvb, poffset->offset_bytes, 1, FALSE );
 513                  proto_item_append_text(ismacryp_item, ": Length=8 bits"); /* add text to Header byte tree indicating length */
 514                  ismacryp_header_byte_tree = proto_item_add_subtree(ismacryp_item, ett_ismacryp_header_byte);
 515                   
 516                  /*ismacryp_header_byte_tree */  
 517                  /* we are being asked for details */
 518                  /* tvb is network order, so get MSB bits first, so shift 8 bits and work "backwards" */
 519                  add_bits(poffset,7);   /*shift 7 bits to get correct bit */
 520                  /* AU_is_encrypted bit */
 521                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */        
 522                  if (selective_encryption){ /* bit used */
 523                          ismacryp_item = proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_au_is_encrypted,
 524                                                                   tvb, bit_offset, 1, FALSE); /*fetch 1 bit AU_is_encrypted */
 525                  }
 526                  else { /* bit unused */
 527                          ismacryp_item = proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_unused_bits,
 528                                                                   tvb, bit_offset, 1, FALSE); /*fetch 1 bit unused */
 529                  }
 530                  switch (set_version){ /* ISMACryp version? */
 531                          case V11:
 532                                  /* Reserved bits */
 533                                  add_bits(poffset, -7); /* move back 7 bits for reserved bits */
 534                                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 535                                  ismacryp_item = proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_reserved_bits,
 536                                                                           tvb, bit_offset, 7, FALSE); /*fetch 7 bits reserved */
 537                                  add_bits(poffset,8);   /* offset to next byte */
 538                                  break;
 539                          case V20:
 540                                  /* Slice_start bit */
 541                                  add_bits(poffset, -1); /* move back 1 bit for slice_start */
 542                                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 543                                  if (slice_indication){
 544                                          ismacryp_item = proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_slice_start,
 545                                                                                   tvb, bit_offset, 1, FALSE); /*fetch 1 bit slice_start */
 546                                  }
 547                                  else { /* bit unused */
 548                                          ismacryp_item = proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_unused_bits,
 549                                                                                   tvb, bit_offset, 1, FALSE); /*fetch 1 bit unused */
 550                                  }
 551                                  add_bits(poffset, -1); /* move back 1 bit for slice_end */
 552   
 553                                  /* Slice_end bit */
 554                                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 555                                  if (slice_indication){
 556                                          ismacryp_item = proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_slice_end,
 557                                                                                   tvb, bit_offset, 1, FALSE); /*fetch 1 bit Slice_end */
 558                                  }
 559                                  else { /* bit unused */
 560                                          ismacryp_item = proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_unused_bits,
 561                                                                                   tvb, bit_offset, 1, FALSE); /*fetch 1 bit unused */
 562                                  }
 563                                  add_bits(poffset, -3); /* move back 3 bits for padding_bitcount */
 564   
 565                                  /* Padding_bitcount bits */
 566                                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 567                                  if (padding_indication){
 568                                          ismacryp_item = proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_padding_bitcount,
 569                                                                                   tvb, bit_offset, 3, FALSE); /*fetch 3 bits padding_bitcount */
 570                                  }
 571                                  else { /* bits unused */
 572                                          ismacryp_item = proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_unused_bits,
 573                                                                                   tvb, bit_offset, 3, FALSE); /*fetch 3 bits unused */
 574                                  }
 575                                  add_bits(poffset, -2); /* move back 2 bits for reserved bits */
 576                           
 577                                  /* Reserved bits */
 578                                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 579                                  ismacryp_item = proto_tree_add_bits_item(ismacryp_header_byte_tree, hf_ismacryp_reserved_bits,
 580                                                                           tvb, bit_offset, 2, FALSE); /*fetch 2 bits reserved */
 581                                  add_bits(poffset,8); /* offset to next byte */
 582                                  break;
 583                          default:
 584                                  DISSECTOR_ASSERT_NOT_REACHED();
 585                                  break;
 586                  } /* end switch set_version */
 587          } /* end selective encryption */
 588          /* IV */
 589          if (first_au_flag == TRUE && iv_length != 0)
 590          {
 591                  ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_iv, tvb, poffset->offset_bytes, iv_length, FALSE);
 592                  proto_item_append_text(ismacryp_item, ": Length=%d bytes",iv_length); /* add IV info */
 593                  if ( check_col( pinfo->cinfo, COL_INFO) ) {
 594                          col_append_fstr( pinfo->cinfo, COL_INFO,
 595                          ", IV=0x%s", tvb_bytes_to_str_punct(tvb, poffset->offset_bytes, iv_length,' '));
 596                  }
 597                  poffset->offset_bytes+=iv_length; /* add IV length to offset_bytes */
 598          }
 599          /*Delta  IV */
 600          if (first_au_flag == FALSE && delta_iv_length != 0)
 601          {
 602                  ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_delta_iv,
 603                                                      tvb, poffset->offset_bytes, delta_iv_length, FALSE);
 604                  proto_item_append_text(ismacryp_item, ": Length=%d bytes",delta_iv_length); /* add delta IV info */
 605                  if ( check_col( pinfo->cinfo, COL_INFO) ) {
 606                          col_append_fstr( pinfo->cinfo, COL_INFO,
 607                          ", Delta IV=0x%s", tvb_bytes_to_str_punct(tvb, poffset->offset_bytes, delta_iv_length,' '));
 608                  }
 609                  poffset->offset_bytes+=iv_length; /* add IV length to offset_bytes */
 610          }                                
 611          /* Key Indicator */
 612          if ( key_indicator_length != 0 && ( first_au_flag == TRUE || key_indicator_per_au_flag == TRUE) )
 613          {                        
 614                  /* (first AU or KI for each AU) and non-zero KeyIndicator size */
 615                  ismacryp_item = proto_tree_add_item(ismacryp_header_tree, hf_ismacryp_key_indicator,  
 616                                                      tvb, poffset->offset_bytes, key_indicator_length, FALSE);
 617                  proto_item_append_text(ismacryp_item,": Length=%d bytes",key_indicator_length); /* add KI info */
 618                  if ( check_col( pinfo->cinfo, COL_INFO) ) {
 619                          col_append_fstr( pinfo->cinfo, COL_INFO,
 620                                           ", KI=0x%s", tvb_bytes_to_str_punct(tvb, poffset->offset_bytes, key_indicator_length,' '));
 621                  }
 622                  poffset->offset_bytes+=key_indicator_length; /* add KI length to offset_bytes */
 623          }                
 624          /* AU size */
 625          if (au_size_length != 0) /* in bits */
 626          {                        
 627                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 628                  ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree,hf_ismacryp_au_size,
 629                                                           tvb, bit_offset, au_size_length, FALSE);
 630                  proto_item_append_text(ismacryp_item, " bytes: Length=%d bits",au_size_length); /* add AU size info */                  
 631                  bit_offset+=au_size_length;
 632                  add_bits(poffset, au_size_length);      
 633          }                                        
 634          /* AU Index */
 635          if (first_au_flag == TRUE && au_index_length != 0) /* first AU and non-zero AU size */
 636          {        
 637                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 638                  ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree,hf_ismacryp_au_index,
 639                                                           tvb, bit_offset, au_index_length, FALSE);
 640                  proto_item_append_text(ismacryp_item, " bits: Length=%d bits",au_index_length); /* add AU index info */
 641                  bit_offset+=au_index_length;
 642                  add_bits(poffset, au_index_length);
 643          }                        
 644          /* AU index delta */
 645          if (first_au_flag == FALSE && au_index_delta_length != 0) /* not first AU and non-zero AU delta size */
 646          {        
 647                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 648                  ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree,hf_ismacryp_au_index_delta,
 649                                                           tvb, bit_offset, au_index_delta_length, FALSE);
 650                  proto_item_append_text(ismacryp_item, ": Length=%d bits", au_index_delta_length); /* add AU index info */
 651                  bit_offset+=au_index_delta_length;
 652                  add_bits(poffset, au_index_delta_length);
 653          }        
 654          /* CTS delta value */
 655          if (cts_delta_length != 0)
 656          {
 657                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 658                  ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_cts_flag,
 659                                                           tvb, bit_offset, 1, FALSE); /* read CTS flag */
 660                  add_bits(poffset, 1);
 661                  if (cts_flag==1)
 662                  {
 663                          /* now fetch CTS delta value (remember offset 1 bit due to CTS flag) */
 664                          bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 665                          ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_cts_delta,
 666                                                                   tvb, bit_offset, cts_delta_length, FALSE); /* read CTS delta value */
 667                          proto_item_append_text(ismacryp_item, ": Length=%d bits",cts_delta_length); /* add CTS delta info */
 668                          add_bits(poffset, cts_delta_length);
 669                  }
 670          }        
 671          /* DTS delta value */
 672          if (dts_delta_length != 0)
 673          {                
 674                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 675                  ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_dts_flag,
 676                                                           tvb, bit_offset, 1, FALSE); /* read DTS flag */
 677                  add_bits(poffset, 1);
 678                   
 679                  /* now fetch DTS delta value (remember offset x bits due to DTS flag) */
 680                  if (dts_flag ==1)
 681                  {
 682                          bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 683                          ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_dts_delta,
 684                                                                   tvb, bit_offset, dts_delta_length, FALSE); /* read DTS delta value */
 685                          proto_item_append_text(ismacryp_item, ": Length=%d bits",dts_delta_length); /* add DTS delta info */
 686                          add_bits(poffset, dts_delta_length);
 687                  }
 688          }        
 689          /* RAP */
 690          if (random_access_indication != FALSE)
 691          {
 692                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 693                  ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_rap_flag,
 694                                                           tvb, bit_offset, 1, FALSE); /* read RAP flag */
 695                  add_bits(poffset, 1);    
 696          }
 697          /*STREAM STATE */
 698          if (stream_state_indication != 0)
 699          {
 700                  bit_offset = (poffset->offset_bytes)*8+poffset->offset_bits; /* offset in bits */
 701                  ismacryp_item = proto_tree_add_bits_item(ismacryp_header_tree, hf_ismacryp_stream_state,
 702                                                           tvb, bit_offset, stream_state_indication, FALSE); /* read stream state */
 703                  add_bits(poffset, stream_state_indication);
 704          }                        
 705          /* end header details */
 706  return poffset;
 707  }
Show more  




Change Warning 2701.32051 : Unreachable Control Flow

Because they are very similar, this warning shares annotations with warning 2701.32052.

Priority:
State:
Finding:
Owner:
Note: