(/home/sate/Testcases/c/cve/wireshark-1.2.0/color_filters.c) |
| |
| 465 | | | read_filters_file(FILE *f, gpointer user_data) |
| 466 | | | { |
| 467 | | | #define INIT_BUF_SIZE 128 |
| 468 | | | gchar *name = NULL; |
| 469 | | | gchar *filter_exp = NULL; |
| 470 | | | guint32 name_len = INIT_BUF_SIZE; |
| 471 | | | guint32 filter_exp_len = INIT_BUF_SIZE; |
| 472 | | | guint32 i = 0; |
| 473 | | | gint32 c; |
| 474 | | | guint16 fg_r, fg_g, fg_b, bg_r, bg_g, bg_b; |
| 475 | | | gboolean disabled = FALSE; |
| 476 | | | gboolean skip_end_of_line = FALSE; |
| 477 | | | |
| 478 | | | name = g_malloc(name_len + 1); |
| 479 | | | filter_exp = g_malloc(filter_exp_len + 1); |
| 480 | | | |
| 481 | | | while (1) { |
Event 3:
Entering loop body. 1 evaluates to true.
hide
|
|
| 482 | | | |
| 483 | | | if (skip_end_of_line) { |
Event 4:
Skipping " if". skip_end_of_line evaluates to false.
hide
|
|
| 484 | | | do { |
| 485 | | | c = getc(f); |
| 486 | | | } while (c != EOF && c != '\n'); |
| 487 | | | if (c == EOF) |
| 488 | | | break; |
| 489 | | | disabled = FALSE; |
| 490 | | | skip_end_of_line = FALSE; |
| 491 | | | } |
| 492 | | | |
| 493 | | | while ((c = getc(f)) != EOF && isspace(c)) { |
| 494 | | | if (c == '\n') { |
| 495 | | | continue; |
| 496 | | | } |
| 497 | | | } |
| 498 | | | |
| 499 | | | if (c == EOF) |
Event 6:
Skipping " if". c == -1 evaluates to false.
hide
|
|
| 500 | | | break; |
| 501 | | | |
| 502 | | | if (c == '!') { |
Event 7:
Skipping " if". c == 33 evaluates to false.
hide
|
|
| 503 | | | disabled = TRUE; |
| 504 | | | continue; |
| 505 | | | } |
| 506 | | | |
| 507 | | | |
| 508 | | | if (c != '@') { |
Event 8:
Skipping " if". c != 64 evaluates to false.
hide
|
|
| 509 | | | skip_end_of_line = TRUE; |
| 510 | | | continue; |
| 511 | | | } |
| 512 | | | |
| 513 | | | |
| 514 | | | |
| 515 | | | |
| 516 | | | |
| 517 | | | |
| 518 | | | |
| 519 | | | i = 0; |
| 520 | | | while (1) { |
Event 10:
During loop iterations, name is set to an unknown [ ?unknown: the analysis lost precision when tracking this value, so this warning may be a false positive] value . - This points to the buffer that will be overrun later.
hide
Event 11:
During loop iterations, i is set to i + 1, which evaluates to a potentially dangerous value [ ?potentially dangerous: the value cannot be determined and may come from program input]. - This determines the position accessed in the buffer during the buffer overrun later.
hide
|
|
| 521 | | | c = getc(f); |
| 522 | | | if (c == EOF || c == '@') |
| 523 | | | break; |
| 524 | | | if (i >= name_len) { |
| 525 | | | |
| 526 | | | name_len *= 2; |
| 527 | | | name = g_realloc(name, name_len + 1); |
| 528 | | | } |
| 529 | | | name[i++] = c; |
| 530 | | | } |
| 531 | | | name[i] = '\0'; |
Buffer Overrun
This code could write past the end of the buffer pointed to by name. - name evaluates to the value assigned to name at color_filters.c:520.
- The code writes 1 byte starting at offset i from the beginning of the buffer pointed to by name.
- The number of bytes written could exceed the number of allocated bytes beyond that offset.
- i evaluates to the value assigned to i at color_filters.c:520, plus 1, which is bounded below by 1. See related event 11.
- The capacity of the buffer pointed to by name, in bytes, is the value assigned to the capacity of the buffer pointed to by name at color_filters.c:520. See related event 10.
- If i plus 1 is higher than the value assigned to the capacity of the buffer pointed to by name at color_filters.c:520, an overrun will occur. The analysis cannot rule out this possibility, so has issued this warning.
The issue can occur if the highlighted code executes. See related events 10 and 11. Show: All events | Only primary events |
|
| |