(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/login-common/main.c) |
| |
| 397 | | | int main(int argc ATTR_UNUSED, char *argv[], char *envp[]) |
| 398 | | | { |
| 399 | | | const char *group_name; |
| 400 | | | struct ip_addr remote_ip, local_ip; |
| 401 | | | unsigned int remote_port, local_port, max_fds; |
| 402 | | | struct ssl_proxy *proxy = NULL; |
| 403 | | | struct client *client; |
| 404 | | | int i, fd = -1, master_fd = -1; |
| 405 | | | bool ssl = FALSE; |
| 406 | | | |
| 407 | | | is_inetd = getenv("DOVECOT_MASTER") == NULL; |
Event 1:
getenv(...) == (void *)0 evaluates to true.
hide
|
|
| 408 | | | |
| 409 | | | #ifdef DEBUG |
| 410 | | | if (!is_inetd && getenv("GDB") == NULL) { |
| 411 | | | const char *env; |
| 412 | | | |
| 413 | | | i = LOGIN_MASTER_SOCKET_FD + 1; |
| 414 | | | env = getenv("LISTEN_FDS"); |
| 415 | | | if (env != NULL) i += atoi(env); |
| 416 | | | env = getenv("SSL_LISTEN_FDS"); |
| 417 | | | if (env != NULL) i += atoi(env); |
| 418 | | | |
| 419 | | | fd_debug_verify_leaks(i, 1024); |
| 420 | | | } |
| 421 | | | #endif |
| 422 | | | |
| 423 | | | |
| 424 | | | lib_init(); |
| 425 | | | |
| 426 | | | if (is_inetd) { |
Event 2:
Taking true branch. is_inetd evaluates to true.
hide
|
|
| 427 | | | |
| 428 | | | |
| 429 | | | process_name = strrchr(argv[0], '/'); |
| 430 | | | process_name = process_name == NULL ? argv[0] : process_name+1; |
Event 3:
process_name == (void *)0 evaluates to true.
hide
|
|
| 431 | | | group_name = t_strcut(process_name, '-'); |
| 432 | | | |
| 433 | | | for (i = 1; i < argc; i++) { |
Event 4:
Leaving loop. i < argc evaluates to false.
hide
|
|
| 434 | | | if (strncmp(argv[i], "--group=", 8) == 0) { |
| 435 | | | group_name = argv[1]+8; |
| 436 | | | break; |
| 437 | | | } |
| 438 | | | } |
| 439 | | | |
| 440 | | | master_fd = master_connect(group_name); |
| 441 | | | } |
| 442 | | | |
| 443 | | | drop_privileges(&max_fds); |
| 444 | | | |
| 445 | | | if (argv[1] != NULL && strcmp(argv[1], "-D") == 0) |
Event 5:
Skipping " if". - argv[1] != (void *)0 evaluates to true.
- strcmp(argv[1], "-D") == 0 evaluates to false.
hide
|
|
| 446 | | | restrict_access_allow_coredumps(TRUE); |
| 447 | | | |
| 448 | | | process_title_init(argv, envp); |
| 449 | | | ioloop = io_loop_create(); |
| 450 | | | io_loop_set_max_fd_count(ioloop, max_fds); |
| 451 | | | main_init(); |
| 452 | | | |
| 453 | | | if (is_inetd) { |
Event 6:
Taking true branch. is_inetd evaluates to true.
hide
|
|
| 454 | [+] | | if (net_getpeername(1, &remote_ip, &remote_port) < 0) { |
 |
| 455 | | | i_fatal("%s can be started only through dovecot " |
| 456 | | | "master process, inetd or equivalent", argv[0]); |
| 457 | | | } |
| 458 | [+] | | if (net_getsockname(1, &local_ip, &local_port) < 0) { |
 |
| 459 | | | memset(&local_ip, 0, sizeof(local_ip)); |
| 460 | | | local_port = 0; |
| 461 | | | } |
| 462 | | | |
| 463 | | | fd = 1; |
| 464 | | | for (i = 1; i < argc; i++) { |
Event 25:
Leaving loop. i < argc evaluates to false.
hide
|
|
| 465 | | | if (strcmp(argv[i], "--ssl") == 0) |
| 466 | | | ssl = TRUE; |
| 467 | | | else if (strncmp(argv[i], "--group=", 8) != 0) |
| 468 | | | i_fatal("Unknown parameter: %s", argv[i]); |
| 469 | | | } |
| 470 | | | |
| 471 | | | |
| 472 | | | if (local_port == 993 || local_port == 995 || ssl) { |
Event 26:
Skipping " if". - local_port == 993 evaluates to false.
- local_port == 995 evaluates to false.
- ssl evaluates to false.
hide
|
|
| 473 | | | ssl = TRUE; |
| 474 | | | fd = ssl_proxy_new(fd, &remote_ip, &proxy); |
| 475 | | | if (fd == -1) |
| 476 | | | return 1; |
| 477 | | | } |
| 478 | | | |
| 479 | | | master_init(master_fd); |
| 480 | | | closing_down = TRUE; |
Event 27:
!0 evaluates to true.
hide
|
|
| 481 | | | |
| 482 | | | if (fd != -1) { |
Event 28:
Taking true branch. fd != -1 evaluates to true.
hide
|
|
| 483 | [+] | | client = client_create(fd, ssl, &local_ip, &remote_ip); |
 |
| 484 | | | client->proxy = proxy; |
Null Pointer Dereference
client is dereferenced here, but it is NULL. The issue can occur if the highlighted code executes. See related event 37. Show: All events | Only primary events |
|
| |