Skip to content

Commit

Permalink
lib-storage: remove attribute accessibility checks
Browse files Browse the repository at this point in the history
index_storage_attribute_{set,get} should assume that the caller performed
due diligence and checked whether or not the user is allowed to store under
the key.
  • Loading branch information
Josef 'Jeff' Sipek authored and GitLab committed Sep 14, 2016
1 parent ee06e0a commit d1147c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
15 changes: 2 additions & 13 deletions src/lib-storage/index/index-attribute.c
Expand Up @@ -192,21 +192,14 @@ index_storage_attribute_get_dict_trans(struct mailbox_transaction_context *t,
int index_storage_attribute_set(struct mailbox_transaction_context *t,
enum mail_attribute_type type, const char *key,
const struct mail_attribute_value *value,
bool internal_attribute)
bool unused ATTR_UNUSED)
{
struct dict_transaction_context *dtrans;
const char *mailbox_prefix;
bool pvt = type == MAIL_ATTRIBUTE_TYPE_PRIVATE;
time_t ts = value->last_change != 0 ? value->last_change : ioloop_time;
int ret = 0;

if (!internal_attribute &&
!MAILBOX_ATTRIBUTE_KEY_IS_USER_ACCESSIBLE(key)) {
mail_storage_set_error(t->box->storage, MAIL_ERROR_PARAMS,
"Internal attributes cannot be changed directly");
return -1;
}

if (index_storage_attribute_get_dict_trans(t, type, &dtrans,
&mailbox_prefix) < 0)
return -1;
Expand Down Expand Up @@ -234,18 +227,14 @@ int index_storage_attribute_set(struct mailbox_transaction_context *t,
int index_storage_attribute_get(struct mailbox *box,
enum mail_attribute_type type, const char *key,
struct mail_attribute_value *value_r,
bool internal_attribute)
bool unused ATTR_UNUSED)
{
struct dict *dict;
const char *mailbox_prefix, *error;
int ret;

memset(value_r, 0, sizeof(*value_r));

if (!internal_attribute &&
!MAILBOX_ATTRIBUTE_KEY_IS_USER_ACCESSIBLE(key))
return 0;

if (index_storage_get_dict(box, type, &dict, &mailbox_prefix) < 0)
return -1;

Expand Down
4 changes: 2 additions & 2 deletions src/lib-storage/index/index-storage.h
Expand Up @@ -114,11 +114,11 @@ int index_mailbox_get_physical_size(struct mailbox *box,
int index_storage_attribute_set(struct mailbox_transaction_context *t,
enum mail_attribute_type type, const char *key,
const struct mail_attribute_value *value,
bool internal_attribute);
bool unused);
int index_storage_attribute_get(struct mailbox *box,
enum mail_attribute_type type, const char *key,
struct mail_attribute_value *value_r,
bool internal_attribute);
bool unused);
struct mailbox_attribute_iter *
index_storage_attribute_iter_init(struct mailbox *box,
enum mail_attribute_type type,
Expand Down

0 comments on commit d1147c2

Please sign in to comment.