(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/radcom.c) |
| |
| 269 | | | static gboolean radcom_read(wtap *wth, int *err, gchar **err_info _U_, |
| 270 | | | gint64 *data_offset) |
| 271 | | | { |
| 272 | | | int ret; |
| 273 | | | struct radcomrec_hdr hdr; |
| 274 | | | guint16 data_length, real_length, length; |
| 275 | | | guint32 sec; |
| 276 | | | int bytes_read; |
| 277 | | | struct tm tm; |
| 278 | | | guchar phdr[8]; |
| 279 | | | char fcs[2]; |
| 280 | | | |
| 281 | | | |
| 282 | | | *data_offset = wth->data_offset; |
| 283 | | | ret = (wth->fh, &hdr, err); |
| 284 | | | if (ret <= 0) { |
| 285 | | | |
| 286 | | | return FALSE; |
| 287 | | | } |
| 288 | | | wth->data_offset += sizeof hdr; |
| 289 | | | data_length = pletohs(&hdr.data_length);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 290 | | | if (data_length == 0) { |
| 291 | | | |
| 292 | | | |
| 293 | | | |
| 294 | | | |
| 295 | | | |
| 296 | | | *err = 0; |
| 297 | | | return FALSE; |
| 298 | | | } |
| 299 | | | length = pletohs(&hdr.length);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 300 | | | real_length = pletohs(&hdr.real_length);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 301 | | | |
| 302 | | | if (wth->file_encap == WTAP_ENCAP_LAPB) { |
| 303 | | | length -= 2; |
| 304 | | | real_length -= 2; |
| 305 | | | } |
| 306 | | | |
| 307 | | | wth->phdr.len = real_length; |
| 308 | | | wth->phdr.caplen = length; |
| 309 | | | |
| 310 | | | tm.tm_year = pletohs(&hdr.date.year)-1900;
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
373 | #define pletohs(p) ((guint16) \ |
374 | ((guint16)*((const guint8 *)(p)+1)<<8| \ |
375 | (guint16)*((const guint8 *)(p)+0)<<0)) |
| |
|
| 311 | | | tm.tm_mon = (hdr.date.month&0x0f)-1; |
| 312 | | | tm.tm_mday = hdr.date.day; |
| 313 | | | sec = pletohl(&hdr.date.sec);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
386 | #define pletohl(p) ((guint32)*((const guint8 *)(p)+3)<<24| \ |
387 | (guint32)*((const guint8 *)(p)+2)<<16| \ |
388 | (guint32)*((const guint8 *)(p)+1)<<8| \ |
389 | (guint32)*((const guint8 *)(p)+0)<<0) |
| |
|
| 314 | | | tm.tm_hour = sec/3600; |
| 315 | | | tm.tm_min = (sec%3600)/60; |
| 316 | | | tm.tm_sec = sec%60; |
| 317 | | | tm.tm_isdst = -1; |
| 318 | | | wth->phdr.ts.secs = mktime(&tm); |
| 319 | | | wth->phdr.ts.nsecs = pletohl(&hdr.date.usec) * 1000;
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/wtap-int.h |
| |
386 | #define pletohl(p) ((guint32)*((const guint8 *)(p)+3)<<24| \ |
387 | (guint32)*((const guint8 *)(p)+2)<<16| \ |
388 | (guint32)*((const guint8 *)(p)+1)<<8| \ |
389 | (guint32)*((const guint8 *)(p)+0)<<0) |
| |
|
| 320 | | | |
| 321 | | | switch (wth->file_encap) { |
| 322 | | | |
| 323 | | | case WTAP_ENCAP_ETHERNET: |
| 324 | | | |
| 325 | | | wth->.eth.fcs_len = -1; |
| 326 | | | break; |
| 327 | | | |
| 328 | | | case WTAP_ENCAP_LAPB: |
| 329 | | | wth->.x25.flags = (hdr.dce & 0x1) ? |
| 330 | | | 0x00 : FROM_DCE; |
| 331 | | | break; |
| 332 | | | |
| 333 | | | case WTAP_ENCAP_ATM_RFC1483: |
| 334 | | | |
| 335 | | | |
| 336 | | | |
| 337 | | | |
| 338 | | | if (!radcom_read_rec_data(wth->fh, phdr, sizeof phdr, err)) |
| 339 | | | return FALSE; |
| 340 | | | wth->data_offset += 8; |
| 341 | | | length -= 8; |
| 342 | | | wth->phdr.len -= 8; |
| 343 | | | wth->phdr.caplen -= 8; |
| 344 | | | break; |
| 345 | | | } |
| 346 | | | |
| 347 | | | |
| 348 | | | |
| 349 | | | |
| 350 | | | buffer_assure_space(wth->frame_buffer, length); |
| 351 | | | if (!radcom_read_rec_data(wth->fh, |
| 352 | | | buffer_start_ptr(wth->frame_buffer), length, err))
x /home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/buffer.h |
| |
46 | # define buffer_start_ptr(buffer) ((buffer)->data + (buffer)->start) |
| |
|
| 353 | | | return FALSE; |
| 354 | | | wth->data_offset += length; |
| 355 | | | |
| 356 | | | if (wth->file_encap == WTAP_ENCAP_LAPB) { |
| 357 | | | |
| 358 | | | |
| 359 | | | |
| 360 | | | |
| 361 | | | errno = WTAP_ERR_CANT_READ; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 362 | | | bytes_read = file_read(&fcs, 1, sizeof fcs, wth->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))) |
| |
|
| 363 | | | if (bytes_read != sizeof fcs) { |
| 364 | | | *err = file_error(wth->fh); |
| 365 | | | if (*err == 0) |
| 366 | | | *err = WTAP_ERR_SHORT_READ; |
| 367 | | | return FALSE; |
| 368 | | | } |
| 369 | | | wth->data_offset += sizeof fcs; |
| 370 | | | } |
| 371 | | | |
| 372 | | | return TRUE; |
| 373 | | | } |
| |