(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/master/dict-process.c) |
| |
| 38 | | | static int dict_process_create(struct dict_listener *listener) |
| 39 | | | { |
| 40 | | | struct dict_process *process; |
| 41 | | | struct log_io *log; |
| 42 | | | const char *executable, *const *dicts; |
| 43 | | | unsigned int i, count; |
| 44 | | | int log_fd; |
| 45 | | | pid_t pid; |
| 46 | | | |
| 47 | | | process = i_new(struct dict_process, 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))) |
| |
|
| 48 | | | process->process.type = PROCESS_TYPE_DICT; |
| 49 | | | process->listener = listener; |
| 50 | | | |
| 51 | | | log_fd = log_create_pipe(&log, 0); |
| 52 | | | if (log_fd < 0) |
| 53 | | | pid = -1; |
| 54 | | | else { |
| 55 | | | pid = fork(); |
| 56 | | | if (pid < 0) |
| 57 | | | i_error("fork() failed: %m"); |
| 58 | | | } |
| 59 | | | |
| 60 | | | if (pid < 0) { |
| 61 | | | (void)close(log_fd); |
| 62 | | | i_free(process);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/imem.h |
| |
14 | #define i_free(mem) \ |
15 | STMT_START { \ |
16 | free(mem); \ |
17 | (mem) = NULL; \ |
18 | } STMT_END |
| |
|
| 63 | | | return -1; |
| 64 | | | } |
| 65 | | | |
| 66 | | | if (pid != 0) { |
| 67 | | | |
| 68 | | | process->next = process->listener->processes; |
| 69 | | | process->listener->processes = process; |
| 70 | | | |
| 71 | | | child_process_add(pid, &process->process); |
| 72 | | | log_set_prefix(log, "dict: "); |
| 73 | | | log_set_pid(log, pid); |
| 74 | | | (void)close(log_fd); |
| 75 | | | |
| 76 | | | process->log = log; |
| 77 | | | log_ref(process->log); |
| 78 | | | return 0; |
| 79 | | | } |
| 80 | | | log_set_prefix(log, "master-dict: "); |
| 81 | | | |
| 82 | | | |
| 83 | | | |
| 84 | | | closelog(); |
| 85 | | | |
| 86 | | | |
| 87 | | | |
| 88 | | | if (dup2(null_fd, 0) < 0) |
| 89 | | | i_fatal("dup2(stdin) failed: %m"); |
| 90 | | | if (dup2(null_fd, 1) < 0) |
| 91 | | | i_fatal("dup2(stdout) failed: %m"); |
| 92 | | | |
| 93 | | | |
| 94 | | | if (dup2(log_fd, 2) < 0) |
| 95 | | | i_fatal("dup2(stderr) failed: %m"); |
| 96 | | | if (dup2(process->listener->fd, 3) < 0) |
| 97 | | | i_fatal("dup2(3) failed: %m"); |
| 98 | | | |
| 99 | | | for (i = 0; i <= 3; i++) |
| 100 | | | fd_close_on_exec(i, FALSE); |
| 101 | | | |
| 102 | | | child_process_init_env(); |
| 103 | | | env_put(t_strconcat("DICT_LISTEN_FROM_FD=", |
| 104 | | | process->listener->path, NULL)); |
| 105 | | | |
| 106 | | | env_put(t_strconcat("BASE_DIR=", settings_root->defaults->base_dir, |
| 107 | | | NULL)); |
| 108 | | | if (settings_root->defaults->dict_db_config != NULL) { |
| 109 | | | env_put(t_strconcat("DB_CONFIG=", |
| 110 | | | settings_root->defaults->dict_db_config, |
| 111 | | | NULL)); |
| 112 | | | } |
| 113 | | | |
| 114 | | | dicts = array_get(&settings_root->dicts, &count);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/array.h |
| |
156 | #define array_get(array, count) \ |
157 | ARRAY_TYPE_CAST_CONST(array)array_get_i(&(array)->arr, count) |
| |
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/array.h |
| |
43 | # define ARRAY_TYPE_CAST_CONST(array) \ |
44 | (typeof(*(array)->v)) |
| |
|
| 115 | | | i_assert((count % 2) == 0);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/macros.h |
| |
189 | #define i_assert(expr) STMT_START{ \ |
190 | if (unlikely(!(expr))) \ |
191 | i_panic("file %s: line %d (%s): assertion failed: (%s)", \ |
192 | __FILE__, \ |
193 | __LINE__, \ |
194 | __PRETTY_FUNCTION__, \ |
195 | #expr); }STMT_END |
| |
|
| 116 | | | for (i = 0; i < count; i += 2) |
| 117 | | | env_put(t_strdup_printf("DICT_%s=%s", dicts[i], dicts[i+1])); |
| 118 | | | |
| 119 | | | executable = PKG_LIBEXECDIR"/dict"; |
| 120 | | | client_process_exec(executable, ""); |
| 121 | | | i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m", executable); |
| 122 | | | return -1; |
Unreachable Computation
The highlighted code will not execute under any circumstances. |
|
| 123 | | | } |
| |