Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at mail-index-strmap.c:1032

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

mail_index_strmap_recreate

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-index-strmap.c)expand/collapse
Show more  
 983  static int mail_index_strmap_recreate(struct mail_index_strmap_view *view)
 984  {
 985          struct mail_index_strmap *strmap = view->strmap;
 986          string_t *str;
 987          struct ostream *output;
 988          const char *temp_path;
 989          int fd, ret = 0;
 990   
 991[+]         if (array_count(&view->recs) == 0) {
 992                  /* everything expunged - just unlink the existing index */
 993                  if (unlink(strmap->path) < 0 && errno != ENOENT)
 994                          mail_index_strmap_set_syscall_error(strmap, "unlink()");
 995                  return 0;
 996          }
 997   
 998[+]         str = t_str_new(256);
 999          str_append(str, strmap->path);
 1000          fd = safe_mkstemp_hostpid_group(str, view->view->index->mode,
 1001                                          view->view->index->gid,
 1002[+]                                         view->view->index->gid_origin);
 1003[+]         temp_path = str_c(str);
 1004   
 1005          if (fd == -1) {
 1006                  mail_index_set_error(strmap->index,
 1007                                       "safe_mkstemp_hostpid(%s) failed: %m",
 1008                                       temp_path);
 1009                  return -1;
 1010          }
 1011          output = o_stream_create_fd(fd, 0, FALSE);
 1012          o_stream_cork(output);
 1013          mail_index_strmap_recreate_write(view, output);
 1014          if (output->last_failed_errno != 0) {
 1015                  errno = output->last_failed_errno;
 1016                  mail_index_set_error(strmap->index,
 1017                                       "write(%s) failed: %m", temp_path);
 1018                  ret = -1;
 1019          }
 1020          o_stream_destroy(&output);
 1021          if (close(fd) < 0) {
 1022                  mail_index_set_error(strmap->index,
 1023                                       "close(%s) failed: %m", temp_path);
 1024                  ret = -1;
 1025          } else if (ret == 0 && rename(temp_path, strmap->path) < 0) {
 1026                  mail_index_set_error(strmap->index,
 1027                                       "rename(%s, %s) failed: %m",
 1028                                       temp_path, strmap->path);
 1029                  ret = -1;
 1030          }
 1031          if (ret < 0)
 1032                  (void)unlink(temp_path);
Show more  




Change Warning 7255.24960 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: