(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/pppdump.c) |
| |
| 374 | | | process_data(pppdump_t *state, FILE_T fh, pkt_t *pkt, int n, guint8 *pd, |
| 375 | | | int *err, pkt_id *pid) |
| 376 | | | { |
| 377 | | | int c; |
| 378 | | | int num_bytes = n; |
| 379 | | | int num_written; |
| 380 | | | |
| 381 | | | for (; num_bytes > 0; --num_bytes) { |
| 382 | | | c = file_getc(fh); |
| 383 | | | if (c == EOF) { |
| 384 | | | *err = file_error(fh); |
| 385 | | | if (*err == 0) { |
| 386 | | | *err = WTAP_ERR_SHORT_READ; |
| 387 | | | } |
| 388 | | | return -1; |
| 389 | | | } |
| 390 | | | state->offset++; |
| 391 | | | switch (c) { |
| 392 | | | case 0x7e: |
| 393 | | | |
| 394 | | | |
| 395 | | | |
| 396 | | | |
| 397 | | | |
| 398 | | | |
| 399 | | | |
| 400 | | | |
| 401 | | | |
| 402 | | | |
| 403 | | | |
| 404 | | | |
| 405 | | | |
| 406 | | | |
| 407 | | | |
| 408 | | | |
| 409 | | | if (pkt->cnt > 0) { |
| 410 | | | |
| 411 | | | |
| 412 | | | |
| 413 | | | |
| 414 | | | |
| 415 | | | pkt->esc = FALSE; |
| 416 | | | |
| 417 | | | num_written = pkt->cnt; |
| 418 | | | pkt->cnt = 0; |
| 419 | | | if (num_written <= 0) { |
| 420 | | | return 0; |
Unreachable Data Flow
The highlighted code will not execute under any circumstances. This may be because of: |
|
| 421 | | | } |
| 422 | | | |
| 423 | | | if (num_written > PPPD_BUF_SIZE) { |
| 424 | | | *err = WTAP_ERR_UNC_OVERFLOW; |
| 425 | | | return -1; |
| 426 | | | } |
| 427 | | | |
| 428 | | | memcpy(pd, pkt->buf, num_written); |
| 429 | | | |
| 430 | | | |
| 431 | | | |
| 432 | | | |
| 433 | | | |
| 434 | | | |
| 435 | | | |
| 436 | | | |
| 437 | | | |
| 438 | | | |
| 439 | | | |
| 440 | | | |
| 441 | | | |
| 442 | | | |
| 443 | | | |
| 444 | | | |
| 445 | | | |
| 446 | | | if (pid) { |
| 447 | | | pid->offset = pkt->id_offset; |
| 448 | | | pid->num_bytes_to_skip = |
| 449 | | | pkt->sd_offset - pkt->id_offset - 3; |
| 450 | | | g_assert(pid->num_bytes_to_skip >= 0);
x /usr/include/glib-2.0/glib/gtestutils.h |
| |
74 | #define g_assert(expr) do { if G_LIKELY (expr) ; else \ |
75 | g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ |
76 | #expr); } while (0) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
277 | #define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1)) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
268 | #define _G_BOOLEAN_EXPR(expr) \ |
269 | __extension__ ({ \ |
270 | int _g_boolean_var_; \ |
271 | if (expr) \ |
272 | _g_boolean_var_ = 1; \ |
273 | else \ |
274 | _g_boolean_var_ = 0; \ |
275 | _g_boolean_var_; \ |
276 | }) |
| |
x /usr/include/glib-2.0/glib/gmacros.h |
| |
160 | # define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__)) |
| |
|
| 451 | | | } |
| 452 | | | |
| 453 | | | num_bytes--; |
| 454 | | | if (num_bytes > 0) { |
| 455 | | | |
| 456 | | | |
| 457 | | | |
| 458 | | | |
| 459 | | | |
| 460 | | | |
| 461 | | | pkt->id_offset = pkt->cd_offset; |
| 462 | | | pkt->sd_offset = state->offset; |
| 463 | | | } else { |
| 464 | | | |
| 465 | | | |
| 466 | | | |
| 467 | | | |
| 468 | | | |
| 469 | | | |
| 470 | | | |
| 471 | | | pkt->id_offset = 0; |
| 472 | | | pkt->sd_offset = 0; |
| 473 | | | } |
| 474 | | | state->num_bytes = num_bytes; |
| 475 | | | state->pkt = pkt; |
| 476 | | | return num_written; |
| 477 | | | } |
| 478 | | | break; |
| 479 | | | |
| 480 | | | case 0x7d: |
| 481 | | | |
| 482 | | | |
| 483 | | | |
| 484 | | | |
| 485 | | | if (!pkt->esc) { |
| 486 | | | |
| 487 | | | |
| 488 | | | |
| 489 | | | |
| 490 | | | |
| 491 | | | |
| 492 | | | pkt->esc = TRUE; |
| 493 | | | break; |
| 494 | | | } |
| 495 | | | |
| 496 | | | |
| 497 | | | |
| 498 | | | |
| 499 | | | |
| 500 | | | |
| 501 | | | default: |
| 502 | | | if (pkt->esc) { |
| 503 | | | |
| 504 | | | |
| 505 | | | |
| 506 | | | |
| 507 | | | |
| 508 | | | |
| 509 | | | |
| 510 | | | |
| 511 | | | c ^= 0x20; |
| 512 | | | pkt->esc = FALSE; |
| 513 | | | } |
| 514 | | | |
| 515 | | | pkt->buf[pkt->cnt++] = c; |
| 516 | | | if (pkt->cnt > PPPD_BUF_SIZE) { |
| 517 | | | *err = WTAP_ERR_UNC_OVERFLOW; |
| 518 | | | return -1; |
| 519 | | | } |
| 520 | | | break; |
| 521 | | | } |
| 522 | | | } |
| 523 | | | |
| 524 | | | |
| 525 | | | return 0; |
| 526 | | | } |
| |