Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at radcom.c:133

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

radcom_open

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/radcom.c)expand/collapse
Show more  
 102  int radcom_open(wtap *wth, int *err, gchar **err_info)
 103  {
 104          int bytes_read;
 105          guint8 r_magic[8], t_magic[11], search_encap[7];
 106          struct frame_date start_date;
 107          guint32 sec;
 108          struct tm tm;
 109   
 110          /* Read in the string that should be at the start of a RADCOM file */
 111          errno = WTAP_ERR_CANT_READ;
 112          bytes_read = file_read(r_magic, 1, 8, wth->fh);
 113          if (bytes_read != 8) {
 114                  *err = file_error(wth->fh);
 115                  if (*err != 0)
 116                          return -1;
 117                  return 0;
 118          }
 119   
 120          /* XXX: bytes 2 and 3 of the "magic" header seem to be different in some 
 121           * captures. We force them to our standard value so that the test 
 122           * succeeds (until we find if they have a special meaning, perhaps a
 123           * version number ?) */
 124          r_magic[1] = 0xD2;
 125          r_magic[2] = 0x00;
 126          if (memcmp(r_magic, radcom_magic, 8) != 0) {
 127                  return 0;
 128          }
 129   
 130          /* Look for the "Active Time" string. The "frame_date" structure should
 131           * be located 32 bytes before the beginning of this string */
 132          wth->data_offset = 8;
 133          errno = WTAP_ERR_CANT_READ;
 134          bytes_read = file_read(t_magic, 1, 11, wth->fh);
 135          if (bytes_read != 11) {
 136                  *err = file_error(wth->fh);
 137                  if (*err != 0)
 138                          return -1;
 139                  return 0;
 140          }
 141          while (memcmp(t_magic, active_time_magic, 11) != 0)
 142          {
 143              if (file_seek(wth->fh, -10, SEEK_CUR, err) == -1)
 144                  return -1;
 145              wth->data_offset += 1;
 146              errno = WTAP_ERR_CANT_READ;
 147              bytes_read = file_read(t_magic, 1, 11, wth->fh);
 148              if (bytes_read != 11) {
 149                  *err = file_error(wth->fh);
 150                  if (*err != 0)
 151                      return -1;
 152                  return 0;
 153              }
 154          }
 155          if (file_seek(wth->fh, -43, SEEK_CUR, err) == -1) return -1;
 156          wth->data_offset -= 32;
 157   
 158          /* Get capture start time */
 159          errno = WTAP_ERR_CANT_READ;
 160          bytes_read = file_read(&start_date, 1, sizeof(struct frame_date),
 161                                 wth->fh);
 162          if (bytes_read != sizeof(struct frame_date)) {
 163                  *err = file_error(wth->fh);
 164                  if (*err != 0)
 165                          return -1;
 166                  return 0;
 167          }
 168          wth->data_offset += sizeof(struct frame_date);
 169   
 170          /* This is a radcom file */
 171          wth->file_type = WTAP_FILE_RADCOM;
 172          wth->subtype_read = radcom_read;
 173          wth->subtype_seek_read = radcom_seek_read;
 174          wth->snapshot_length = 0; /* not available in header, only in frame */
 175          wth->tsprecision = WTAP_FILE_TSPREC_USEC;
 176   
 177          tm.tm_year = pletohs(&start_date.year)-1900;
 178          tm.tm_mon = start_date.month-1;
 179          tm.tm_mday = start_date.day;
 180          sec = pletohl(&start_date.sec);
 181          tm.tm_hour = sec/3600;
 182          tm.tm_min = (sec%3600)/60;
 183          tm.tm_sec = sec%60;
 184          tm.tm_isdst = -1;
 185   
 186          if (file_seek(wth->fh, sizeof(struct frame_date), SEEK_CUR, err) == -1)
 187                  return -1;
 188          wth->data_offset += sizeof(struct frame_date);
 189   
 190          errno = WTAP_ERR_CANT_READ;
 191          bytes_read = file_read(search_encap, 1, 4, wth->fh);
 192          if (bytes_read != 4) {
 193                  goto read_error;
 194          }
 195          wth->data_offset += 4;
 196          while (memcmp(encap_magic, search_encap, 4)) {
 197                  if (file_seek(wth->fh, -3, SEEK_CUR, err) == -1)
 198                          return -1;
 199                  wth->data_offset -= 3;
 200                  errno = WTAP_ERR_CANT_READ;
 201                  bytes_read = file_read(search_encap, 1, 4, wth->fh);
 202                  if (bytes_read != 4) {
 203                          goto read_error;
 204                  }
 205                  wth->data_offset += 4;
 206          }
 207          if (file_seek(wth->fh, 12, SEEK_CUR, err) == -1)
 208                  return -1;
 209          wth->data_offset += 12;
 210          errno = WTAP_ERR_CANT_READ;
 211          bytes_read = file_read(search_encap, 1, 4, wth->fh);
 212          if (bytes_read != 4) {
 213                  goto read_error;
 214          }
 215          wth->data_offset += 4;
 216          if (memcmp(search_encap, "LAPB", 4) == 0)
 217                  wth->file_encap = WTAP_ENCAP_LAPB;
 218          else if (memcmp(search_encap, "Ethe", 4) == 0)
 219                  wth->file_encap = WTAP_ENCAP_ETHERNET;
 220          else if (memcmp(search_encap, "ATM/", 4) == 0)
 221                  wth->file_encap = WTAP_ENCAP_ATM_RFC1483;
 222          else {
 223                  *err = WTAP_ERR_UNSUPPORTED_ENCAP;
 224                  *err_info = g_strdup_printf("radcom: network type \"%.4s\" unknown", search_encap);
 225                  return -1;
 226          }
 227   
 228          /*bytes_read = file_read(&next_date, 1, sizeof(struct frame_date), wth->fh);
 229          errno = WTAP_ERR_CANT_READ;
 230          if (bytes_read != sizeof(struct frame_date)) {
 231                  goto read_error;
 232          }
 233   
 234          while (memcmp(&start_date, &next_date, 4)) {
 235                  if (file_seek(wth->fh, 1-sizeof(struct frame_date), SEEK_CUR, err) == -1)
 236                          return -1;
 237                  errno = WTAP_ERR_CANT_READ;
 238                  bytes_read = file_read(&next_date, 1, sizeof(struct frame_date),
 239                                     wth->fh);
 240                  if (bytes_read != sizeof(struct frame_date)) {
 241                          goto read_error;
 242                  }
 243          }*/
 244   
 245          if (wth->file_encap == WTAP_ENCAP_ETHERNET) {
 246                  if (file_seek(wth->fh, 294, SEEK_CUR, err) == -1)
 247                          return -1;
 248                  wth->data_offset += 294;
 249          } else if (wth->file_encap == WTAP_ENCAP_LAPB) {
 250                  if (file_seek(wth->fh, 297, SEEK_CUR, err) == -1)
 251                          return -1;
 252                  wth->data_offset += 297;
 253          } else if (wth->file_encap == WTAP_ENCAP_ATM_RFC1483) {
 254                  if (file_seek(wth->fh, 504, SEEK_CUR, err) == -1)
 255                          return -1;
 256                  wth->data_offset += 504;
 257          }
 258   
 259          return 1;
 260   
 261  read_error:
 262          *err = file_error(wth->fh);
 263          if (*err != 0)
 264                  return -1;
 265          return 0;
 266  }
Show more  




Change Warning 1050.29846 : Useless Assignment

Because they are very similar, this warning shares annotations with warnings 1050.29847, 1050.29848, and 1050.29849.

Priority:
State:
Finding:
Owner:
Note: