Text   |  XML   |  ReML   |   Visible Warnings:

Buffer Overrun  at strfuncs.c:39

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

maildir_copy_hardlink

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/maildir/maildir-copy.c)expand/collapse
Show more  
 129  maildir_copy_hardlink(struct maildir_transaction_context *t, struct mail *mail,
 130                        enum mail_flags flags, struct mail_keywords *keywords,
 131                        struct mail *dest_mail)
 132  {
 133          struct maildir_mailbox *dest_mbox =
 134                  (struct maildir_mailbox *)t->ictx.ibox;
 135          struct maildir_mailbox *src_mbox;
 136          struct hardlink_ctx do_ctx;
 137          const char *path, *filename = NULL;
 138   
 139          i_assert((t->ictx.flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0);
 140   
 141          if (strcmp(mail->box->storage->name, MAILDIR_STORAGE_NAME) == 0)
 142                  src_mbox = (struct maildir_mailbox *)mail->box;
 143          else if (strcmp(mail->box->storage->name, "raw") == 0) {
 144                  /* deliver uses raw format */
 145                  src_mbox = NULL;
 146          } else {
 147                  /* Can't hard link files from the source storage */
 148                  return 0;
 149          }
 150   
 151          if (t->save_ctx == NULL)
 152                  t->save_ctx = maildir_save_transaction_init(t);
 153   
 154          /* don't allow caller to specify recent flag */
 155          flags &= ~MAIL_RECENT;
 156          if (dest_mbox->ibox.keep_recent)
 157                  flags |= MAIL_RECENT;
 158   
 159          memset(&do_ctx, 0, sizeof(do_ctx));
 160          do_ctx.dest_path = str_new(default_pool, 512);
 161   
 162          if (dest_mbox->storage->copy_preserve_filename && src_mbox != NULL) {
 163                  enum maildir_uidlist_rec_flag src_flags;
 164                  const char *src_fname;
 165   
 166                  /* see if the filename exists in destination maildir's
 167                     uidlist. if it doesn't, we can use it. otherwise generate
 168                     a new filename. FIXME: There's a race condition here if 
 169                     another process is just doing the same copy. */
 170                  if (maildir_uidlist_lookup(src_mbox->uidlist,
 171                                             mail->uid, &src_flags,
 172                                             &src_fname) > 0 &&
 173                      maildir_uidlist_refresh(dest_mbox->uidlist) >= 0 &&
 174                      maildir_uidlist_get_full_filename(dest_mbox->uidlist,
 175                                                        src_fname) == NULL)
 176                          filename = t_strcut(src_fname, ':');
 177          }
 178          if (filename == NULL) {
 179                  /* the generated filename is _always_ unique, so we don't
 180                     bother trying to check if it already exists */
 181[+]                 do_ctx.dest_fname = maildir_filename_generate();
 182          } else {
 183                  do_ctx.dest_fname = filename;
 184                  do_ctx.preserve_filename = TRUE;
 185          }
 186   
 187          /* FIXME: We could hardlink the files directly to destination, but 
 188             that would require checking if someone else had already assigned 
 189             UIDs for them after we have the uidlist locked. Index would also 
 190             need to be properly not-updated somehow.. */
 191  #if 0 
 192
202
Show [ Lines 192 to 202 omitted. ]
 203                          str_append(do_ctx.dest_path,
 204                                     maildir_filename_set_flags(NULL,
 205                                                                do_ctx.dest_fname,
 206                                                                flags, NULL));
 207                  }
 208          } else 
 209  #endif
 210          {
 211                  /* keywords, hardlink to tmp/ with basename and later when we
 212                     have uidlist locked, move it to new/cur. */
 213                  str_printfa(do_ctx.dest_path, "%s/tmp/%s",
 214                              dest_mbox->path, do_ctx.dest_fname);
 215                  do_ctx.base_end_pos = str_len(do_ctx.dest_path);
 216          }
 217          if (src_mbox != NULL) {
 218                  /* maildir */
 219                  if (maildir_file_do(src_mbox, mail->uid,
 220                                      do_hardlink, &do_ctx) < 0)
 221                          return -1;
 222          } else {
 223                  /* raw / deliver */
 224                  if (mail_get_special(mail, MAIL_FETCH_UIDL_FILE_NAME,
 225                                       &path) < 0 || *path == '\0')
 226                          return 0;
 227[+]                 if (do_hardlink(dest_mbox, path, &do_ctx) < 0)
 228                          return -1;
 229          }
 230   
 231          if (!do_ctx.success) {
 232                  /* couldn't copy with hardlinking, fallback to copying */
 233                  return 0;
 234          }
 235   
 236  #if 0 
 237          if (keywords == NULL || keywords->count == 0) {
 238                  /* hardlinked to destination, set hardlinked-flag */
 239                  maildir_save_add(t, do_ctx.dest_fname,
 240                                   flags | MAILDIR_SAVE_FLAG_HARDLINK, NULL,
 241                                   dest_mail);
 242          } else 
 243  #endif
 244  {
 245                  /* hardlinked to tmp/, treat as normal copied mail */
 246                  maildir_save_add(t, do_ctx.dest_fname, flags, keywords,
 247[+]                                  dest_mail);
expand/collapse

maildir_save_add

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/maildir/maildir-save.c)expand/collapse
Show more  
 137  uint32_t maildir_save_add(struct maildir_transaction_context *t,
 138                            const char *base_fname, enum mail_flags flags,
 139                            struct mail_keywords *keywords,
 140                            struct mail *dest_mail)
 141  {
 142          struct maildir_save_context *ctx = t->save_ctx;
 143          struct maildir_filename *mf;
 144          struct istream *input;
 145   
 146          /* now, we want to be able to rollback the whole append session,
 147             so we'll just store the name of this temp file and move it later
 148             into new/ or cur/. */
 149          /* @UNSAFE */
 150          mf = p_malloc(ctx->pool, sizeof(*mf) +
 151                        sizeof(unsigned int) * (keywords == NULL ? 0 :
 152                                                keywords->count));
 153[+]         mf->basename = p_strdup(ctx->pool, base_fname);
expand/collapse

p_strdup

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/strfuncs.c)expand/collapse
Show more  
 31  char *p_strdup(pool_t pool, const char *str)
 32  {
 33          void *mem;
 34          size_t len;
 35   
 36          if (str == NULL)
 37                  return NULL;
 38   
 39          for (len = 0; (str)[len] != '\0'; )
 40                  len++;
Show more  
Show more  
Show more  




Change Warning 7323.26023 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: