Text   |  XML   |  ReML   |   Visible Warnings:

Null Pointer Dereference  at nfs-workarounds.c:127

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

dotlock_create

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/file-dotlock.c)expand/collapse
Show more  
 458  dotlock_create(struct dotlock *dotlock, enum dotlock_create_flags flags,
 459                 bool write_pid, const char **lock_path_r)
 460  {
 461          const struct dotlock_settings *set = &dotlock->settings;
 462          const char *lock_path;
 463          struct lock_info lock_info;
 464          struct stat st;
 465          unsigned int stale_notify_threshold;
 466          unsigned int change_secs, wait_left;
 467          time_t now, max_wait_time, last_notify;
 468          time_t prev_last_change = 0, prev_wait_update = 0;
 469          string_t *tmp_path;
 470          int ret;
 471          bool do_wait;
 472   
 473          now = time(NULL);
 474   
 475          lock_path = *lock_path_r =
 476[+]                 t_strconcat(dotlock->path, set->lock_suffix, NULL);
 477          stale_notify_threshold = set->stale_timeout / 2;
 478          max_wait_time = (flags & DOTLOCK_CREATE_FLAG_NONBLOCK) != 0 ? 0 :
 479                  now + set->timeout;
 480          tmp_path = t_str_new(256);
 481   
 482          memset(&lock_info, 0, sizeof(lock_info));
 483          lock_info.path = dotlock->path;
 484          lock_info.set = set;
 485          lock_info.lock_path = lock_path;
 486          lock_info.fd = -1;
 487          lock_info.use_io_notify = set->use_io_notify;
 488   
 489          last_notify = 0; do_wait = FALSE;
 490   
 491          do {
 492                  if (do_wait) {
 493                          if (prev_last_change != lock_info.last_change) {
 494                                  /* dotlock changed since last check,
 495                                     reset the wait time */
 496                                  lock_info.wait_usecs = LOCK_RANDOM_USLEEP_TIME;
 497                                  prev_last_change = lock_info.last_change;
 498                                  prev_wait_update = now;
 499                          } else if (prev_wait_update != now &&
 500                                     lock_info.wait_usecs < LOCK_MAX_WAIT_USECS) {
 501                                  /* we've been waiting for a while now, increase 
 502                                     the wait time to avoid wasting CPU */
 503                                  prev_wait_update = now;
 504                                  lock_info.wait_usecs += lock_info.wait_usecs/2;
 505                          }
 506                          dotlock_wait(&lock_info);
 507                          do_wait = FALSE;
 508                  }
 509   
 510[+]                 ret = check_lock(now, &lock_info);
 511                  if (ret < 0)
 512                          break;
 513   
 514                  if (ret == 1) {
 515                          if ((flags & DOTLOCK_CREATE_FLAG_CHECKONLY) != 0)
 516                                  break;
 517   
 518                          ret = set->use_excl_lock ?
 519                                  try_create_lock_excl(&lock_info, write_pid) :
 520                                  try_create_lock_hardlink(&lock_info, write_pid,
 521[+]                                                          tmp_path);
expand/collapse

try_create_lock_hardlink

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/file-dotlock.c)expand/collapse
Show more  
 318  static int try_create_lock_hardlink(struct lock_info *lock_info, bool write_pid,
 319                                      string_t *tmp_path)
 320  {
 321          const char *temp_prefix = lock_info->set->temp_prefix;
 322          const char *p;
 323          mode_t old_mask;
 324   
 325          if (lock_info->temp_path == NULL) {
 326                  /* we'll need our temp file first. */
 327                  i_assert(lock_info->fd == -1);
 328   
 329                  p = strrchr(lock_info->lock_path, '/');
 330   
 331                  str_truncate(tmp_path, 0);
 332                  if (temp_prefix != NULL) {
 333                          if (*temp_prefix != '/' && p != NULL) {
 334                                  /* add directory */
 335                                  str_append_n(tmp_path, lock_info->lock_path,
 336
359
Show [ Lines 336 to 359 omitted. ]
 360                                             str_c(tmp_path)) < 0) {
 361                                  (void)close(lock_info->fd);
 362                                  lock_info->fd = -1;
 363                                  return -1;
 364                          }
 365                  }
 366   
 367                  lock_info->temp_path = str_c(tmp_path);
 368          }
 369   
 370          if (nfs_safe_link(lock_info->temp_path,
 371[+]                           lock_info->lock_path, TRUE) < 0) {
expand/collapse

nfs_safe_link

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/nfs-workarounds.c)expand/collapse
Show more  
 116  int nfs_safe_link(const char *oldpath, const char *newpath, bool links1)
 117  {
 118          struct stat st;
 119          nlink_t orig_link_count = 1;
 120   
 121          if (!links1) {
 122                  if (stat(oldpath, &st) < 0)
 123                          return -1;
 124                  orig_link_count = st.st_nlink;
 125          }
 126   
 127          if (link(oldpath, newpath) == 0) {
Show more  
Show more  
 522                          if (ret != 0)
 523                                  break;
 524                  }
 525   
 526                  do_wait = TRUE;
 527                  if (last_notify != now && set->callback != NULL) {
 528                          last_notify = now;
 529                          change_secs = now - lock_info.last_change;
 530                          wait_left = max_wait_time - now;
 531   
 532                          if (change_secs >= stale_notify_threshold &&
 533                              change_secs <= wait_left) {
 534                                  unsigned int secs_left =
 535                                          set->stale_timeout < change_secs ?
 536                                          0 : set->stale_timeout - change_secs;
 537                                  if (!set->callback(secs_left, TRUE,
 538                                                     set->context)) {
 539                                          /* we don't want to override */
 540                                          lock_info.last_change = now;
 541                                  }
 542                          } else if (wait_left > 0) {
 543                                  (void)set->callback(wait_left, FALSE,
 544                                                      set->context);
 545                          }
 546                  }
 547   
 548                  now = time(NULL);
 549          } while (now < max_wait_time);
Show more  




Change Warning 7080.24946 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: