(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/k12.c) |
| |
| 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 | | | |
| 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 | | | |
| 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 | | | |
| 236 | | | bytes_read = file_read(junk,1,0x14,fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 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 | | | |
| 249 | | | bytes_read = file_read(buffer,1, 0x4, fh);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 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);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
354 | #define pntohl(p) ((guint32)*((const guint8 *)(p)+0)<<24| \ |
355 | (guint32)*((const guint8 *)(p)+1)<<16| \ |
356 | (guint32)*((const guint8 *)(p)+2)<<8| \ |
357 | (guint32)*((const guint8 *)(p)+3)<<0) |
| |
|
Unused Value
The value assigned to actual_len is never subsequently used on any execution path. |
|
| 261 | | | junky_offset -= 0x4; |
| 262 | | | |
| 263 | | | K12_DBG(5,("get_record: GET length=%u",left)); |
| 264 | | | |
| 265 | | | |
| 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);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 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);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 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);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/file_wrappers.h |
| |
36 | #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize))) |
| |
|
| 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 | | | } |
| |