Text   |  XML   |  ReML   |   Visible Warnings:

Uninitialized Variable  at mail-storage.c:225

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

shared_storage_get_namespace

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/shared/shared-storage.c)expand/collapse
Show more  
 125  int shared_storage_get_namespace(struct mail_storage *_storage,
 126                                   const char **_name,
 127                                   struct mail_namespace **ns_r)
 128  {
 129          struct shared_storage *storage = (struct shared_storage *)_storage;
 130          struct mail_user *user = _storage->ns->user;
 131          static struct var_expand_table static_tab[] = {
 132                  { 'u', NULL, "user" },
 133                  { 'n', NULL, "username" },
 134                  { 'd', NULL, "domain" },
 135                  { 'h', NULL, "home" },
 136                  { '\0', NULL, NULL }
 137          };
 138          struct var_expand_table *tab;
 139          struct mail_namespace *ns;
 140          struct mail_user *owner;
 141          const char *domain = NULL, *username = NULL, *userdomain = NULL;
 142          const char *name, *p, *next, **dest, *error;
 143          string_t *prefix, *location;
 144          int ret;
 145   
 146          *ns_r = NULL;
 147   
 148          p = storage->ns_prefix_pattern;
 149          for (name = *_name; *p != '\0';) {
 150                  if (*p != '%') {
 151                          if (*p != *name)
 152                                  break;
 153                          p++; name++;
 154                          continue;
 155                  }
 156                  switch (*++p) {
 157                  case 'd':
 158                          dest = &domain;
 159                          break;
 160                  case 'n':
 161                          dest = &username;
 162                          break;
 163                  case 'u':
 164                          dest = &userdomain;
 165                          break;
 166                  default:
 167                          /* we checked this already above */
 168                          i_unreached();
 169                  }
 170                  p++;
 171   
 172                  next = strchr(name, *p != '\0' ? *p : _storage->ns->sep);
 173                  if (next == NULL) {
 174                          *dest = name;
 175                          name = "";
 176                          break;
 177                  }
 178                  *dest = t_strdup_until(name, next);
 179                  name = next;
 180          }
 181          if (*p != '\0') {
 182                  if (*name == '\0' ||
 183                      (name[1] == '\0' && *name == _storage->ns->sep)) {
 184                          /* trying to open <prefix>/<user> mailbox */
 185                          name = "INBOX";
 186                  } else {
 187                          mail_storage_set_critical(_storage,
 188                                          "Invalid namespace prefix %s vs %s",
 189                                          storage->ns_prefix_pattern, *_name);
 190                          return -1;
 191                  }
 192          }
 193   
 194          /* successfully matched the name. */
 195          if (userdomain == NULL) {
 196                  if (username == NULL) {
 197                          /* trying to open namespace "shared/domain"
 198                             namespace prefix. */
 199                          mail_storage_set_error(_storage, MAIL_ERROR_NOTFOUND,
 200                                  T_MAIL_ERR_MAILBOX_NOT_FOUND(*_name));
 201                          return -1;
 202                  }
 203                  userdomain = domain == NULL ? username :
 204                          t_strconcat(username, "@", domain, NULL);
 205          } else {
 206                  domain = strchr(userdomain, '@');
 207                  if (domain == NULL)
 208                          username = userdomain;
 209                  else {
 210                          username = t_strdup_until(userdomain, domain);
 211                          domain++;
 212                  }
 213          }
 214          if (*userdomain == '\0') {
 215                  mail_storage_set_error(_storage, MAIL_ERROR_PARAMS,
 216                                         "Empty username doesn't exist");
 217                  return -1;
 218          }
 219   
 220          /* expand the namespace prefix and see if it already exists.
 221             this should normally happen only when the mailbox is being opened */
 222          tab = t_malloc(sizeof(static_tab));
 223          memcpy(tab, static_tab, sizeof(static_tab));
 224          tab[0].value = userdomain;
 225          tab[1].value = username;
 226          tab[2].value = domain;
 227   
 228          prefix = t_str_new(128);
 229          str_append(prefix, _storage->ns->prefix);
 230          var_expand(prefix, storage->ns_prefix_pattern, tab);
 231   
 232[+]         ns = mail_namespace_find_prefix(user->namespaces, str_c(prefix));
 233          if (ns != NULL) {
 234                  *_name = mail_namespace_fix_sep(ns, name);
 235                  *ns_r = ns;
 236                  return 0;
 237          }
 238   
 239          owner = mail_user_init(userdomain);
 240          if (!var_has_key(storage->location, 'h', "home"))
 241                  ret = 1;
 242          else {
 243                  /* we'll need to look up the user's home directory */
 244                  if ((ret = mail_user_get_home(owner, &tab[3].value)) < 0) {
 245                          mail_storage_set_critical(_storage, "Namespace '%s': "
 246                                  "Could not lookup home for user %s",
 247                                  _storage->ns->prefix, userdomain);
 248                          mail_user_unref(&owner);
 249                          return -1;
 250                  }
 251          }
 252   
 253          /* create the new namespace */
 254          ns = i_new(struct mail_namespace, 1);
 255          ns->type = NAMESPACE_SHARED;
 256          ns->user = user;
 257          ns->prefix = i_strdup(str_c(prefix));
 258          ns->owner = owner;
 259          ns->flags = (NAMESPACE_FLAG_SUBSCRIPTIONS & _storage->ns->flags) |
 260                  NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_HIDDEN |
 261                  NAMESPACE_FLAG_AUTOCREATED | NAMESPACE_FLAG_INBOX;
 262          ns->sep = _storage->ns->sep;
 263   
 264          location = t_str_new(256);
 265          if (ret > 0)
 266                  var_expand(location, storage->location, tab);
 267          else {
 268                  get_nonexisting_user_location(storage, userdomain, location);
 269                  ns->flags |= NAMESPACE_FLAG_UNUSABLE;
 270          }
 271          if (mail_storage_create(ns, NULL, str_c(location), _storage->flags,
 272[+]                                 _storage->lock_method, &error) < 0) {
expand/collapse

mail_storage_create

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/mail-storage.c)expand/collapse
Show more  
 160  int mail_storage_create(struct mail_namespace *ns, const char *driver,
 161                          const char *data, enum mail_storage_flags flags,
 162                          enum file_lock_method lock_method,
 163                          const char **error_r)
 164  {
 165          struct mail_storage *storage_class, *storage = NULL;
 166          struct mail_storage *const *classes;
 167          const char *home, *value;
 168          unsigned int i, count;
 169   
 170          if (data == NULL)
 171                  data = "";
 172          else if (driver == NULL)
 173                  mail_storage_set_autodetection(&data, &driver, &flags);
 174   
 175          if (*data == '\0' && driver == NULL) {
 176                  /* use the first driver that works */
 177[+]                 classes = array_get(&storages, &count);
 178          } else if (driver == NULL) {
 179                  storage_class = mail_storage_autodetect(data, flags);
 180                  if (storage_class == NULL) {
 181                          *error_r = t_strdup_printf(
 182                                  "Ambiguous mail location setting, "
 183                                  "don't know what to do with it: %s "
 184                                  "(try prefixing it with mbox: or maildir:)",
 185                                  data);
 186                          return -1;
 187                  }
 188                  classes = &storage_class;
 189                  count = 1;
 190          } else {
 191                  storage_class = mail_storage_find_class(driver);
 192                  if (storage_class == NULL) {
 193                          *error_r = t_strdup_printf(
 194                                  "Unknown mail storage driver %s", driver);
 195                          return -1;
 196                  }
 197                  classes = &storage_class;
 198                  count = 1;
 199          }
 200   
 201          for (i = 0; i < count; i++) {
 202                  storage = classes[i]->v.alloc();
 203                  storage->flags = flags;
 204                  storage->lock_method = lock_method;
 205                  storage->ns = ns;
 206   
 207                  storage->callbacks =
 208                          p_new(storage->pool, struct mail_storage_callbacks, 1);
 209                  p_array_init(&storage->module_contexts, storage->pool, 5);
 210   
 211                  if (classes[i]->v.create(storage, data, error_r) == 0)
 212                          break;
 213   
 214                  if ((flags & MAIL_STORAGE_FLAG_DEBUG) != 0 && count > 1) {
 215                          i_info("%s: Couldn't create mail storage %s: %s",
 216                                 classes[i]->name, data, *error_r);
 217                  }
 218   
 219                  /* try the next one */
 220                  pool_unref(&storage->pool);
 221          }
 222          if (i == count) {
 223                  if (count <= 1) {
 224                          *error_r = t_strdup_printf("%s: %s", classes[0]->name,
 225                                                     *error_r);
Show more  
Show more  




Change Warning 7505.24967 : Uninitialized Variable

Priority:
State:
Finding:
Owner:
Note: