Text   |  XML   |  ReML   |   Visible Warnings:

Negative file descriptor  at nfs-workarounds.c:249

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

mbox_open

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/mbox/mbox-storage.c)expand/collapse
Show more  
 601  static struct mailbox *
 602  mbox_open(struct mbox_storage *storage, const char *name,
 603            enum mailbox_open_flags flags)
 604  {
 605          struct mail_storage *_storage = &storage->storage;
 606          struct mbox_mailbox *mbox;
 607          struct mail_index *index;
 608          const char *path, *rootdir;
 609   
 610          path = mailbox_list_get_path(_storage->list, name,
 611                                       MAILBOX_LIST_PATH_TYPE_MAILBOX);
 612   
 613          index = index_storage_alloc(_storage, name, flags, MBOX_INDEX_PREFIX);
 614[+]         mbox = mbox_alloc_mailbox(storage, index, name, path, flags);
 615   
 616          if (access(path, R_OK|W_OK) < 0) {
 617                  if (errno < EACCES)
 618                          mbox_set_syscall_error(mbox, "access()");
 619                  else 
 620                          mbox->ibox.backend_readonly = TRUE;
 621          }
 622   
 623          if (strcmp(name, "INBOX") == 0) {
 624                  /* if INBOX isn't under the root directory, it's probably in
 625                     /var/mail and we want to allow privileged dotlocking */
 626                  rootdir = mailbox_list_get_path(_storage->list, NULL,
 627                                                  MAILBOX_LIST_PATH_TYPE_DIR);
 628                  if (strncmp(path, rootdir, strlen(rootdir)) != 0)
 629                          mbox->mbox_privileged_locking = TRUE;
 630          }
 631          if ((flags & MAILBOX_OPEN_KEEP_LOCKED) != 0) {
 632[+]                 if (mbox_lock(mbox, F_WRLCK, &mbox->mbox_global_lock_id) <= 0) {
expand/collapse

mbox_lock

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/mbox/mbox-lock.c)expand/collapse
Show more  
 770  int mbox_lock(struct mbox_mailbox *mbox, int lock_type,
 771                unsigned int *lock_id_r)
 772  {
 773          bool fcntl_locked;
 774          int ret;
 775   
 776          /* allow only unlock -> shared/exclusive or exclusive -> shared */
 777          i_assert(lock_type == F_RDLCK || lock_type == F_WRLCK);
 778          i_assert(lock_type == F_RDLCK || mbox->mbox_lock_type != F_RDLCK);
 779   
 780          /* mbox must be locked before index */
 781          i_assert(mbox->ibox.index->lock_type != F_WRLCK);
 782   
 783          if (mbox->mbox_lock_type == F_UNLCK) {
 784[+]                 ret = mbox_update_locking(mbox, lock_type, &fcntl_locked);
 785                  if (ret <= 0)
 786                          return ret;
 787   
 788                  if ((mbox->storage->storage.flags &
 789                       MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0) {
 790                          if (fcntl_locked) {
 791                                  nfs_flush_attr_cache_fd_locked(mbox->path,
 792                                                                 mbox->mbox_fd);
 793                                  nfs_flush_read_cache_locked(mbox->path,
 794                                                              mbox->mbox_fd);
 795                          } else {
 796                                  nfs_flush_attr_cache_unlocked(mbox->path);
 797                                  nfs_flush_read_cache_unlocked(mbox->path,
 798[+]                                                               mbox->mbox_fd);
expand/collapse

nfs_flush_read_cache_unlocked

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/nfs-workarounds.c)expand/collapse
Show more  
 385  void nfs_flush_read_cache_unlocked(const char *path, int fd)
 386  {
 387  #ifdef READ_CACHE_FLUSH_FCNTL 
 388[+]         if (!nfs_flush_fcntl(path, fd))
expand/collapse

nfs_flush_fcntl

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/nfs-workarounds.c)expand/collapse
Show more  
 217  static bool nfs_flush_fcntl(const char *path, int fd)
 218  {
 219          static bool locks_disabled = FALSE;
 220          struct flock fl;
 221          int ret;
 222   
 223          if (locks_disabled)
 224                  return FALSE;
 225   
 226          /* If the file was already locked, we'll just get the same lock 
 227             again. It should succeed just fine. If was was unlocked, we'll
 228             have to get a lock and then unlock it. Linux 2.6 flushes read cache 
 229             only when read/write locking succeeded. */
 230          fl.l_type = F_RDLCK;
 231          fl.l_whence = SEEK_SET;
 232          fl.l_start = 0;
 233          fl.l_len = 0;
 234   
 235          alarm(60);
 236          ret = fcntl(fd, F_SETLKW, &fl);
 237          alarm(0);
 238   
 239          if (unlikely(ret < 0)) {
 240                  if (errno == ENOLCK) {
 241                          locks_disabled = TRUE;
 242                          return FALSE;
 243                  }
 244                  i_error("nfs_flush_fcntl: fcntl(%s, F_RDLCK) failed: %m", path);
 245                  return FALSE;
 246          }
 247   
 248          fl.l_type = F_UNLCK;
 249          (void)fcntl(fd, F_SETLKW, &fl);
Show more  
Show more  
Show more  
Show more  




Change Warning 7437.25930 : Negative file descriptor

Priority:
State:
Finding:
Owner:
Note: