Skip to content

Commit

Permalink
Replace some t_malloc_no0 calls with t_malloc0
Browse files Browse the repository at this point in the history
This might increase safety.
  • Loading branch information
mrannanj authored and GitLab committed May 30, 2016
1 parent 657d704 commit 11f02cd
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib-imap/imap-date.c
Expand Up @@ -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_no0(27);
buf = t_malloc0(27);
imap_to_date_tm(buf, tm);
buf[11] = ' ';

Expand Down
2 changes: 1 addition & 1 deletion src/lib-imap/imap-utf7.c
Expand Up @@ -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_no0(strlen(p)*2);
utf16 = t_malloc0(strlen(p)*2);
while (*p != '\0') {
if (*p == '&') {
str_append(dest, "&-");
Expand Down
2 changes: 1 addition & 1 deletion src/lib-index/test-mail-index-sync-ext.c
Expand Up @@ -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_no0(ctx.view->map->hdr.record_size);
t_malloc0(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);
Expand Down
3 changes: 1 addition & 2 deletions src/lib-ssl-iostream/iostream-openssl-common.c
Expand Up @@ -174,8 +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_no0(err_size);
buf[err_size-1] = '\0';
buf = t_malloc0(err_size);
ERR_error_string_n(err, buf, err_size-1);
ret = buf;

Expand Down
2 changes: 1 addition & 1 deletion src/lib-ssl-iostream/iostream-openssl.c
Expand Up @@ -664,7 +664,7 @@ openssl_iostream_get_peer_name(struct ssl_iostream *ssl_io)
if (len < 0)
name = "";
else {
name = t_malloc_no0(len + 1);
name = t_malloc0(len + 1);
if (X509_NAME_get_text_by_NID(X509_get_subject_name(x509),
ssl_io->username_nid,
name, len + 1) < 0)
Expand Down
2 changes: 1 addition & 1 deletion src/login-common/ssl-proxy-openssl.c
Expand Up @@ -701,7 +701,7 @@ const char *ssl_proxy_get_peer_name(struct ssl_proxy *proxy)
if (len < 0)
name = "";
else {
name = t_malloc_no0(len + 1);
name = t_malloc0(len + 1);
if (X509_NAME_get_text_by_NID(X509_get_subject_name(x509),
ssl_username_nid, name, len + 1) < 0)
name = "";
Expand Down

0 comments on commit 11f02cd

Please sign in to comment.