Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at lazy-expunge-plugin.c:393

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

mailbox_move

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/plugins/lazy-expunge/lazy-expunge-plugin.c)expand/collapse
Show more  
 379  mailbox_move(struct mailbox_list *src_list, const char *src_name,
 380               struct mailbox_list *dest_list, const char **_dest_name)
 381  {
 382          const char *dest_name = *_dest_name;
 383          const char *srcdir, *src2dir, *src3dir, *destdir, *p, *destparent;
 384          const char *origin;
 385          struct stat st;
 386          mode_t mode;
 387          gid_t gid;
 388   
 389          srcdir = mailbox_list_get_path(src_list, src_name,
 390[+]                                        MAILBOX_LIST_PATH_TYPE_MAILBOX);
 391          destdir = mailbox_list_get_path(dest_list, dest_name,
 392                                          MAILBOX_LIST_PATH_TYPE_MAILBOX);
 393          while (rename(srcdir, destdir) < 0) {
 394                  if (errno == ENOENT) {
 395                          /* if this is because the destination parent directory
 396                             didn't exist, create it. */
 397                          p = strrchr(destdir, '/');
 398                          if (p == NULL)
 399                                  return 0;
 400                          destparent = t_strdup_until(destdir, p);
 401                          if (stat(destparent, &st) == 0)
 402                                  return 0;
 403   
 404                          mailbox_list_get_dir_permissions(dest_list, NULL,
 405                                                           &mode, &gid, &origin);
 406                          if (mkdir_parents_chgrp(destparent, mode,
 407                                                  gid, origin) < 0) {
 408                                  if (errno == EEXIST) {
 409                                          /* race condition */
 410                                          continue;
 411                                  }
 412                                  mailbox_list_set_critical(src_list,
 413                                          "mkdir(%s) failed: %m", destparent);
 414                                  return -1;
 415                          }
 416                          /* created, try again. */
 417                          continue;
 418                  }
 419   
 420                  if (!EDESTDIREXISTS(errno)) {
 421                          mailbox_list_set_critical(src_list,
 422                                  "rename(%s, %s) failed: %m", srcdir, destdir);
 423                          return -1;
 424                  }
 425   
 426                  /* mailbox is being deleted multiple times per second.
 427                     update the filename. */
 428                  dest_name = t_strdup_printf("%s-%04u", *_dest_name,
 429                                              (uint32_t)random());
 430                  destdir = mailbox_list_get_path(dest_list, dest_name,
 431                                                  MAILBOX_LIST_PATH_TYPE_MAILBOX);
Show more  




Change Warning 8115.24984 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: