(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/cydir/cydir-save.c) |
| |
| 154 | | | int cydir_save_finish(struct mail_save_context *_ctx) |
| 155 | | | { |
| 156 | | | struct cydir_save_context *ctx = (struct cydir_save_context *)_ctx; |
| 157 | | | struct mail_storage *storage = &ctx->mbox->storage->storage; |
| 158 | [+] | | const char *path = cydir_get_save_path(ctx, ctx->mail_count); |
 |
| 159 | | | struct stat st; |
| 160 | | | |
| 161 | | | ctx->finished = TRUE; |
Event 33:
!0 evaluates to true.
hide
|
|
| 162 | | | |
| 163 | [+] | | if (o_stream_flush(_ctx->output) < 0) { |
 |
| 164 | | | mail_storage_set_critical(storage, |
| 165 | | | "o_stream_flush(%s) failed: %m", path); |
| 166 | | | ctx->failed = TRUE; |
| 167 | | | } |
| 168 | | | |
| 169 | | | if (!ctx->mbox->ibox.fsync_disable) { |
Event 42:
Skipping " if". ctx->mbox->ibox.fsync_disable evaluates to true.
hide
|
|
| 170 | | | if (fsync(ctx->fd) < 0) { |
| 171 | | | mail_storage_set_critical(storage, |
| 172 | | | "fsync(%s) failed: %m", path); |
| 173 | | | ctx->failed = TRUE; |
| 174 | | | } |
| 175 | | | } |
| 176 | | | |
| 177 | | | if (_ctx->received_date == (time_t)-1) { |
Event 43:
Taking false branch. _ctx->received_date == (time_t)-1 evaluates to false.
hide
|
|
| 178 | | | if (fstat(ctx->fd, &st) == 0) |
| 179 | | | _ctx->received_date = st.st_mtime;
x /usr/include/bits/stat.h |
| |
95 | # define st_mtime st_mtim.tv_sec |
| |
|
| 180 | | | else { |
| 181 | | | mail_storage_set_critical(storage, |
| 182 | | | "fstat(%s) failed: %m", path); |
| 183 | | | ctx->failed = TRUE; |
| 184 | | | } |
| 185 | | | } else { |
| 186 | | | struct utimbuf ut; |
| 187 | | | |
| 188 | | | ut.actime = ioloop_time; |
| 189 | | | ut.modtime = _ctx->received_date; |
| 190 | | | if (utime(path, &ut) < 0) { |
Event 44:
path, which evaluates to the value assigned to ret at data-stack.c:335, is passed to utime() as the first argument. See related event 32.
hide
Event 45:
utime() accesses the file named path, where path is the value assigned to ret at data-stack.c:335. - The same name is used to access a file later, but it is not safe to assume that it will be the same underlying file.
See related event 44.
hide
Event 46:
Skipping " if". utime(path, &ut) < 0 evaluates to false.
hide
|
|
| 191 | | | mail_storage_set_critical(storage, |
| 192 | | | "utime(%s) failed: %m", path); |
| 193 | | | ctx->failed = TRUE; |
| 194 | | | } |
| 195 | | | } |
| 196 | | | |
| 197 | | | o_stream_destroy(&_ctx->output); |
| 198 | | | if (close(ctx->fd) < 0) { |
Event 47:
Skipping " if". close(ctx->fd) < 0 evaluates to false.
hide
|
|
| 199 | | | mail_storage_set_critical(storage, |
| 200 | | | "close(%s) failed: %m", path); |
| 201 | | | ctx->failed = TRUE; |
| 202 | | | } |
| 203 | | | ctx->fd = -1; |
| 204 | | | |
| 205 | | | if (!ctx->failed) |
Event 48:
Taking false branch. ctx->failed evaluates to true.
hide
|
|
| 206 | | | ctx->mail_count++; |
| 207 | | | else { |
| 208 | | | if (unlink(path) < 0) { |
Event 49:
path, which evaluates to the value assigned to ret at data-stack.c:335, is passed to unlink(). See related event 32.
hide
File System Race Condition
The file named path is accessed again. Another process may have changed the file since the access at cydir-save.c:190. For example, an attacker could replace the original file with a link to a file containing important or confidential data. The issue can occur if the highlighted code executes. See related events 45 and 49. Show: All events | Only primary events |
|
| |