Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Data Flow  at libpcap.c:775

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

libpcap_read_header

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/libpcap.c)expand/collapse
Show more  
 745  static int libpcap_read_header(wtap *wth, int *err, gchar **err_info,
 746      struct pcaprec_ss990915_hdr *hdr)
 747  {
 748          int     bytes_to_read, bytes_read;
 749   
 750          /* Read record header. */
 751          errno = WTAP_ERR_CANT_READ;
 752          switch (wth->file_type) {
 753   
 754          case WTAP_FILE_PCAP:
 755          case WTAP_FILE_PCAP_AIX:
 756          case WTAP_FILE_PCAP_NSEC:
 757                  bytes_to_read = sizeof (struct pcaprec_hdr);
 758                  break;
 759   
 760          case WTAP_FILE_PCAP_SS990417:
 761          case WTAP_FILE_PCAP_SS991029:
 762                  bytes_to_read = sizeof (struct pcaprec_modified_hdr);
 763                  break;
 764   
 765          case WTAP_FILE_PCAP_SS990915:
 766                  bytes_to_read = sizeof (struct pcaprec_ss990915_hdr);
 767                  break;
 768   
 769          case WTAP_FILE_PCAP_NOKIA:
 770                  bytes_to_read = sizeof (struct pcaprec_nokia_hdr);
 771                  break;
 772   
 773          default:
 774                  g_assert_not_reached();
 775                  bytes_to_read = 0;
 776          }
 777          bytes_read = file_read(hdr, 1, bytes_to_read, wth->fh);
 778          if (bytes_read != bytes_to_read) {
 779                  *err = file_error(wth->fh);
 780                  if (*err == 0 && bytes_read != 0) {
 781                          *err = WTAP_ERR_SHORT_READ;
 782                  }
 783                  return -1;
 784          }
 785   
 786          adjust_header(wth, &hdr->hdr);
 787   
 788          if (hdr->hdr.incl_len > WTAP_MAX_PACKET_SIZE) {
 789                  /*
 790                   * Probably a corrupt capture file; return an error,
 791                   * so that our caller doesn't blow up trying to allocate 
 792                   * space for an immensely-large packet, and so that 
 793                   * the code to try to guess what type of libpcap file 
 794                   * this is can tell when it's not the type we're guessing 
 795                   * it is.
 796                   */
 797                  *err = WTAP_ERR_BAD_RECORD;
 798                  if (err_info != NULL) {
 799                          *err_info = g_strdup_printf("pcap: File has %u-byte packet, bigger than maximum of %u",
 800                              hdr->hdr.incl_len, WTAP_MAX_PACKET_SIZE);
 801                  }
 802                  return -1;
 803          }
 804   
 805          if (hdr->hdr.orig_len > WTAP_MAX_PACKET_SIZE) {
 806                  /*
 807                   * Probably a corrupt capture file; return an error,
 808                   * so that our caller doesn't blow up trying to
 809                   * cope with a huge "real" packet length, and so that 
 810                   * the code to try to guess what type of libpcap file 
 811                   * this is can tell when it's not the type we're guessing 
 812                   * it is.
 813                   */
 814                  *err = WTAP_ERR_BAD_RECORD;
 815                  if (err_info != NULL) {
 816                          *err_info = g_strdup_printf("pcap: File has %u-byte packet, bigger than maximum of %u",
 817                              hdr->hdr.orig_len, WTAP_MAX_PACKET_SIZE);
 818                  }
 819                  return -1;
 820          }
 821   
 822          return bytes_read;
 823  }
Show more  




Change Warning 1016.29668 : Unreachable Data Flow

Priority:
State:
Finding:
Owner:
Note: