Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Control Flow  at ngsniffer.c:2640

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

ng_file_seek_rand

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/ngsniffer.c)expand/collapse
Show more  
 2617  ng_file_seek_rand(wtap *wth, gint64 offset, int whence, int *err)
 2618  {
 2619      ngsniffer_t *ngsniffer;
 2620      gint64 delta;
 2621      GList *new, *next;
 2622      blob_info_t *next_blob, *new_blob;
 2623   
 2624      if (wth->file_type == WTAP_FILE_NGSNIFFER_UNCOMPRESSED)
 2625          return file_seek(wth->random_fh, offset, whence, err);
 2626   
 2627      ngsniffer = wth->capture.ngsniffer;
 2628   
 2629      switch (whence) {
 2630   
 2631      case SEEK_SET:
 2632          break;          /* "offset" is the target offset */
 2633   
 2634      case SEEK_CUR:
 2635          offset += ngsniffer->rand.uncomp_offset;
 2636          break;          /* "offset" is relative to the current offset */
 2637   
 2638      case SEEK_END:
 2639          g_assert_not_reached(); /* "offset" is relative to the end of the file... */
 2640          break;          /* ...but we don't know where that is. */
 2641      }
 2642   
 2643      delta = offset - ngsniffer->rand.uncomp_offset;
 2644   
 2645      /* Is the place to which we're seeking within the current buffer, or 
 2646         will we have to read a different blob into the buffer? */
 2647      new = NULL;
 2648      if (delta > 0) {
 2649          /* We're going forwards.
 2650             Is the place to which we're seeking within the current buffer? */
 2651          if ((size_t)(ngsniffer->rand.nextout + delta) >= ngsniffer->rand.nbytes) {
 2652              /* No.  Search for a blob that contains the target offset in 
 2653                 the uncompressed byte stream, starting with the blob
 2654                 following the current blob. */
 2655              new = g_list_next(ngsniffer->current_blob);
 2656              while (new) {
 2657                  next = g_list_next(new);
 2658                  if (next == NULL) {
 2659                      /* No more blobs; the current one is it. */
 2660                      break;
 2661                  }
 2662   
 2663                  next_blob = next->data;
 2664                  /* Does the next blob start after the target offset?
 2665                     If so, the current blob is the one we want. */
 2666                  if (next_blob->blob_uncomp_offset > offset)
 2667                      break;
 2668   
 2669                  new = next;
 2670              }
 2671          }
 2672      } else if (delta < 0) {
 2673          /* We're going backwards.
 2674             Is the place to which we're seeking within the current buffer? */
 2675          if (ngsniffer->rand.nextout + delta < 0) {
 2676              /* No.  Search for a blob that contains the target offset in 
 2677                 the uncompressed byte stream, starting with the blob
 2678                 preceding the current blob. */
 2679              new = g_list_previous(ngsniffer->current_blob);
 2680              while (new) {
 2681                  /* Does this blob start at or before the target offset?
 2682                     If so, the current blob is the one we want. */
 2683                  new_blob = new->data;
 2684                  if (new_blob->blob_uncomp_offset <= offset)
 2685                      break;
 2686   
 2687                  /* It doesn't - skip to the previous blob. */
 2688                  new = g_list_previous(new);
 2689              }
 2690          }
 2691      }
 2692   
 2693      if (new != NULL) {
 2694          /* The place to which we're seeking isn't in the current buffer;
 2695             move to a new blob. */
 2696          new_blob = new->data;
 2697   
 2698          /* Seek in the compressed file to the offset in the compressed file
 2699             of the beginning of that blob. */
 2700          if (file_seek(wth->random_fh, new_blob->blob_comp_offset, SEEK_SET, err) == -1)
 2701              return -1;
 2702   
 2703          /* Make the blob we found the current one. */
 2704          ngsniffer->current_blob = new;
 2705   
 2706          /* Now set the current offsets to the offsets of the beginning 
 2707             of the blob. */
 2708          ngsniffer->rand.uncomp_offset = new_blob->blob_uncomp_offset;
 2709          ngsniffer->rand.comp_offset = new_blob->blob_comp_offset;
 2710   
 2711          /* Now fill the buffer. */
 2712          if (read_blob(wth->random_fh, &ngsniffer->rand, err) < 0)
 2713              return -1;
 2714   
 2715          /* Set "delta" to the amount to move within this blob; it had
 2716             better be >= 0, and < the amount of uncompressed data in
 2717             the blob, as otherwise it'd mean we need to seek before
 2718             the beginning or after the end of this blob. */
 2719          delta = offset - ngsniffer->rand.uncomp_offset;
 2720          g_assert(delta >= 0 && (unsigned long)delta < ngsniffer->rand.nbytes);
 2721      }
 2722   
 2723      /* OK, the place to which we're seeking is in the buffer; adjust 
 2724         "ngsniffer->rand.nextout" to point to the place to which 
 2725         we're seeking, and adjust "ngsniffer->rand.uncomp_offset" to be
 2726         the destination offset. */
 2727      ngsniffer->rand.nextout += (int) delta;
 2728      ngsniffer->rand.uncomp_offset += delta;
 2729   
 2730      return offset;
 2731  }
Show more  




Change Warning 1038.30027 : Unreachable Control Flow

Priority:
State:
Finding:
Owner:
Note: