Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at lanalyzer.c:326

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

lanalyzer_read

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/lanalyzer.c)expand/collapse
Show more  
 276  static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
 277      gint64 *data_offset)
 278  {
 279          int             packet_size = 0;
 280          int             bytes_read;
 281          char            LE_record_type[2];
 282          char            LE_record_length[2];
 283          guint16         record_type, record_length;
 284          gchar           descriptor[DESCRIPTOR_LEN];
 285          guint16         time_low, time_med, time_high, true_size;
 286          guint64         t;
 287          time_t          tsecs;
 288   
 289          /* read the record type and length. */
 290          errno = WTAP_ERR_CANT_READ;
 291          bytes_read = file_read(LE_record_type, 1, 2, wth->fh);
 292          if (bytes_read != 2) {
 293                  *err = file_error(wth->fh);
 294                  if (*err == 0 && bytes_read != 0) {
 295                          *err = WTAP_ERR_SHORT_READ;
 296                  }
 297                  return FALSE;
 298          }
 299          wth->data_offset += 2;
 300          bytes_read = file_read(LE_record_length, 1, 2, wth->fh);
 301          if (bytes_read != 2) {
 302                  *err = file_error(wth->fh);
 303                  if (*err == 0)
 304                          *err = WTAP_ERR_SHORT_READ;
 305                  return FALSE;
 306          }
 307          wth->data_offset += 2;
 308   
 309          record_type = pletohs(LE_record_type);
 310          record_length = pletohs(LE_record_length);
 311   
 312          /* Only Trace Packet Data Records should occur now that we're in 
 313           * the middle of reading packets.  If any other record type exists 
 314           * after a Trace Packet Data Record, mark it as an error. */
 315          if (record_type != RT_PacketData) {
 316                  *err = WTAP_ERR_BAD_RECORD;
 317                  *err_info = g_strdup_printf("lanalyzer: record type %u seen after trace summary record",
 318                      record_type);
 319                  return FALSE;
 320          }
 321          else {
 322                  packet_size = record_length - DESCRIPTOR_LEN;
 323          }
 324   
 325          /* Read the descriptor data */
 326          errno = WTAP_ERR_CANT_READ;
 327          bytes_read = file_read(descriptor, 1, DESCRIPTOR_LEN, wth->fh);
 328          if (bytes_read != DESCRIPTOR_LEN) {
 329                  *err = file_error(wth->fh);
 330                  if (*err == 0)
 331                          *err = WTAP_ERR_SHORT_READ;
 332                  return FALSE;
 333          }
 334          wth->data_offset += DESCRIPTOR_LEN;
 335   
 336          /* Read the packet data */
 337          buffer_assure_space(wth->frame_buffer, packet_size);
 338          *data_offset = wth->data_offset;
 339          errno = WTAP_ERR_CANT_READ;
 340          bytes_read = file_read(buffer_start_ptr(wth->frame_buffer), 1,
 341                  packet_size, wth->fh);
 342   
 343          if (bytes_read != packet_size) {
 344                  *err = file_error(wth->fh);
 345                  if (*err == 0)
 346                          *err = WTAP_ERR_SHORT_READ;
 347                  return FALSE;
 348          }
 349          wth->data_offset += packet_size;
 350   
 351          true_size = pletohs(&descriptor[4]);
 352          packet_size = pletohs(&descriptor[6]);
 353   
 354          /*
 355           * OK, is the frame data size greater than than what's left of the 
 356           * record?
 357           */
 358          if (packet_size > record_length - DESCRIPTOR_LEN) {
 359                  /*
 360                   * Yes - treat this as an error.
 361                   */
 362                  *err = WTAP_ERR_BAD_RECORD;
 363                  *err_info = g_strdup("lanalyzer: Record length is less than packet size");
 364                  return FALSE;
 365          }
 366   
 367          time_low = pletohs(&descriptor[8]);
 368          time_med = pletohs(&descriptor[10]);
 369          time_high = pletohs(&descriptor[12]);
 370          t = (((guint64)time_low) << 0) + (((guint64)time_med) << 16) +
 371              (((guint64)time_high) << 32);
 372          tsecs = (time_t) (t/2000000);
 373          wth->phdr.ts.secs = tsecs + wth->capture.lanalyzer->start;
 374          wth->phdr.ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500;
 375   
 376          if (true_size - 4 >= packet_size) {
 377                  /*
 378                   * It appears that the "true size" includes the FCS;
 379                   * make it reflect the non-FCS size (the "packet size"
 380                   * appears never to include the FCS, even if no slicing
 381                   * is done).
 382                   */
 383                  true_size -= 4;
 384          }
 385          wth->phdr.len = true_size;
 386          wth->phdr.caplen = packet_size;
 387   
 388          switch (wth->file_encap) {
 389   
 390          case WTAP_ENCAP_ETHERNET:
 391                  /* We assume there's no FCS in this frame. */
 392                  wth->pseudo_header.eth.fcs_len = 0;
 393                  break;
 394          }
 395   
 396          return TRUE;
 397  }
Show more  




Change Warning 1014.29838 : Useless Assignment

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

Priority:
State:
Finding:
Owner:
Note: