]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Clean up MAX_INT_STRLEN usage
authorJosef 'Jeff' Sipek <jeff.sipek@open-xchange.com>
Tue, 23 Jul 2019 12:05:02 +0000 (08:05 -0400)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 5 Sep 2019 09:26:10 +0000 (09:26 +0000)
A number of MAX_INT_STRLEN consumers did not realize that it already
includes space for the trailing nul.

src/lib/file-lock.c
src/lib/iostream-rawlog.c
src/plugins/autocreate/autocreate-plugin.c
src/plugins/expire/doveadm-expire.c
src/plugins/expire/expire-plugin.c
src/plugins/fts/fts-storage.c
src/plugins/quota/quota-maildir.c
src/plugins/quota/quota.c

index ab8a2d9b5e26a01b6fc13639005238c33e2891c2..a34ca5f066f2dd6ada2cebae104ed51b57290388 100644 (file)
@@ -97,7 +97,7 @@ file_lock_find_proc_locks(int lock_fd ATTR_UNUSED)
 #ifdef __linux__
        static bool have_proc_locks = TRUE;
        struct stat st;
-       char node_buf[MAX_INT_STRLEN*3 + 2 + 1];
+       char node_buf[MAX_INT_STRLEN * 3 + 2];
        struct istream *input;
        const char *line, *lock_type = "";
        pid_t pid = 0;
index fcde45d5c9fbe787fd215f84773fad846eae9387..5805c9b30d89d6ee3f4e356960c319ad7df2c215 100644 (file)
@@ -24,7 +24,7 @@
 static void
 rawlog_write_timestamp(struct rawlog_iostream *rstream, bool line_ends)
 {
-       unsigned char data[MAX_INT_STRLEN + 6 + 1 + 3];
+       unsigned char data[MAX_INT_STRLEN + 1 + 6 + 1 + 3];
        buffer_t buf;
 
        if ((rstream->flags & IOSTREAM_RAWLOG_FLAG_TIMESTAMP) == 0)
index 8115761328c78ca43a498a0c672328b97f4c4c8f..47c71ae6e8200ed9c69f2cf15f5a1cdb0025c9e8 100644 (file)
@@ -74,7 +74,7 @@ read_autobox_settings(struct mail_user *user, const char *env_name_base,
                      bool subscriptions)
 {
        const char *value;
-       char env_name[13+MAX_INT_STRLEN+1];
+       char env_name[strlen(env_name_base) + MAX_INT_STRLEN];
        unsigned int i = 1;
 
        value = mail_user_plugin_getenv(user, env_name_base);
index b6aab1a6fa9b7930768d1762457b155e498e4942..492f30582398e11f13aa879817b38cc50c4e9cc2 100644 (file)
@@ -171,7 +171,7 @@ static const char *const *doveadm_expire_get_patterns(void)
 {
        ARRAY_TYPE(const_string) patterns;
        const char *str;
-       char set_name[6+MAX_INT_STRLEN+1];
+       char set_name[6 + MAX_INT_STRLEN];
        unsigned int i;
 
        t_array_init(&patterns, 16);
index 89bbddd28c860f6bfd70f90002611342d8cfb6c1..6dd713b8293b0bef9b7282cddefb576137b01300 100644 (file)
@@ -382,7 +382,7 @@ static const char *const *expire_get_patterns(struct mail_user *user)
 {
        ARRAY_TYPE(const_string) patterns;
        const char *str;
-       char set_name[6+MAX_INT_STRLEN+1];
+       char set_name[6 + MAX_INT_STRLEN];
        unsigned int i;
 
        t_array_init(&patterns, 16);
index 2cecce864f1653adba3fc51f5c1949c182df03fb..a4984c69a964e554a762feca44aeb8ebb3e6f362 100644 (file)
@@ -802,7 +802,7 @@ static const char *const *fts_exclude_get_patterns(struct mail_user *user)
 {
        ARRAY_TYPE(const_string) patterns;
        const char *str;
-       char set_name[21+MAX_INT_STRLEN+1];
+       char set_name[21 + MAX_INT_STRLEN];
        unsigned int i;
 
        str = mail_user_plugin_getenv(user, "fts_autoindex_exclude");
index 1276500d9293446a2e4458dbc5ebd68d3a475f37..015bab841e46b5c79987630e089269ac47221c31 100644 (file)
@@ -724,7 +724,7 @@ maildirquota_refresh(struct maildir_quota_root *root, bool *recalculated_r,
 static int maildirsize_update(struct maildir_quota_root *root,
                              int count_diff, int64_t bytes_diff)
 {
-       char str[MAX_INT_STRLEN*2 + 2 + 1];
+       char str[MAX_INT_STRLEN * 2 + 2];
        int ret = 0;
 
        if (count_diff == 0 && bytes_diff == 0)
index 2bd54cebcdfc377a8495ce4c0dc4a6ee163565f5..cc3ea562b9555243f798baaf632090728792795a 100644 (file)
@@ -302,7 +302,7 @@ int quota_user_read_settings(struct mail_user *user,
                             const char **error_r)
 {
        struct quota_settings *quota_set;
-       char root_name[5 + MAX_INT_STRLEN + 1];
+       char root_name[5 + MAX_INT_STRLEN];
        const char *env, *error;
        unsigned int i;
        pool_t pool;