Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at text2pcap.c:795

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

parse_preamble

(/home/sate/Testcases/c/cve/wireshark-1.2.0/text2pcap.c)expand/collapse
Show more  
 740  parse_preamble (void)
 741  {
 742          struct tm timecode;
 743          char *subsecs;
 744          char *p;
 745          int  subseclen;
 746          int  i;
 747   
 748          /*
 749           * If no "-t" flag was specified, don't attempt to parse a packet 
 750           * preamble to extract a time stamp.
 751           */
 752          if (ts_fmt == NULL)
 753              return;
 754   
 755          /*
 756           * Initialize to today localtime, just in case not all fields
 757           * of the date and time are specified.
 758           */
 759   
 760          timecode = timecode_default;
 761          ts_usec = 0;
 762   
 763          /*
 764           * Null-terminate the preamble.
 765           */
 766          packet_preamble[packet_preamble_len] = '\0';
 767   
 768          /* Ensure preamble has more than two chars before atempting to parse.
 769           * This should cover line breaks etc that get counted.
 770           */
 771          if ( strlen(packet_preamble) > 2 ) {
 772                  /* Get Time leaving subseconds */
 773                  subsecs = strptime( packet_preamble, ts_fmt, &timecode );
 774                  if (subsecs != NULL) {
 775                          /* Get the long time from the tm structure */
 776                          /*  (will return -1 if failure)            */
 777                          ts_sec  = mktime( &timecode );
 778                  } else 
 779                          ts_sec = -1;    /* we failed to parse it */
 780   
 781                  /* This will ensure incorrectly parsed dates get set to zero */
 782                  if ( -1 == ts_sec )
 783                  {
 784                          /* Sanitize - remove all '\r' */
 785                          char *c;
 786                          while ((c = strchr(packet_preamble, '\r')) != NULL) *c=' ';
 787                          fprintf (stderr, "Failure processing time \"%s\" using time format \"%s\"\n   (defaulting to Jan 1,1970 00:00:00 GMT)\n",
 788                                   packet_preamble, ts_fmt);
 789                          if (debug >= 2) {
 790                                  fprintf(stderr, "timecode: %02d/%02d/%d %02d:%02d:%02d %d\n",
 791                                          timecode.tm_mday, timecode.tm_mon, timecode.tm_year,
 792                                          timecode.tm_hour, timecode.tm_min, timecode.tm_sec, timecode.tm_isdst);
 793                          }
 794                          ts_sec  = 0;  /* Jan 1,1970: 00:00 GMT; tshark/wireshark will display date/time as adjusted by timezone */
 795                          ts_usec = 0;
 796                  }
 797                  else 
 798                  {
 799                          /* Parse subseconds */
 800                          ts_usec = strtol(subsecs, &p, 10);
 801                          if (subsecs == p) {
 802                                  /* Error */
 803                                  ts_usec = 0;
 804                          } else {
 805                                  /*
 806                                   * Convert that number to a number
 807                                   * of microseconds; if it's N digits
 808                                   * long, it's in units of 10^(-N) seconds,
 809                                   * so, to convert it to units of
 810                                   * 10^-6 seconds, we multiply by 
 811                                   * 10^(6-N).
 812                                   */
 813                                  subseclen = (int) (p - subsecs);
 814                                  if (subseclen > 6) {
 815                                          /*
 816                                           * *More* than 6 digits; 6-N is 
 817                                           * negative, so we divide by
 818                                           * 10^(N-6).
 819                                           */
 820                                          for (i = subseclen - 6; i != 0; i--)
 821                                                  ts_usec /= 10;
 822                                  } else if (subseclen < 6) {
 823                                          for (i = 6 - subseclen; i != 0; i--)
 824                                                  ts_usec *= 10;
 825                                  }
 826                          }
 827                  }
 828          }
 829          if (debug >= 2) {
 830                  char *c;
 831                  while ((c = strchr(packet_preamble, '\r')) != NULL) *c=' ';
 832                  fprintf(stderr, "[[parse_preamble: \"%s\"]]\n", packet_preamble);
 833                  fprintf(stderr, "Format(%s), time(%u), subsecs(%u)\n", ts_fmt, (guint32)ts_sec, ts_usec);
 834          }
 835   
 836   
 837          /* Clear Preamble */
 838          packet_preamble_len = 0;
 839  }
Show more  




Change Warning 4900.29920 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: