Text   |  XML   |  ReML   |   Visible Warnings:

Redundant Condition  at ascend.c:147

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

ascend_seek

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/ascend.c)expand/collapse
Show more  
 91  static gint64 ascend_seek(wtap *wth, int *err)
 92  {
 93    int byte;
 94    gint64 date_off = -1, cur_off, packet_off;
 95    size_t string_level[ASCEND_MAGIC_STRINGS];
 96    guint string_i = 0, type = 0;
 97    guint excessive_read_count = 262144;
 98   
 99    memset(&string_level, 0, sizeof(string_level));
 100   
 101    while (((byte = file_getc(wth->fh)) != EOF)) {
 102      excessive_read_count--;
 103   
 104      if (!excessive_read_count) {
 105        return -1;
 106      }
 107   
 108      for (string_i = 0; string_i < ASCEND_MAGIC_STRINGS; string_i++) {
 109        const gchar *strptr = ascend_magic[string_i].strptr;
 110        size_t len          = strlen(strptr);
 111   
 112        if (byte == *(strptr + string_level[string_i])) {
 113          string_level[string_i]++;
 114          if (string_level[string_i] >= len) {
 115            cur_off = file_tell(wth->fh);
 116            if (cur_off == -1) {
 117              /* Error. */
 118              *err = file_error(wth->fh);
 119              return -1;
 120            }
 121   
 122            /* Date: header is a special case. Remember the offset,
 123               but keep looking for other headers. */
 124            if (strcmp(strptr, ASCEND_DATE) == 0) {
 125              date_off = cur_off - len;
 126            } else {
 127              if (date_off == -1) {
 128                /* Back up over the header we just read; that's where a read 
 129                   of this packet should start. */
 130                packet_off = cur_off - len;
 131              } else {
 132                /* This packet has a date/time header; a read of it should 
 133                   start at the beginning of *that* header. */
 134                packet_off = date_off;
 135              }
 136   
 137              type = ascend_magic[string_i].type;
 138              goto found;
 139            }
 140          }
 141        } else {
 142          string_level[string_i] = 0;
 143        }
 144      }
 145    }
 146   
 147    if (byte != EOF || file_eof(wth->fh)) {
 148      /* Either we didn't find the offset, or we got an EOF. */
 149      *err = 0;
 150    } else {
 151      /* We (presumably) got an error (there's no equivalent to "ferror()"
 152         in zlib, alas, so we don't have a wrapper to check for an error). */
 153      *err = file_error(wth->fh);
 154    }
 155    return -1;
 156   
 157  found:
 158    /*
 159     * Move to where the read for this packet should start, and return
 160     * that seek offset.
 161     */
 162    if (file_seek(wth->fh, packet_off, SEEK_SET, err) == -1)
 163      return -1;
 164   
 165    wth->pseudo_header.ascend.type = type;
 166   
 167    return packet_off;
 168  }
Show more  




Change Warning 953.29803 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: