Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at dbox-storage.c:509

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

dbox_list_delete_mailbox

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/dbox/dbox-storage.c)expand/collapse
Show more  
 448  dbox_list_delete_mailbox(struct mailbox_list *list, const char *name)
 449  {
 450          struct dbox_storage *storage = DBOX_LIST_CONTEXT(list);
 451          struct stat st;
 452          const char *path, *alt_path;
 453          bool deleted = FALSE;
 454          int ret;
 455   
 456          /* Make sure the indexes are closed before trying to delete the 
 457             directory that contains them. It can still fail with some NFS 
 458             implementations if indexes are opened by another session, but 
 459             that can't really be helped. */
 460          index_storage_destroy_unrefed();
 461   
 462          /* delete the index and control directories */
 463          if (storage->list_module_ctx.super.delete_mailbox(list, name) < 0)
 464                  return -1;
 465   
 466          /* check if the mailbox actually exists */
 467          path = mailbox_list_get_path(list, name,
 468                                       MAILBOX_LIST_PATH_TYPE_MAILBOX);
 469          if ((ret = dbox_delete_nonrecursive(list, path, name)) > 0) {
 470                  /* delete the mailbox first */
 471                  alt_path = dbox_get_alt_path(storage, path);
 472                  if (alt_path != NULL) {
 473                          if (dbox_delete_nonrecursive(list, alt_path, name) < 0)
 474                                  return -1;
 475                  }
 476                  if (*list->set.maildir_name == '\0') {
 477                          /* everything was in the one directory that was
 478                             already deleted succesfully. */
 479                          return 0;
 480                  }
 481                  /* try to delete the directory also */
 482                  deleted = TRUE;
 483                  path = mailbox_list_get_path(list, name,
 484                                               MAILBOX_LIST_PATH_TYPE_DIR);
 485          } else if (errno != ENOENT) {
 486                  mailbox_list_set_critical(list, "stat(%s) failed: %m", path);
 487                  return -1;
 488          } else {
 489                  /* mailbox not found - what about the directory? */
 490                  path = mailbox_list_get_path(list, name,
 491[+]                                              MAILBOX_LIST_PATH_TYPE_DIR);
 492                  if (stat(path, &st) == 0) {
 493                          /* delete the directory */
 494                  } else if (errno == ENOENT) {
 495                          mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND,
 496                                  T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
 497                          return -1;
 498                  } else if (!mailbox_list_set_error_from_errno(list)) {
 499                          mailbox_list_set_critical(list, "stat(%s) failed: %m",
 500                                                    path);
 501                          return -1;
 502                  }
 503          }
 504   
 505          alt_path = dbox_get_alt_path(storage, path);
 506          if (alt_path != NULL)
 507                  (void)rmdir(alt_path);
 508   
 509          if (rmdir(path) == 0)
Show more  




Change Warning 7484.25730 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: