Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Call  at file-dotlock.c:345

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

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                                               p - lock_info->lock_path);
 337                                  str_append_c(tmp_path, '/');
 338                          }
 339                          str_append(tmp_path, temp_prefix);
 340                  } else {
 341                          if (p != NULL) {
 342                                  /* add directory */
 343                                  str_append_n(tmp_path, lock_info->lock_path,
 344                                               p - lock_info->lock_path);
 345                                  str_append_c(tmp_path, '/');
 346                          }
 347                          str_printfa(tmp_path, ".temp.%s.%s.",
 348                                      my_hostname, my_pid);
 349                  }
 350   
 351                  old_mask = umask(0666);
 352                  lock_info->fd = safe_mkstemp(tmp_path, 0666 ^ old_mask,
 353                                               (uid_t)-1, (gid_t)-1);
 354                  umask(old_mask);
 355                  if (lock_info->fd == -1)
 356                          return -1;
 357   
 358                  if (write_pid) {
 359                          if (file_write_pid(lock_info->fd,
 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) {
 372                  if (errno == EEXIST)
 373                          return 0;
 374   
 375                  if (errno != EACCES) {
 376                          i_error("link(%s, %s) failed: %m",
 377                                  lock_info->temp_path, lock_info->lock_path);
 378                  }
 379                  return -1;
 380          }
 381   
 382          if (unlink(lock_info->temp_path) < 0) {
 383                  i_error("unlink(%s) failed: %m", lock_info->temp_path);
 384                  /* non-fatal, continue */
 385          }
 386          lock_info->temp_path = NULL;
 387          return 1;
 388  }
Show more  




Change Warning 7074.24874 : Unreachable Call

Because they are very similar, this warning shares annotations with warning 7074.24875.

Priority:
State:
Finding:
Owner:
Note: