Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Data Flow  at mailbox-list-maildir-iter.c:242

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

maildir_fill_readdir

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/list/mailbox-list-maildir-iter.c)expand/collapse
Show more  
 119  maildir_fill_readdir(struct maildir_list_iterate_context *ctx,
 120                       struct imap_match_glob *glob, bool update_only)
 121  {
 122          struct mail_namespace *ns = ctx->ctx.list->ns;
 123          DIR *dirp;
 124          struct dirent *d;
 125          const char *mailbox_name;
 126          string_t *mailbox;
 127          enum mailbox_info_flags flags;
 128          enum imap_match_result match;
 129          struct mailbox_node *node;
 130          bool created, virtual_names;
 131          char prefix_char;
 132          int ret;
 133   
 134          dirp = opendir(ctx->dir);
 135          if (dirp == NULL) {
 136                  if (errno == EACCES) {
 137                          mailbox_list_set_critical(ctx->ctx.list, "%s",
 138                                  mail_error_eacces_msg("opendir", ctx->dir));
 139                  } else if (errno != ENOENT) {
 140                          mailbox_list_set_critical(ctx->ctx.list,
 141                                  "opendir(%s) failed: %m", ctx->dir);
 142                          return -1;
 143                  }
 144                  return 0;
 145          }
 146   
 147          virtual_names = (ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0;
 148          prefix_char =
 149                  strcmp(ctx->ctx.list->name, MAILBOX_LIST_NAME_IMAPDIR) != 0 ?
 150                  ctx->ctx.list->hierarchy_sep : '\0';
 151   
 152          mailbox = t_str_new(PATH_MAX);
 153          while ((d = readdir(dirp)) != NULL) {
 154                  const char *fname = d->d_name;
 155   
 156                  if (fname[0] == prefix_char)
 157                          mailbox_name = fname + 1;
 158                  else {
 159                          if (prefix_char != '\0' || fname[0] == '.')
 160                                  continue;
 161                          mailbox_name = fname;
 162                  }
 163   
 164                  /* skip . and .. */
 165                  if (fname[0] == '.' &&
 166                      (fname[1] == '\0' || (fname[1] == '.' && fname[2] == '\0')))
 167                          continue;
 168   
 169                  if (!virtual_names) {
 170                          str_truncate(mailbox, 0);
 171                          str_append(mailbox, mailbox_name);
 172                          mailbox_name = str_c(mailbox);
 173                  } else {
 174                          mailbox_name = mail_namespace_get_vname(ns, mailbox,
 175                                                                  mailbox_name);
 176                  }
 177   
 178                  /* make sure the pattern matches */
 179                  match = imap_match(glob, mailbox_name);
 180                  if ((match & (IMAP_MATCH_YES | IMAP_MATCH_PARENT)) == 0)
 181                          continue;
 182   
 183                  /* check if this is an actual mailbox */
 184                  flags = 0;
 185                  T_BEGIN {
 186                          ret = ctx->ctx.list->v.
 187                                  iter_is_mailbox(&ctx->ctx, ctx->dir, fname,
 188                                          mailbox_name,
 189                                          mailbox_list_get_file_type(d), &flags);
 190                  } T_END;
 191                  if (ret <= 0) {
 192                          if (ret < 0)
 193                                  return -1;
 194                          continue;
 195                  }
 196   
 197                  /* we know the children flags ourself, so ignore if any of 
 198                     them were set. */
 199                  flags &= ~(MAILBOX_NOINFERIORS |
 200                             MAILBOX_CHILDREN | MAILBOX_NOCHILDREN);
 201   
 202                  if ((match & IMAP_MATCH_PARENT) != 0) {
 203                          T_BEGIN {
 204                                  maildir_fill_parents(ctx, glob, update_only,
 205                                                       mailbox, flags);
 206                          } T_END;
 207                  } else {
 208                          created = FALSE;
 209                          node = update_only ?
 210                                  mailbox_tree_lookup(ctx->tree_ctx,
 211                                                      mailbox_name) :
 212                                  mailbox_tree_get(ctx->tree_ctx,
 213                                                   mailbox_name, &created);
 214   
 215                          if (node != NULL) {
 216                                  if (created)
 217                                          node->flags = MAILBOX_NOCHILDREN;
 218                                  else 
 219                                          node->flags &= ~MAILBOX_NONEXISTENT;
 220                                  if (!update_only)
 221                                          node->flags |= MAILBOX_MATCHED;
 222                                  node->flags |= flags;
 223                                  node_fix_parents(node);
 224                          } else {
 225                                  i_assert(update_only);
 226                                  maildir_set_children(ctx, mailbox);
 227                          }
 228                  }
 229          }
 230   
 231          if (closedir(dirp) < 0) {
 232                  mailbox_list_set_critical(ctx->ctx.list,
 233                                            "readdir(%s) failed: %m", ctx->dir);
 234                  return -1;
 235          }
 236   
 237          if ((ns->flags & NAMESPACE_FLAG_INBOX) != 0) {
 238                  /* make sure INBOX is listed */
 239                  if (!virtual_names)
 240                          mailbox_name = "INBOX";
 241                  else {
 242                          mailbox_name = mail_namespace_get_vname(ns, mailbox,
 243                                                                  "INBOX");
 244                  }
 245   
 246                  created = FALSE;
 247                  node = update_only ?
 248                          mailbox_tree_lookup(ctx->tree_ctx, mailbox_name) :
 249                          mailbox_tree_get(ctx->tree_ctx, mailbox_name, &created);
 250                  if (created)
 251                          node->flags = MAILBOX_NOCHILDREN;
 252                  else if (node != NULL)
 253                          node->flags &= ~MAILBOX_NONEXISTENT;
 254   
 255                  match = imap_match(glob, mailbox_name);
 256                  if ((match & (IMAP_MATCH_YES | IMAP_MATCH_PARENT)) != 0) {
 257                          if (!update_only)
 258                                  node->flags |= MAILBOX_MATCHED;
 259                  }
 260          }
 261          return 0;
 262  }
Show more  




Change Warning 7292.24972 : Unreachable Data Flow

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

Priority:
State:
Finding:
Owner:
Note: