(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/deliver/deliver.c) |
| |
| 885 | | | int main(int argc, char *argv[]) |
| 886 | | | { |
| 887 | | | const char *config_path = DEFAULT_CONFIG_FILE; |
| 888 | | | const char *mailbox = "INBOX"; |
| 889 | | | const char *auth_socket; |
| 890 | | | const char *home, *destaddr, *user, *value, *errstr, *path, *orig_user; |
| 891 | | | ARRAY_TYPE(const_string) = ARRAY_INIT; |
| 892 | | | struct mail_user *mail_user, *raw_mail_user; |
| 893 | | | struct mail_namespace *raw_ns; |
| 894 | | | struct mail_storage *storage; |
| 895 | | | struct mailbox *box; |
| 896 | | | struct raw_mailbox *raw_box; |
| 897 | | | struct istream *input; |
| 898 | | | struct mailbox_transaction_context *t; |
| 899 | | | struct *; |
| 900 | | | struct mail *mail; |
| 901 | | | char cwd[PATH_MAX];
x /usr/include/linux/limits.h |
| |
12 | #define PATH_MAX 4096 /* # chars in a path name including nul */ |
| |
|
| 902 | | | uid_t process_euid; |
| 903 | | | bool stderr_rejection = FALSE; |
| 904 | | | bool keep_environment = FALSE; |
| 905 | | | bool user_auth = FALSE; |
| 906 | | | time_t mtime; |
| 907 | | | int i, ret; |
| 908 | | | pool_t userdb_pool = NULL; |
| 909 | | | string_t *str; |
| 910 | | | enum mail_error error; |
| 911 | | | |
| 912 | | | if (getuid() != geteuid() && geteuid() == 0) { |
Event 1:
Skipping " if". getuid() != geteuid() evaluates to false.
hide
|
|
| 913 | | | |
| 914 | | | |
| 915 | | | struct stat st; |
| 916 | | | |
| 917 | | | if (stat(argv[0], &st) < 0) { |
| 918 | | | fprintf(stderr, "stat(%s) failed: %s\n", |
| 919 | | | argv[0], strerror(errno)); |
| 920 | | | return EX_CONFIG;
x /usr/include/sysexits.h |
| |
110 | #define EX_CONFIG 78 /* configuration error */ |
| |
|
| 921 | | | } else if ((st.st_mode & 1) != 0) { |
| 922 | | | fprintf(stderr, "%s must not be both world-executable " |
| 923 | | | "and setuid-root. This allows root exploits. " |
| 924 | | | "See http://wiki.dovecot.org/LDA#multipleuids\n", |
| 925 | | | argv[0]); |
| 926 | | | return EX_CONFIG;
x /usr/include/sysexits.h |
| |
110 | #define EX_CONFIG 78 /* configuration error */ |
| |
|
| 927 | | | } |
| 928 | | | } |
| 929 | | | |
| 930 | | | i_set_failure_exit_callback(failure_exit_callback); |
| 931 | | | |
| 932 | | | lib_init(); |
| 933 | | | ioloop = io_loop_create(); |
| 934 | | | |
| 935 | | | lib_signals_init(); |
| 936 | | | lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL);
x /usr/include/bits/signum.h |
| |
34 | #define SIGINT 2 /* Interrupt (ANSI). */ |
| |
|
Event 2:
!0 evaluates to true.
hide
|
|
| 937 | | | lib_signals_set_handler(SIGTERM, TRUE, sig_die, NULL);
x /usr/include/bits/signum.h |
| |
48 | #define SIGTERM 15 /* Termination (ANSI). */ |
| |
|
Event 3:
!0 evaluates to true.
hide
|
|
| 938 | | | lib_signals_ignore(SIGPIPE, TRUE);
x /usr/include/bits/signum.h |
| |
46 | #define SIGPIPE 13 /* Broken pipe (POSIX). */ |
| |
|
Event 4:
!0 evaluates to true.
hide
|
|
| 939 | | | lib_signals_ignore(SIGALRM, FALSE);
x /usr/include/bits/signum.h |
| |
47 | #define SIGALRM 14 /* Alarm clock (POSIX). */ |
| |
|
| 940 | | | #ifdef SIGXFSZ
x /usr/include/bits/signum.h |
| |
59 | #define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */ |
| |
|
| 941 | | | lib_signals_ignore(SIGXFSZ, TRUE);
x /usr/include/bits/signum.h |
| |
59 | #define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */ |
| |
|
Event 5:
!0 evaluates to true.
hide
|
|
| 942 | | | #endif |
| 943 | | | |
| 944 | | | deliver_set = i_new(struct deliver_settings, 1);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/imem.h |
| |
8 | #define i_new(type, count) ((type *) i_malloc(sizeof(type) * (count))) |
| |
|
| 945 | | | deliver_set->mailbox_autocreate = TRUE; |
Event 6:
!0 evaluates to true.
hide
|
|
| 946 | | | |
| 947 | | | destaddr = user = path = NULL; |
| 948 | | | for (i = 1; i < argc; i++) { |
Event 7:
Entering loop body. i < argc evaluates to true.
hide
Event 15:
Continuing from loop body. Leaving loop. i < argc evaluates to false.
hide
|
|
| 949 | | | if (strcmp(argv[i], "-a") == 0) { |
Event 8:
Taking false branch. strcmp(argv[i], "-a") == 0 evaluates to false.
hide
|
|
| 950 | | | |
| 951 | | | i++; |
| 952 | | | if (i == argc) |
| 953 | | | i_fatal_status(EX_USAGE, "Missing -a argument");
x /usr/include/sysexits.h |
| |
96 | #define EX_USAGE 64 /* command line usage error */ |
| |
|
| 954 | | | destaddr = argv[i]; |
| 955 | | | } else if (strcmp(argv[i], "-d") == 0) { |
Event 9:
Taking false branch. strcmp(argv[i], "-d") == 0 evaluates to false.
hide
|
|
| 956 | | | |
| 957 | | | i++; |
| 958 | | | if (i == argc) |
| 959 | | | i_fatal_status(EX_USAGE, "Missing -d argument");
x /usr/include/sysexits.h |
| |
96 | #define EX_USAGE 64 /* command line usage error */ |
| |
|
| 960 | | | user = argv[i]; |
| 961 | | | user_auth = TRUE; |
| 962 | | | } else if (strcmp(argv[i], "-p") == 0) { |
Event 10:
Taking false branch. strcmp(argv[i], "-p") == 0 evaluates to false.
hide
|
|
| 963 | | | |
| 964 | | | i++; |
| 965 | | | if (i == argc) |
| 966 | | | i_fatal_status(EX_USAGE, "Missing -p argument");
x /usr/include/sysexits.h |
| |
96 | #define EX_USAGE 64 /* command line usage error */ |
| |
|
| 967 | | | path = argv[i]; |
| 968 | | | if (*path != '/') { |
| 969 | | | |
| 970 | | | if (getcwd(cwd, sizeof(cwd)) == NULL) |
| 971 | | | i_fatal("getcwd() failed: %m"); |
| 972 | | | path = t_strconcat(cwd, "/", path, NULL); |
| 973 | | | } |
| 974 | | | } else if (strcmp(argv[i], "-e") == 0) { |
Event 11:
Taking false branch. strcmp(argv[i], "-e") == 0 evaluates to false.
hide
|
|
| 975 | | | stderr_rejection = TRUE; |
| 976 | | | } else if (strcmp(argv[i], "-c") == 0) { |
Event 12:
Taking false branch. strcmp(argv[i], "-c") == 0 evaluates to false.
hide
|
|
| 977 | | | |
| 978 | | | i++; |
| 979 | | | if (i == argc) { |
| 980 | | | i_fatal_status(EX_USAGE,
x /usr/include/sysexits.h |
| |
96 | #define EX_USAGE 64 /* command line usage error */ |
| |
|
| 981 | | | "Missing config file path argument"); |
| 982 | | | } |
| 983 | | | config_path = argv[i]; |
| 984 | | | } else if (strcmp(argv[i], "-k") == 0) { |
Event 13:
Taking true branch. strcmp(argv[i], "-k") == 0 evaluates to true.
hide
|
|
| 985 | | | keep_environment = TRUE; |
Event 14:
!0 evaluates to true.
hide
|
|
| 986 | | | } else if (strcmp(argv[i], "-m") == 0) { |
| 987 | | | |
| 988 | | | i++; |
| 989 | | | if (i == argc) |
| 990 | | | i_fatal_status(EX_USAGE, "Missing -m argument");
x /usr/include/sysexits.h |
| |
96 | #define EX_USAGE 64 /* command line usage error */ |
| |
|
| 991 | | | |
| 992 | | | |
| 993 | | | if (*argv[i] != '\0') { |
| 994 | | | str = t_str_new(256); |
| 995 | | | if (imap_utf8_to_utf7(argv[i], str) < 0) { |
| 996 1008 |  | | [ Lines 996 to 1008 omitted. ] |
| 1009 | | | i_fatal_status(EX_USAGE, "Missing -f argument");
x /usr/include/sysexits.h |
| |
96 | #define EX_USAGE 64 /* command line usage error */ |
| |
|
| 1010 | | | explicit_envelope_sender = |
| 1011 | | | i_strdup(address_sanitize(argv[i])); |
| 1012 | | | } else if (argv[i][0] != '\0') { |
| 1013 | | | print_help(); |
| 1014 | | | i_fatal_status(EX_USAGE,
x /usr/include/sysexits.h |
| |
96 | #define EX_USAGE 64 /* command line usage error */ |
| |
|
| 1015 | | | "Unknown argument: %s", argv[i]); |
| 1016 | | | } |
| 1017 | | | } |
| 1018 | | | |
| 1019 | | | if (user == NULL) |
Event 16:
Taking true branch. user == (void *)0 evaluates to true.
hide
|
|
| 1020 | | | user = getenv("USER"); |
| 1021 | | | if (!keep_environment) |
Event 17:
Skipping " if". keep_environment evaluates to true.
hide
|
|
| 1022 | | | deliver_env_clean(!user_auth); |
| 1023 | | | |
| 1024 | | | process_euid = geteuid(); |
| 1025 | | | if (user_auth) |
Event 18:
Taking false branch. user_auth evaluates to false.
hide
|
|
| 1026 | | | ; |
| 1027 | | | else if (process_euid != 0) { |
Event 19:
Taking true branch. process_euid != 0 evaluates to true.
hide
|
|
| 1028 | | | |
| 1029 | | | struct passwd *pw; |
| 1030 | | | |
| 1031 | | | home = getenv("HOME"); |
| 1032 | | | if (user != NULL && home != NULL) { |
| 1033 | | | |
| 1034 | | | } else if ((pw = getpwuid(process_euid)) != NULL) { |
Event 21:
Taking false branch. (pw = getpwuid(...)) != (void *)0 evaluates to false.
hide
|
|
| 1035 | | | user = t_strdup(pw->pw_name); |
| 1036 | | | if (home == NULL) |
| 1037 | | | env_put(t_strconcat("HOME=", pw->pw_dir, NULL)); |
| 1038 | | | } else if (user == NULL) { |
Event 22:
Skipping " if". user == (void *)0 evaluates to false.
hide
|
|
| 1039 | | | i_fatal_status(EX_USAGE,
x /usr/include/sysexits.h |
| |
96 | #define EX_USAGE 64 /* command line usage error */ |
| |
|
| 1040 | | | "Couldn't lookup our username (uid=%s)", |
| 1041 | | | dec2str(process_euid)); |
| 1042 | | | } |
| 1043 | | | } else { |
| 1044 | | | i_fatal_status(EX_USAGE,
x /usr/include/sysexits.h |
| |
96 | #define EX_USAGE 64 /* command line usage error */ |
| |
|
| 1045 | | | "destination user parameter (-d user) not given"); |
| 1046 | | | } |
| 1047 | | | |
| 1048 | | | T_BEGIN {
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/data-stack.h |
| |
49 | #define T_BEGIN \ |
50 | STMT_START { unsigned int _data_stack_cur_id = t_push(); |
| |
|
| 1049 | | | config_file_init(config_path); |
| 1050 | | | } T_END; |
| 1051 | | | open_logfile(user); |
| 1052 | | | |
| 1053 | | | if (getenv("MAIL_DEBUG") != NULL) |
Event 23:
Skipping " if". getenv(...) != (void *)0 evaluates to false.
hide
|
|
| 1054 | | | env_put("DEBUG=1"); |
| 1055 | | | |
| 1056 | | | if (getenv("MAIL_PLUGINS") == NULL) |
Event 24:
Taking false branch. getenv(...) == (void *)0 evaluates to false.
hide
|
|
| 1057 | | | modules = NULL; |
| 1058 | | | else { |
| 1059 | | | const char *plugin_dir = getenv("MAIL_PLUGIN_DIR"); |
| 1060 | | | const char *version; |
| 1061 | | | |
| 1062 | | | if (plugin_dir == NULL) |
Event 25:
Skipping " if". plugin_dir == (void *)0 evaluates to false.
hide
|
|
| 1063 | | | plugin_dir = MODULEDIR"/lda"; |
| 1064 | | | |
| 1065 | | | version = getenv("VERSION_IGNORE") != NULL ? |
Event 26:
getenv(...) != (void *)0 evaluates to false.
hide
|
|
| 1066 | | | NULL : PACKAGE_VERSION; |
| 1067 | | | modules = module_dir_load(plugin_dir, getenv("MAIL_PLUGINS"), |
| 1068 | | | TRUE, version); |
Event 27:
!0 evaluates to true.
hide
|
|
| 1069 | | | } |
| 1070 | | | |
| 1071 | | | if (user_auth) { |
Event 28:
Skipping " if". user_auth evaluates to false.
hide
|
|
| 1072 | | | auth_socket = getenv("AUTH_SOCKET_PATH"); |
| 1073 | | | if (auth_socket == NULL) { |
| 1074 | | | const char *base_dir = getenv("BASE_DIR"); |
| 1075 | | | if (base_dir == NULL) |
| 1076 | | | base_dir = PKG_RUNDIR; |
| 1077 | | | auth_socket = t_strconcat(base_dir, "/auth-master", |
| 1078 | | | NULL); |
| 1079 | | | } |
| 1080 | | | |
| 1081 | | | userdb_pool = pool_alloconly_create("userdb lookup replys", 512); |
| 1082 1091 |  | | [ Lines 1082 to 1091 omitted. ] |
| 1092 | | | if (getenv("DEBUG") != NULL) |
| 1093 | | | i_info("userdb changed username to %s", user); |
| 1094 | | | i_set_failure_prefix(t_strdup_printf("deliver(%s): ", |
| 1095 | | | user)); |
| 1096 | | | } |
| 1097 | | | |
| 1098 | | | |
| 1099 | | | user = t_strdup(user); |
| 1100 | | | } |
| 1101 | | | |
| 1102 | | | expand_envs(user); |
| 1103 | | | if (userdb_pool != NULL) { |
Event 29:
Skipping " if". userdb_pool != (void *)0 evaluates to false.
hide
|
|
| 1104 | | | (&); |
| 1105 | | | pool_unref(&userdb_pool); |
| 1106 | | | } |
| 1107 | | | |
| 1108 | | | |
| 1109 | | | for (i = 1;; i++) { |
| 1110 | | | value = getenv(t_strdup_printf("NAMESPACE_%u", i)); |
| 1111 | | | if (value == NULL) |
Event 30:
Skipping " if". value == (void *)0 evaluates to false.
hide
|
|
| 1112 | | | break; |
| 1113 | | | |
| 1114 | | | if (*value == '\0') { |
Event 31:
Taking true branch. *value == 0 evaluates to true.
hide
|
|
| 1115 | | | env_put(t_strdup_printf("NAMESPACE_%u=%s", i, |
| 1116 | [+][+] | | getenv("MAIL"))); |
 |
 |
| |