Text   |  XML   |  ReML   |   Visible Warnings:

Uninitialized Variable  at iseries.c:761

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

iseries_parse_packet

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/iseries.c)expand/collapse
Show more  
 473  iseries_parse_packet (wtap * wth, FILE_T fh,
 474                        union wtap_pseudo_header *pseudo_header, guint8 * pd,
 475                        int *err, gchar ** err_info)
 476  {
 477    gint64 cur_off;
 478    gboolean isValid, isCurrentPacket, IPread, TCPread, isDATA;
 479    int num_items_scanned, line, pktline, buflen, i;
 480    guint32 pkt_len;
 481    int cap_len, pktnum, month, day, year, hr, min, sec, csec;
 482    char direction[2], destmac[13], srcmac[13], type[5], ipheader[41],
 483      tcpheader[81];
 484    char hex1[17], hex2[17], hex3[17], hex4[17];
 485    char data[ISERIES_LINE_LENGTH * 2];
 486    guint8 *buf, *asciibuf;
 487    char   *tcpdatabuf, *workbuf;
 488    struct tm tm;
 489   
 490    /*
 491     * Check for packet headers in first 3 lines this should handle page breaks 
 492     * situations and the header lines output at each page throw and ensure we 
 493     * read both the captured and packet lengths.
 494     */
 495    isValid = FALSE;
 496    for (line = 1; line < ISERIES_PKT_LINES_TO_CHECK; line++)
 497      {
 498        cur_off = file_tell (fh);
 499        if (file_gets (data, ISERIES_LINE_LENGTH, fh) == NULL)
 500          {
 501            *err = file_error (fh);
 502            if (*err == 0)
 503              {
 504                *err = WTAP_ERR_SHORT_READ;
 505              }
 506            return -1;
 507          }
 508        /* Convert UNICODE data to ASCII */
 509        if (wth->capture.iseries->format == ISERIES_FORMAT_UNICODE)
 510          {
 511           iseries_UNICODE_to_ASCII ((guint8 *)data, ISERIES_LINE_LENGTH);
 512          }
 513        /* look for packet header */
 514        for (i=0; i<8; i++) {
 515                    if (strncmp(data+i,"*",1) == 0)
 516                            g_strlcpy(data+i," ",(ISERIES_LINE_LENGTH * 2));
 517        }
 518        num_items_scanned =
 519          sscanf (data,
 520                  "%6d   %1s   %6d  %d:%d:%d.%d               %12s  %12s  ETHV2   Type: %4s",
 521                  &pktnum, direction, &cap_len, &hr, &min, &sec, &csec, destmac,
 522                  srcmac, type);
 523        if (num_items_scanned == 10)
 524          {
 525            /* OK! We found the packet header line */
 526            isValid = TRUE;
 527            /*
 528             * XXX - The Capture length returned by the iSeries trace doesn't seem to include the src/dest MAC 
 529             * addresses or the packet type. So we add them here.
 530             */
 531            cap_len += 14;
 532            break;
 533          }
 534      }
 535   
 536    /*
 537     * If no packet header found we exit at this point and inform the user.
 538     */
 539    if (!isValid)
 540      {
 541        *err = WTAP_ERR_BAD_RECORD;
 542        *err_info = g_strdup ("iseries: packet header isn't valid");
 543        return -1;
 544      }
 545   
 546    /*
 547     * If we have Wiretap Header then populate it here 
 548     *
 549     * XXX - Timer resolution on the iSeries is hardware dependant; the value for csec may be
 550     * different on other platforms though all the traces I've seen seem to show resolution 
 551     * to Milliseconds (i.e HH:MM:SS.nnnnn) or Nanoseconds (i.e HH:MM:SS.nnnnnn)
 552     */
 553    if (wth->capture.iseries->sdate)
 554      {
 555        num_items_scanned =
 556          sscanf (wth->capture.iseries->sdate, "%d/%d/%d", &month, &day, &year);
 557        tm.tm_year = 100 + year;
 558        tm.tm_mon = month - 1;
 559        tm.tm_mday = day;
 560        tm.tm_hour = hr;
 561        tm.tm_min = min;
 562        tm.tm_sec = sec;
 563        tm.tm_isdst = -1;
 564        wth->phdr.ts.secs = mktime (&tm);
 565        /* Handle Millisecond precision for timer */
 566        if (csec > 99999)
 567          {
 568            wth->phdr.ts.nsecs = csec * 1000;
 569          }
 570        /* Handle Nanosecond precision for timer */
 571        else 
 572          {
 573            wth->phdr.ts.nsecs = csec * 10000;
 574          }
 575      }
 576   
 577      wth->phdr.caplen = cap_len;
 578      wth->phdr.pkt_encap = WTAP_ENCAP_ETHERNET;
 579      pseudo_header->eth.fcs_len = -1;
 580   
 581    /*
 582     * Start Reading packet contents
 583     */
 584    isCurrentPacket = TRUE;
 585    IPread = FALSE;
 586    TCPread = FALSE;
 587    isDATA = FALSE;
 588    /*
 589     * Allocate 2 work buffers to handle concatentation of the hex data block
 590     */
 591    tcpdatabuf = g_malloc (ISERIES_PKT_ALLOC_SIZE);
 592    g_snprintf (tcpdatabuf, 1, "%s", "");
 593    workbuf = g_malloc (ISERIES_PKT_ALLOC_SIZE);
 594    g_snprintf (workbuf, 1, "%s", "");
 595    /* loop through packet lines and breakout when the next packet header is read */
 596    pktline = 0;
 597    while (isCurrentPacket)
 598      {
 599        pktline++;
 600        /* Read the next line */
 601        if (file_gets (data, ISERIES_LINE_LENGTH, fh) == NULL)
 602          {
 603            if (file_eof (fh))
 604              {
 605                break;
 606              }
 607            else 
 608              {
 609                *err = file_error (fh);
 610                if (*err == 0)
 611                  {
 612                    *err = WTAP_ERR_SHORT_READ;
 613                  }
 614                return -1;
 615              }
 616
696
Show [ Lines 616 to 696 omitted. ]
 697              {
 698                return -1;
 699              }
 700          }
 701      }
 702   
 703    /*
 704     * For a formated trace ensure we have read at least the IP and TCP headers otherwise
 705     * exit and pass error message to user.
 706     */
 707    if (wth->capture.iseries->tcp_formatted)
 708      {
 709        if (!IPread)
 710          {
 711            *err = WTAP_ERR_BAD_RECORD;
 712            *err_info = g_strdup ("iseries: IP header isn't valid");
 713            return -1;
 714          }
 715        if (!TCPread)
 716          {
 717            *err = WTAP_ERR_BAD_RECORD;
 718            *err_info = g_strdup ("iseries: TCP header isn't valid");
 719            return -1;
 720          }
 721      }
 722   
 723    /*
 724     * Create a buffer to hold all the ASCII Hex data and populate with all the 
 725     * extracted data.
 726     */
 727    asciibuf = g_malloc (ISERIES_PKT_ALLOC_SIZE);
 728    if (isDATA)
 729      {
 730        /* packet contained data */
 731        if (wth->capture.iseries->tcp_formatted)
 732          {
 733            /* build string for formatted fields */
 734            g_snprintf (asciibuf, ISERIES_PKT_ALLOC_SIZE, "%s%s%s%s%s%s",
 735                        destmac, srcmac, type, ipheader, tcpheader, tcpdatabuf);
 736          }
 737        else 
 738          {
 739            /* build string for unformatted data fields */
 740            g_snprintf (asciibuf, ISERIES_PKT_ALLOC_SIZE, "%s%s%s%s", destmac,
 741                        srcmac, type, tcpdatabuf);
 742          }
 743      }
 744    else 
 745      {
 746        /* No data in the packet */
 747        g_snprintf (asciibuf, ISERIES_PKT_ALLOC_SIZE, "%s%s%s%s%s", destmac,
 748                    srcmac, type, ipheader, tcpheader);
 749      }
 750   
 751    /*
 752     * Extract the packet length from the actual IP header; this may
 753     * differ from the capture length reported by the formatted trace.
 754     * Note: if the entire Ethernet packet is present, but the IP 
 755     * packet is less than 46 bytes long, there will be padding, and 
 756     * the length in the IP header won't include the padding; if 
 757     * the packet length is less than the captured length, set the
 758     * packet length to the captured length.
 759     */
 760    num_items_scanned = sscanf (asciibuf + 32, "%4x", &pkt_len);
 761    wth->phdr.len = pkt_len + 14;
Show more  




Change Warning 1011.30026 : Uninitialized Variable

Priority:
State:
Finding:
Owner:
Note: