]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Remove t_malloc in favour of t_malloc_no0
authorMartti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
Tue, 17 May 2016 07:35:35 +0000 (10:35 +0300)
committerGitLab <gitlab@git.dovecot.net>
Mon, 30 May 2016 18:35:24 +0000 (21:35 +0300)
Using either t_malloc_no0 or t_malloc0 makes it clear whether the
allocated memory is zeroed or not.

38 files changed:
src/auth/auth-request-var-expand.c
src/auth/password-scheme.c
src/doveadm/doveadm-dsync.c
src/doveadm/doveadm-dump-log.c
src/imap-hibernate/imap-client.c
src/imap/imap-client.c
src/lib-http/http-transfer-chunked.c
src/lib-imap/imap-date.c
src/lib-imap/imap-utf7.c
src/lib-index/test-mail-index-sync-ext.c
src/lib-lda/mail-deliver.c
src/lib-lda/mail-send.c
src/lib-mail/mail-user-hash.c
src/lib-ssl-iostream/iostream-openssl-common.c
src/lib-ssl-iostream/iostream-openssl.c
src/lib-storage/index/shared/shared-storage.c
src/lib-storage/mail-storage-service.c
src/lib-storage/mailbox-list.c
src/lib/data-stack.c
src/lib/data-stack.h
src/lib/hex-binary.c
src/lib/mempool-datastack.c
src/lib/mempool-unsafe-datastack.c
src/lib/net.c
src/lib/strfuncs.c
src/lib/test-data-stack.c
src/lib/test-istream-concat.c
src/lib/test-istream-seekable.c
src/lib/var-expand.c
src/login-common/client-common.c
src/login-common/login-settings.c
src/login-common/ssl-proxy-openssl.c
src/plugins/acl/acl-shared-storage.c
src/plugins/fts-squat/squat-trie.c
src/plugins/fts-squat/squat-uidlist.c
src/pop3/pop3-client.c
src/pop3/pop3-commands.c
src/ssl-params/ssl-params.c

index f1f041e473b99270a2cb9580bb5c732761dc4e56..3b0013601ea347ac52fb00fbb80ee4162393a014 100644 (file)
@@ -78,7 +78,7 @@ auth_request_get_var_expand_table_full(const struct auth_request *auth_request,
 
        /* keep the extra fields at the beginning. the last static_tab field
           contains the ending NULL-fields. */
-       tab = ret_tab = t_malloc((*count + auth_count) * sizeof(*tab));
+       tab = ret_tab = t_malloc_no0((*count + auth_count) * sizeof(*tab));
        memset(tab, 0, *count * sizeof(*tab));
        tab += *count;
        *count += auth_count;
index 1633e50b1ea8947f2f388e6c14c519e0af613712..bdff0f11424aaf301eb93d43f56d18e64e6fcc3f 100644 (file)
@@ -262,7 +262,7 @@ const char *password_generate_salt(size_t len)
        unsigned int i;
        char *salt;
 
-       salt = t_malloc(len + 1);
+       salt = t_malloc_no0(len + 1);
        random_fill(salt, len);
        for (i = 0; i < len; i++)
                salt[i] = salt_chars[salt[i] % (sizeof(salt_chars)-1)];
@@ -400,7 +400,7 @@ sha1_generate(const char *plaintext, const char *user ATTR_UNUSED,
 {
        unsigned char *digest;
 
-       digest = t_malloc(SHA1_RESULTLEN);
+       digest = t_malloc_no0(SHA1_RESULTLEN);
        sha1_get_digest(plaintext, strlen(plaintext), digest);
 
        *raw_password_r = digest;
@@ -413,7 +413,7 @@ sha256_generate(const char *plaintext, const char *user ATTR_UNUSED,
 {
        unsigned char *digest;
 
-       digest = t_malloc(SHA256_RESULTLEN);
+       digest = t_malloc_no0(SHA256_RESULTLEN);
        sha256_get_digest(plaintext, strlen(plaintext), digest);
 
        *raw_password_r = digest;
@@ -426,7 +426,7 @@ sha512_generate(const char *plaintext, const char *user ATTR_UNUSED,
 {
        unsigned char *digest;
 
-       digest = t_malloc(SHA512_RESULTLEN);
+       digest = t_malloc_no0(SHA512_RESULTLEN);
        sha512_get_digest(plaintext, strlen(plaintext), digest);
 
        *raw_password_r = digest;
@@ -441,7 +441,7 @@ ssha_generate(const char *plaintext, const char *user ATTR_UNUSED,
        unsigned char *digest, *salt;
        struct sha1_ctxt ctx;
 
-       digest = t_malloc(SHA1_RESULTLEN + SSHA_SALT_LEN);
+       digest = t_malloc_no0(SHA1_RESULTLEN + SSHA_SALT_LEN);
        salt = digest + SHA1_RESULTLEN;
        random_fill(salt, SSHA_SALT_LEN);
 
@@ -482,7 +482,7 @@ ssha256_generate(const char *plaintext, const char *user ATTR_UNUSED,
        unsigned char *digest, *salt;
        struct sha256_ctx ctx;
 
-       digest = t_malloc(SHA256_RESULTLEN + SSHA256_SALT_LEN);
+       digest = t_malloc_no0(SHA256_RESULTLEN + SSHA256_SALT_LEN);
        salt = digest + SHA256_RESULTLEN;
        random_fill(salt, SSHA256_SALT_LEN);
 
@@ -525,7 +525,7 @@ ssha512_generate(const char *plaintext, const char *user ATTR_UNUSED,
        unsigned char *digest, *salt;
        struct sha512_ctx ctx;
 
-       digest = t_malloc(SHA512_RESULTLEN + SSHA512_SALT_LEN);
+       digest = t_malloc_no0(SHA512_RESULTLEN + SSHA512_SALT_LEN);
        salt = digest + SHA512_RESULTLEN;
        random_fill(salt, SSHA512_SALT_LEN);
 
@@ -568,7 +568,7 @@ smd5_generate(const char *plaintext, const char *user ATTR_UNUSED,
        unsigned char *digest, *salt;
        struct md5_context ctx;
 
-       digest = t_malloc(MD5_RESULTLEN + SMD5_SALT_LEN);
+       digest = t_malloc_no0(MD5_RESULTLEN + SMD5_SALT_LEN);
        salt = digest + MD5_RESULTLEN;
        random_fill(salt, SMD5_SALT_LEN);
 
@@ -646,7 +646,7 @@ cram_md5_generate(const char *plaintext, const char *user ATTR_UNUSED,
        struct hmac_context ctx;
        unsigned char *context_digest;
 
-       context_digest = t_malloc(CRAM_MD5_CONTEXTLEN);
+       context_digest = t_malloc_no0(CRAM_MD5_CONTEXTLEN);
        hmac_init(&ctx, (const unsigned char *)plaintext,
                  strlen(plaintext), &hash_method_md5);
        hmac_md5_get_cram_context(&ctx, context_digest);
@@ -677,7 +677,7 @@ digest_md5_generate(const char *plaintext, const char *user,
        }
 
        /* user:realm:passwd */
-       digest = t_malloc(MD5_RESULTLEN);
+       digest = t_malloc_no0(MD5_RESULTLEN);
        str = t_strdup_printf("%s:%s:%s", user, realm, plaintext);
        md5_get_digest(str, strlen(str), digest);
 
@@ -691,7 +691,7 @@ plain_md4_generate(const char *plaintext, const char *user ATTR_UNUSED,
 {
        unsigned char *digest;
 
-       digest = t_malloc(MD4_RESULTLEN);
+       digest = t_malloc_no0(MD4_RESULTLEN);
        md4_get_digest(plaintext, strlen(plaintext), digest);
 
        *raw_password_r = digest;
@@ -704,7 +704,7 @@ plain_md5_generate(const char *plaintext, const char *user ATTR_UNUSED,
 {
        unsigned char *digest;
 
-       digest = t_malloc(MD5_RESULTLEN);
+       digest = t_malloc_no0(MD5_RESULTLEN);
        md5_get_digest(plaintext, strlen(plaintext), digest);
 
        *raw_password_r = digest;
@@ -717,7 +717,7 @@ lm_generate(const char *plaintext, const char *user ATTR_UNUSED,
 {
        unsigned char *digest;
 
-       digest = t_malloc(LM_HASH_SIZE);
+       digest = t_malloc_no0(LM_HASH_SIZE);
        lm_hash(plaintext, digest);
 
        *raw_password_r = digest;
@@ -730,7 +730,7 @@ ntlm_generate(const char *plaintext, const char *user ATTR_UNUSED,
 {
        unsigned char *digest;
 
-       digest = t_malloc(NTLMSSP_HASH_SIZE);
+       digest = t_malloc_no0(NTLMSSP_HASH_SIZE);
        ntlm_v1_hash(plaintext, digest);
 
        *raw_password_r = digest;
@@ -782,7 +782,7 @@ rpa_generate(const char *plaintext, const char *user ATTR_UNUSED,
 {
        unsigned char *digest;
 
-       digest = t_malloc(MD5_RESULTLEN);
+       digest = t_malloc_no0(MD5_RESULTLEN);
        password_generate_rpa(plaintext, digest);
 
        *raw_password_r = digest;
index 92dba0d839e126383cca85c26c529e31e98e76ef..a3e34635b2a7d2ad6ee2e876823e8ca57e184558 100644 (file)
@@ -226,7 +226,7 @@ get_ssh_cmd_args(const char *host, const char *login, const char *mail_user)
        string_t *str, *str2;
        const char *value, *const *args;
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
 
        tab[0].value = mail_user;
index bbcf35b966f01f63aa3d350cca06810571f58d79..9b7e43cbb5208f7f16f721c6e29eba970d6fbd7d 100644 (file)
@@ -520,7 +520,7 @@ static int dump_record(int fd, uint64_t *modseq)
        if (hdr.size < sizeof(hdr)) {
                i_fatal("Invalid header size %u", hdr.size);
        } else if (hdr.size < 1024*1024) {
-               unsigned char *buf = t_malloc(hdr.size);
+               unsigned char *buf = t_malloc_no0(hdr.size);
 
                ret = read(fd, buf, hdr.size - sizeof(hdr));
                if (ret != (ssize_t)(hdr.size - sizeof(hdr))) {
index 4521d0ad688fd7aad16230bda2b91c4ca6fb41ab..c89c0ab3b7872276a02fa2ccf69fc537b41ab379 100644 (file)
@@ -356,7 +356,7 @@ imap_client_get_var_expand_table(struct imap_client *client)
        struct var_expand_table *tab;
        const char *auth_user;
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
 
        tab[0].value = client->state.username;
index 0bbd1d55f2615e68e1d740a051de77e9196dc319..3fdaff773ded54907e2e8c65b433186b0ff8f2f5 100644 (file)
@@ -247,7 +247,7 @@ const char *client_stats(struct client *client)
        struct var_expand_table *tab;
        string_t *str;
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
 
        tab[0].value = dec2str(i_stream_get_absolute_offset(client->input));
index 4d3bd625be0e156189b2828e92424f7bf3696e59..fff71cf931ed3e696085ff8bd56ab7132a0a6238 100644 (file)
@@ -623,7 +623,7 @@ http_transfer_chunked_ostream_sendv(struct ostream_private *stream,
        /* create new iovec */
        prefix = t_strdup_printf("%llx\r\n", (unsigned long long)tcstream->chunk_size);
        iov_count = iov_count_new + 2;
-       iov_new = t_malloc(sizeof(struct const_iovec) * iov_count);
+       iov_new = t_malloc_no0(sizeof(struct const_iovec) * iov_count);
        iov_new[0].iov_base = prefix;
        iov_new[0].iov_len = strlen(prefix);
        memcpy(&iov_new[1], iov, sizeof(struct const_iovec) * iov_count_new);
index 8c86a744057cc2dfbc5d728923d14b23499f39fb..0be4fd23f9e2c0a52eeda72360bcd68f7dadf6a3 100644 (file)
@@ -183,7 +183,7 @@ imap_to_datetime_tm(const struct tm *tm, int timezone_offset)
        char *buf;
 
        /* @UNSAFE: but faster than t_strdup_printf() call.. */
-       buf = t_malloc(27);
+       buf = t_malloc_no0(27);
        imap_to_date_tm(buf, tm);
        buf[11] = ' ';
 
index db530d76723839f54aeb8302da6e529169bac9b7..87ea8194d8357826201c5b3604838129caaf9908 100644 (file)
@@ -82,7 +82,7 @@ int imap_utf8_to_utf7(const char *src, string_t *dest)
 
        /* at least one encoded character */
        str_append_n(dest, src, p-src);
-       utf16 = t_malloc(strlen(p)*2);
+       utf16 = t_malloc_no0(strlen(p)*2);
        while (*p != '\0') {
                if (*p == '&') {
                        str_append(dest, "&-");
index 7a9f29d152e58fa05399e2280cc5d6e3a3233b55..34c7b6d0b279ae1fda75f1bee58acbb9c0fa2174 100644 (file)
@@ -48,7 +48,7 @@ static void test_mail_index_sync_ext_atomic_inc(void)
        ctx.view->map->hdr.record_size = sizeof(struct mail_index_record) + 16;
        ctx.view->map->rec_map = t_new(struct mail_index_record_map, 1);
        ctx.view->map->rec_map->records =
-               t_malloc(ctx.view->map->hdr.record_size);
+               t_malloc_no0(ctx.view->map->hdr.record_size);
        t_array_init(&ctx.view->map->extensions, 4);
        ext = array_append_space(&ctx.view->map->extensions);
        ext->record_offset = sizeof(struct mail_index_record);
index 035a2fa4e8e5af7a1b096594027b6a042e1f1a8a..8ee055b7078229349ff85fa073b64d323bc4a24f 100644 (file)
@@ -74,7 +74,7 @@ mail_deliver_get_log_var_expand_table_full(struct mail_deliver_context *ctx,
        const char *str;
        uoff_t size;
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
 
        tab[0].value = message;
index 359d9e9c2bc768aaa03bcb1d8f3f0acf65125fd2..bf2d404caada9f9717fce53241c8db569c4feaed 100644 (file)
@@ -34,7 +34,7 @@ get_var_expand_table(struct mail *mail, const char *reason,
        struct var_expand_table *tab;
        const char *subject;
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
 
        tab[0].value = "\r\n";
index c29aca0e8a49a3a7b9f85467a738bfd29fc7e567..60b3a8f09bd5c16a4a93e42e2a60439d2af1dc29 100644 (file)
@@ -30,7 +30,7 @@ unsigned int mail_user_hash(const char *username, const char *format)
        } else T_BEGIN {
                string_t *str = t_str_new(128);
 
-               tab = t_malloc(sizeof(static_tab));
+               tab = t_malloc_no0(sizeof(static_tab));
                memcpy(tab, static_tab, sizeof(static_tab));
                tab[0].value = username;
                tab[1].value = t_strcut(username, '@');
index 439ccfd08c7acfd5c7a88503ea4cca7b38369301..52e38c5c697306327c940bd104256a89fa4d4e1d 100644 (file)
@@ -174,7 +174,7 @@ static const char *ssl_err2str(unsigned long err, const char *data, int flags)
        char *buf;
        size_t err_size = 256;
 
-       buf = t_malloc(err_size);
+       buf = t_malloc_no0(err_size);
        buf[err_size-1] = '\0';
        ERR_error_string_n(err, buf, err_size-1);
        ret = buf;
index 0f937b3cc96c28f6e9aeb9bb353c2e924d812e0d..daccb298bcc5cd94b067dfd86553efa3f1307df0 100644 (file)
@@ -664,7 +664,7 @@ openssl_iostream_get_peer_name(struct ssl_iostream *ssl_io)
        if (len < 0)
                name = "";
        else {
-               name = t_malloc(len + 1);
+               name = t_malloc_no0(len + 1);
                if (X509_NAME_get_text_by_NID(X509_get_subject_name(x509),
                                              ssl_io->username_nid,
                                              name, len + 1) < 0)
index 8a4770325fc1c93988cb676f207b36c1c9e03af9..c9717728b17ccf56e70f709fe001fa9709f7d00a 100644 (file)
@@ -235,7 +235,7 @@ int shared_storage_get_namespace(struct mail_namespace **_ns,
 
        /* expand the namespace prefix and see if it already exists.
           this should normally happen only when the mailbox is being opened */
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
        tab[0].value = userdomain;
        tab[1].value = username;
index 1928a3d579f7833e8c48d6e772b01c715f8e6564..b7dae9eb41ebed5edc42b3edfb0fbb10d5e0ac75 100644 (file)
@@ -412,7 +412,7 @@ get_var_expand_table(struct master_service *service,
        };
        struct var_expand_table *tab;
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
 
        tab[0].value = input->username;
index 72dc53087a0d06c8a73b735958dfd9afa9fa2fc3..38fa559db70b2df6c0fe913ec4ca5987dfc2a608 100644 (file)
@@ -739,7 +739,7 @@ const char *mailbox_list_default_get_vname(struct mailbox_list *list,
        if (list_sep != ns_sep || prefix_len > 0) {
                /* @UNSAFE */
                name_len = strlen(vname);
-               ret = t_malloc(prefix_len + name_len + 1);
+               ret = t_malloc_no0(prefix_len + name_len + 1);
                memcpy(ret, list->ns->prefix, prefix_len);
                for (i = 0; i < name_len; i++) {
                        ret[i + prefix_len] =
index 4802110f5b6adc3bfc24a1769b84c264c30a9e75..c9ee52dea6e8a6a0b4534ac3e06d82013b0b3e5b 100644 (file)
@@ -435,7 +435,7 @@ static void *t_malloc_real(size_t size, bool permanent)
        return ret;
 }
 
-void *t_malloc(size_t size)
+void *t_malloc_no0(size_t size)
 {
        return t_malloc_real(size, TRUE);
 }
index 142981dab3fe116e9c1e58e905dd3b495acd63b2..eb5546f3cbccc857de97e210bafb39399c0b4012 100644 (file)
@@ -75,7 +75,7 @@ void t_pop_check(unsigned int *id) ATTR_HOT;
 
    t_malloc() calls never fail. If there's not enough memory left,
    i_panic() will be called. */
-void *t_malloc(size_t size) ATTR_MALLOC ATTR_RETURNS_NONNULL;
+void *t_malloc_no0(size_t size) ATTR_MALLOC ATTR_RETURNS_NONNULL;
 void *t_malloc0(size_t size) ATTR_MALLOC ATTR_RETURNS_NONNULL;
 
 /* Try growing allocated memory. Returns TRUE if successful. Works only
index 0fb89ef1673b5f9d79a503d09522ac0066f5ccd5..16f7868ec70fe9c99ed2ccc2c1c2adf578b3a66f 100644 (file)
@@ -28,7 +28,7 @@ binary_to_hex_case(unsigned char *dest, const unsigned char *data,
 
 const char *binary_to_hex(const unsigned char *data, size_t size)
 {
-       unsigned char *dest = t_malloc(size * 2 + 1);
+       unsigned char *dest = t_malloc_no0(size * 2 + 1);
 
        binary_to_hex_case(dest, data, size, FALSE);
        dest[size*2] = '\0';
@@ -37,7 +37,7 @@ const char *binary_to_hex(const unsigned char *data, size_t size)
 
 const char *binary_to_hex_ucase(const unsigned char *data, size_t size)
 {
-       unsigned char *dest = t_malloc(size * 2 + 1);
+       unsigned char *dest = t_malloc_no0(size * 2 + 1);
 
        binary_to_hex_case(dest, data, size, TRUE);
        dest[size*2] = '\0';
index 2e119190c24c8ed9a9032084fad9b683f7ed1957..0a986af2f1164f3727387bf8f321bd67db11500f 100644 (file)
@@ -123,7 +123,7 @@ static void *pool_data_stack_realloc(pool_t pool, void *mem,
                return mem;
 
        if (!t_try_realloc(mem, new_size)) {
-               new_mem = t_malloc(new_size);
+               new_mem = t_malloc_no0(new_size);
                memcpy(new_mem, mem, old_size);
                mem = new_mem;
        }
index a8e7e20c9b7438ffc1c0b1b141035d67e97a8de0..0e3ee65a8dc929e61010d5ea4327f53a8e95579c 100644 (file)
@@ -82,7 +82,7 @@ static void *pool_unsafe_data_stack_realloc(pool_t pool ATTR_UNUSED,
                return mem;
 
        if (!t_try_realloc(mem, new_size)) {
-               new_mem = t_malloc(new_size);
+               new_mem = t_malloc_no0(new_size);
                memcpy(new_mem, mem, old_size);
                mem = new_mem;
        }
index 6206e654483de38b22c726f2efa56281406ac208..5cfc91b2d512dcf07e21a0ef138011f4540c7e0a 100644 (file)
@@ -651,7 +651,7 @@ int net_gethostbyname(const char *addr, struct ip_addr **ips,
                 count++;
 
         *ips_count = count;
-        *ips = t_malloc(sizeof(struct ip_addr) * count);
+        *ips = t_malloc_no0(sizeof(struct ip_addr) * count);
 
         count = 0;
        for (ai = origai; ai != NULL; ai = ai->ai_next, count++) {
index db877141a54e7ede96ee7321989f5c87a94b82b9..d8d3bc4fc4fe814a4fb922e2994d55396a9a1857 100644 (file)
@@ -313,7 +313,7 @@ const char *t_str_replace(const char *str, char from, char to)
                return str;
 
        len = strlen(str);
-       out = t_malloc(len + 1);
+       out = t_malloc_no0(len + 1);
        for (i = 0; i < len; i++) {
                if (str[i] == from)
                        out[i] = to;
@@ -758,7 +758,7 @@ const char *dec2str(uintmax_t number)
        int pos;
 
        pos = MAX_INT_STRLEN;
-       buffer = t_malloc(pos);
+       buffer = t_malloc_no0(pos);
 
        buffer[--pos] = '\0';
        do {
index 055ac3d57a86812bb4bf3274de5d72596043c484..c870249f6b012b8ad9fa5d738de8a261ac18da79 100644 (file)
@@ -11,7 +11,7 @@ static void test_ds_buffers(void)
                unsigned char *p;
                size_t left = t_get_bytes_available();
                while (left < 10000) {
-                       t_malloc(left); /* force a new block */
+                       t_malloc_no0(left); /* force a new block */
                        left = t_get_bytes_available();
                }
                left -= 64; /* make room for the sentry if DEBUG */
@@ -33,7 +33,7 @@ static void test_ds_buffers(void)
        test_begin("data-stack buffer interruption");
        T_BEGIN {
                void *b = t_buffer_get(1000);
-               void *a = t_malloc(1);
+               void *a = t_malloc_no0(1);
                void *b2 = t_buffer_get(1001);
                test_assert(a == b); /* expected, not guaranteed */
                test_assert(b2 != b);
@@ -47,7 +47,7 @@ static void test_ds_buffers(void)
                for (i = 1; i < bigleft-64; i += rand()%32) T_BEGIN {
                        unsigned char *p, *p2;
                        size_t left;
-                       t_malloc(i);
+                       t_malloc_no0(i);
                        left = t_get_bytes_available();
                        /* The most useful idx for the assert is 'left' */
                        test_assert_idx(left <= bigleft-i, left);
@@ -70,11 +70,11 @@ static void test_ds_realloc()
                unsigned char *p;
                size_t left = t_get_bytes_available();
                while (left < 10000) {
-                       t_malloc(left); /* force a new block */
+                       t_malloc_no0(left); /* force a new block */
                        left = t_get_bytes_available();
                }
                left -= 64; /* make room for the sentry if DEBUG */
-               p = t_malloc(1);
+               p = t_malloc_no0(1);
                p[0] = 1;
                for (i = 2; i <= left; i++) {
                        /* grow it */
@@ -99,12 +99,12 @@ static void test_ds_recurse(int depth, int number, size_t size)
        t_buffer_alloc_type(char *, number);
 
        for (i = 0; i < number; i++) {
-               ps[i] = t_malloc(size/2);
+               ps[i] = t_malloc_no0(size/2);
                bool re = t_try_realloc(ps[i], size);
                i_assert(ps[i] != NULL);
                if (!re) {
                        try_fails++;
-                       ps[i] = t_malloc(size);
+                       ps[i] = t_malloc_no0(size);
                }
                /* drop our own canaries */
                memset(ps[i], tag[0], size);
@@ -177,8 +177,8 @@ enum fatal_test_state fatal_data_stack(int stage)
                test_begin("fatal data-stack underrun");
                t_id = t_push_named("fatal_data_stack underrun");
                size_t left = t_get_bytes_available();
-               p = t_malloc(left-80); /* will fit */
-               p = t_malloc(100); /* won't fit, will get new block */
+               p = t_malloc_no0(left-80); /* will fit */
+               p = t_malloc_no0(100); /* won't fit, will get new block */
                int seek = 0;
                /* Seek back for the canary, don't assume endianness */
                while(seek > -60 &&
@@ -191,15 +191,15 @@ enum fatal_test_state fatal_data_stack(int stage)
                undo_ptr = p + seek;
                undo_data = *undo_ptr;
                *undo_ptr = '*';
-               /* t_malloc will panic block header corruption */
-               (void)t_malloc(10);
+               /* t_malloc_no0 will panic block header corruption */
+               (void)t_malloc_no0(10);
                return FATAL_TEST_FAILURE;
        }
 
        case 1: case 2: {
-               test_begin(stage == 1 ? "fatal t_malloc overrun near" : "fatal t_malloc overrun far");
-               t_id = t_push_named(stage == 1 ? "fatal t_malloc overrun first" : "fatal t_malloc overrun far");
-               unsigned char *p = t_malloc(10);
+               test_begin(stage == 1 ? "fatal t_malloc_no0 overrun near" : "fatal t_malloc_no0 overrun far");
+               t_id = t_push_named(stage == 1 ? "fatal t_malloc_no0 overrun first" : "fatal t_malloc_no0 overrun far");
+               unsigned char *p = t_malloc_no0(10);
                undo_ptr = p + 10 + (stage == 1 ? 0 : 8*4-1); /* presumes sentry size */
                undo_data = *undo_ptr;
                *undo_ptr = '*';
index e61b886886c5aed4d44c41a294b6c243bed89394..059aed4c0176bdcd20c299cb54563cba64a35ae8 100644 (file)
@@ -67,7 +67,7 @@ static bool test_istream_concat_random(void)
        streams = t_new(struct istream *, stream_count + 1);
        for (i = 0, offset = 0; i < stream_count; i++) {
                data_len = rand() % TEST_MAX_ISTREAM_SIZE + 1;
-               w_data = t_malloc(data_len);
+               w_data = t_malloc_no0(data_len);
                for (j = 0; j < data_len; j++)
                        w_data[j] = offset++;
                streams[i] = test_istream_create_data(w_data, data_len);
index 08cc95d8ca58e12dfdab4edcb1f7791b32d4084b..e7fdb9407b3723fcd1f62875f500ff262594149d 100644 (file)
@@ -77,7 +77,7 @@ static void test_istream_seekable_random(void)
        streams = t_new(struct istream *, stream_count + 1);
        for (i = 0, offset = 0; i < stream_count; i++) {
                data_len = rand() % 100 + 1;
-               w_data = t_malloc(data_len);
+               w_data = t_malloc_no0(data_len);
                for (j = 0; j < data_len; j++)
                        w_data[j] = offset++;
                streams[i] = test_istream_create_data(w_data, data_len);
index 5d06cebee05854e35f97492a2132386f8c82d0ec..d334c8ed57779b484f69c4ad74a5dc411f3d9aab 100644 (file)
@@ -61,7 +61,7 @@ m_str_reverse(const char *str, struct var_expand_context *ctx ATTR_UNUSED)
        size_t len = strlen(str);
        char *p, *rev;
 
-       rev = t_malloc(len + 1);
+       rev = t_malloc_no0(len + 1);
        rev[len] = '\0';
 
        for (p = rev + len - 1; *str != '\0'; str++)
index 50307d72702701349229541c45cf8f8d61a02a55..4fde20edfc586c4d9a90c52e4c3a3ce296dfd05b 100644 (file)
@@ -531,7 +531,7 @@ get_var_expand_table(struct client *client)
 {
        struct var_expand_table *tab;
 
-       tab = t_malloc(sizeof(login_var_expand_empty_tab));
+       tab = t_malloc_no0(sizeof(login_var_expand_empty_tab));
        memcpy(tab, login_var_expand_empty_tab,
               sizeof(login_var_expand_empty_tab));
 
@@ -641,7 +641,7 @@ client_get_log_str(struct client *client, const char *msg)
 
        var_expand_table = get_var_expand_table(client);
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
 
        str = t_str_new(256);
index f8945f1694e8898b424a88141588155cbd3ce8c9..05be020c552b112c4ce8474f32c0d81d0633cfd1 100644 (file)
@@ -124,7 +124,7 @@ login_set_var_expand_table(const struct master_service_settings_input *input)
        };
        struct var_expand_table *tab;
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
 
        tab[0].value = net_ip2addr(&input->local_ip);
index 8bdb68b9aa8547087fb314c91dcd64328e721ee5..be2bcdc6a5afb494ca38a5a427f73fa20c3ce98f 100644 (file)
@@ -701,7 +701,7 @@ const char *ssl_proxy_get_peer_name(struct ssl_proxy *proxy)
        if (len < 0)
                name = "";
        else {
-               name = t_malloc(len + 1);
+               name = t_malloc_no0(len + 1);
                if (X509_NAME_get_text_by_NID(X509_get_subject_name(x509),
                                        ssl_username_nid, name, len + 1) < 0)
                        name = "";
index 718573a664775b8e1549f2b5a98eb02b00111cda..e36af1602e0e8aca78c9610241947c723313844a 100644 (file)
@@ -55,7 +55,7 @@ acl_shared_namespace_add(struct mail_namespace *ns,
 
        p = strchr(userdomain, '@');
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
        tab[0].value = userdomain;
        tab[1].value = p == NULL ? userdomain : t_strdup_until(userdomain, p);
index b3d8fa301b8387259cc024c2e28ef96560a5dcb1..bbf6e89121735e1c2de9f6b74cb9d978cd5b60bd 100644 (file)
@@ -658,7 +658,7 @@ node_split_string(struct squat_trie_build_context *ctx, struct squat_node *node)
 
        /* make a copy of the leaf string and convert to normal node by
           removing it. */
-       str = t_malloc(leafstr_len);
+       str = t_malloc_no0(leafstr_len);
        if (!NODE_IS_DYNAMIC_LEAF(node))
                memcpy(str, node->children.static_leaf_string, leafstr_len);
        else {
@@ -892,7 +892,7 @@ squat_data_normalize(struct squat_trie *trie, const unsigned char *data,
        unsigned char *dest;
        unsigned int i;
 
-       dest = t_malloc(size);
+       dest = t_malloc_no0(size);
        for (i = 0; i < size; i++) {
                if (data[i] == replacement_utf8[0] && i + 2 < size &&
                    data[i+1] == replacement_utf8[1] &&
@@ -922,7 +922,7 @@ squat_trie_build_more_real(struct squat_trie_build_context *ctx,
 
        uid = uid * 2 + (type == SQUAT_INDEX_TYPE_HEADER ? 1 : 0);
 
-       char_lengths = t_malloc(size);
+       char_lengths = t_malloc_no0(size);
        data = squat_data_normalize(trie, input, size);
        for (i = 0; i < size; i++) {
                char_lengths[i] = uni_utf8_char_bytes(input[i]);
index 1b7fb1cad19dc43b49610f1c2e9d8e1ed5999161..348dd646d7e12d89b4b43bf293dbea3c89726a4f 100644 (file)
@@ -126,7 +126,7 @@ uidlist_write_array(struct ostream *output, const uint32_t *uid_list,
        base_uid = uid_list[0] & ~UID_LIST_MASK_RANGE;
        datastack = uid_count < 1024*8/SQUAT_PACK_MAX_SIZE;
        if (datastack)
-               uidbuf = t_malloc(SQUAT_PACK_MAX_SIZE * uid_count);
+               uidbuf = t_malloc_no0(SQUAT_PACK_MAX_SIZE * uid_count);
        else
                uidbuf = i_malloc(SQUAT_PACK_MAX_SIZE * uid_count);
        bufp = uidbuf;
index f1752a21db867a747db4e8ecb1ef250435dec082..35b4f74fa39fed9193a3a1714c931648e61d6cfd 100644 (file)
@@ -542,7 +542,7 @@ static const char *client_stats(struct client *client)
        struct var_expand_table *tab;
        string_t *str;
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
 
        tab[0].value = dec2str(client->top_bytes);
index 2fe8a964833ee1548d0a3d9168c6cf39b5c3199e..320d4c10509a94cc1bfcca0c719740d8a56a9fbb 100644 (file)
@@ -598,7 +598,7 @@ pop3_get_uid(struct client *client, struct mail *mail, string_t *str,
                return 0;
        }
 
-       tab = t_malloc(sizeof(static_tab));
+       tab = t_malloc_no0(sizeof(static_tab));
        memcpy(tab, static_tab, sizeof(static_tab));
        tab[0].value = t_strdup_printf("%u", client->uid_validity);
 
index be44693d61eaef34cd3adafbe2a4254033241d9f..04ba39e569a680308dd9eee60b1c1208e2f2dd8c 100644 (file)
@@ -214,7 +214,7 @@ static int ssl_params_read(struct ssl_params *param)
                return -1;
        }
 
-       buffer = t_malloc(st.st_size);
+       buffer = t_malloc_no0(st.st_size);
        ret = read_full(fd, buffer, st.st_size);
        if (ret < 0)
                i_error("read(%s) failed: %m", param->path);