Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at radcom.c:361

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

radcom_read

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/radcom.c)expand/collapse
Show more  
 269  static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_,
 270      gint64 *data_offset)
 271  {
 272          int     ret;
 273          struct radcomrec_hdr hdr;
 274          guint16 data_length, real_length, length;
 275          guint32 sec;
 276          int     bytes_read;
 277          struct tm tm;
 278          guchar  phdr[8];
 279          char    fcs[2];
 280   
 281          /* Read record header. */
 282          *data_offset = wth->data_offset;
 283          ret = radcom_read_rec_header(wth->fh, &hdr, err);
 284          if (ret <= 0) {
 285                  /* Read error or EOF */
 286                  return FALSE;
 287          }
 288          wth->data_offset += sizeof hdr;
 289          data_length = pletohs(&hdr.data_length);
 290          if (data_length == 0) {
 291                  /*
 292                   * The last record appears to have 0 in its "data_length"
 293                   * field, but non-zero values in other fields, so we
 294                   * check for that and treat it as an EOF indication.
 295                   */
 296                  *err = 0;
 297                  return FALSE;
 298          }
 299          length = pletohs(&hdr.length);
 300          real_length = pletohs(&hdr.real_length);
 301   
 302          if (wth->file_encap == WTAP_ENCAP_LAPB) {
 303                  length -= 2; /* FCS */
 304                  real_length -= 2;
 305          }
 306   
 307          wth->phdr.len = real_length;
 308          wth->phdr.caplen = length;
 309   
 310          tm.tm_year = pletohs(&hdr.date.year)-1900;
 311          tm.tm_mon = (hdr.date.month&0x0f)-1;
 312          tm.tm_mday = hdr.date.day;
 313          sec = pletohl(&hdr.date.sec);
 314          tm.tm_hour = sec/3600;
 315          tm.tm_min = (sec%3600)/60;
 316          tm.tm_sec = sec%60;
 317          tm.tm_isdst = -1;
 318          wth->phdr.ts.secs = mktime(&tm);
 319          wth->phdr.ts.nsecs = pletohl(&hdr.date.usec) * 1000;
 320   
 321          switch (wth->file_encap) {
 322   
 323          case WTAP_ENCAP_ETHERNET:
 324                  /* XXX - is there an FCS? */
 325                  wth->pseudo_header.eth.fcs_len = -1;
 326                  break;
 327   
 328          case WTAP_ENCAP_LAPB:
 329                  wth->pseudo_header.x25.flags = (hdr.dce & 0x1) ?
 330                      0x00 : FROM_DCE;
 331                  break;
 332   
 333          case WTAP_ENCAP_ATM_RFC1483:
 334                  /*
 335                   * XXX - is this stuff a pseudo-header?
 336                   * The direction appears to be in the "hdr.dce" field.
 337                   */
 338                  if (!radcom_read_rec_data(wth->fh, phdr, sizeof phdr, err))
 339                          return FALSE;   /* Read error */
 340                  wth->data_offset += 8;
 341                  length -= 8;
 342                  wth->phdr.len -= 8;
 343                  wth->phdr.caplen -= 8;
 344                  break;
 345          }
 346   
 347          /*
 348           * Read the packet data.
 349           */
 350          buffer_assure_space(wth->frame_buffer, length);
 351          if (!radcom_read_rec_data(wth->fh,
 352              buffer_start_ptr(wth->frame_buffer), length, err))
 353                  return FALSE;   /* Read error */
 354          wth->data_offset += length;
 355   
 356          if (wth->file_encap == WTAP_ENCAP_LAPB) {
 357                  /* Read the FCS.
 358                     XXX - should we have some way of indicating the
 359                     presence and size of an FCS to our caller?
 360                     That'd let us handle other file types as well. */
 361                  errno = WTAP_ERR_CANT_READ;
 362                  bytes_read = file_read(&fcs, 1, sizeof fcs, wth->fh);
 363                  if (bytes_read != sizeof fcs) {
 364                          *err = file_error(wth->fh);
 365                          if (*err == 0)
 366                                  *err = WTAP_ERR_SHORT_READ;
 367                          return FALSE;
 368                  }
 369                  wth->data_offset += sizeof fcs;
 370          }
 371   
 372          return TRUE;
 373  }
Show more  




Change Warning 1051.29850 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: