Text   |  XML   |  ReML   |   Visible Warnings:

Unused Value  at k12.c:260

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

get_record

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/k12.c)expand/collapse
Show more  
 212  static gint get_record(guint8** bufferp, FILE* fh, gint64 file_offset) {
 213      static guint8* buffer = NULL;
 214      static guint buffer_len = 0x2000 ;
 215      guint bytes_read;
 216      guint last_read;
 217      guint actual_len, left;
 218      guint8 junk[0x14];
 219      guint8* writep;
 220   
 221      /* where the next unknown 0x10 bytes are stuffed to the file */
 222      guint junky_offset = 0x2000 - (gint) ( (file_offset - 0x200) % 0x2000 );
 223   
 224      K12_DBG(6,("get_record: ENTER: junky_offset=%" G_GINT64_MODIFIER "d, file_offset=%" G_GINT64_MODIFIER "d",junky_offset,file_offset));
 225   
 226      /* no buffer is given, lets create it */
 227      if (buffer == NULL) {
 228          buffer = g_malloc(0x2000);
 229          buffer_len = 0x2000;
 230      }
 231   
 232      *bufferp = buffer;
 233   
 234      if  ( junky_offset == 0x2000 ) {
 235          /* the length of the record is 0x10 bytes ahead from we are reading */
 236          bytes_read = file_read(junk,1,0x14,fh);
 237   
 238          if (bytes_read == 2 && junk[0] == 0xff && junk[1] == 0xff) {
 239              K12_DBG(1,("get_record: EOF"));
 240              return 0;
 241          } else if ( bytes_read < 0x14 ){
 242              K12_DBG(1,("get_record: SHORT READ"));
 243              return -1;
 244          }
 245   
 246          memcpy(buffer,&(junk[0x10]),4);
 247      } else {
 248          /* the length of the record is right where we are reading */
 249          bytes_read = file_read(buffer,1, 0x4, fh);
 250   
 251          if (bytes_read == 2 && buffer[0] == 0xff && buffer[1] == 0xff) {
 252              K12_DBG(1,("get_record: EOF"));
 253              return 0;
 254          } else if ( bytes_read != 0x4 ) {
 255              K12_DBG(1,("get_record: SHORT READ"));
 256              return -1;
 257          }
 258      }
 259   
 260      actual_len = left = pntohl(buffer);
 261      junky_offset -= 0x4;
 262   
 263      K12_DBG(5,("get_record: GET length=%u",left));
 264   
 265      /* XXX - Is WTAP_MAX_PACKET_SIZE */
 266      if (left < 4 || left > WTAP_MAX_PACKET_SIZE) {
 267          K12_DBG(1,("get_record: Invalid GET length=%u",left));
 268          errno = WTAP_ERR_BAD_RECORD;
 269          return -1;
 270      }
 271   
 272      while (left > buffer_len) *bufferp = buffer = g_realloc(buffer,buffer_len*=2);
 273   
 274      writep = buffer + 4;
 275      left -= 4;
 276   
 277      do {
 278          K12_DBG(6,("get_record: looping left=%d junky_offset=%" G_GINT64_MODIFIER "d",left,junky_offset));
 279   
 280          if (junky_offset > left) {
 281              bytes_read += last_read = file_read(writep,1, left, fh);
 282   
 283              if ( last_read != left ) {
 284                  K12_DBG(1,("get_record: SHORT READ"));
 285                  return -1;
 286              } else {
 287                  K12_HEXDMP(5,file_offset, "GOT record", buffer, actual_len);
 288                  return bytes_read;
 289              }
 290          } else {
 291              bytes_read += last_read = file_read(writep,1, junky_offset, fh);
 292   
 293              if ( last_read != junky_offset ) {
 294                  K12_DBG(1,("get_record: SHORT READ, read=%d expected=%d",last_read, junky_offset));
 295                  return -1;
 296              }
 297   
 298              writep += last_read;
 299   
 300              bytes_read += last_read = file_read(junk,1, 0x10, fh);
 301   
 302              if ( last_read != 0x10 ) {
 303                  K12_DBG(1,("get_record: SHORT READ"));
 304                  return -1;
 305              }
 306   
 307              left -= junky_offset;
 308              junky_offset = 0x2000;
 309          }
 310   
 311      } while(left);
 312   
 313      K12_HEXDMP(5,file_offset, "GOT record", buffer, actual_len);
 314      return bytes_read;
 315  }
Show more  




Change Warning 1012.29685 : Unused Value

Priority:
State:
Finding:
Owner:
Note: