Commit e68db773 e68db77391acf334fd6920cbd2c84413dcf5ced0 by Sergey Poznyakoff

Bugfixes.

* mailbox/filter.c (filter_close): Do not close transport stream if
the MU_STREAM_NO_CLOSE flag is set.
* imap4d/fetch.c (fetch_io): Fix memory leak: open the filter
with MU_STREAM_NO_CLOSE flag and destroy it after use.
* include/mailutils/header.h (mu_header_set_stream): Comment out.
There is no such function, but perhaps there should be?

* libproto/mbox/folder.c (_folder_mbox_init): If there is no
explicit path in the URL, use ".".  This makes it possible to
use URLs like: mbox:file.

* mailbox/nls.c (mu_set_locale) [ENABLE_NLS]: Remove ifdef.
Setlocale must be enabled whenever possible, otherwise
we cannot relay on mu_strftime malfunctions in non-english
locales.
* mh/mh_whom.c (mh_alias_expand): Handle NULL or empty inputs.
1 parent dfae7b2b
......@@ -692,7 +692,8 @@ fetch_io (mu_stream_t stream, size_t start, size_t size, size_t max)
size_t n = 0;
mu_off_t offset;
mu_filter_create (&rfc, stream, "rfc822", MU_FILTER_ENCODE, MU_STREAM_READ);
mu_filter_create (&rfc, stream, "rfc822", MU_FILTER_ENCODE,
MU_STREAM_READ|MU_STREAM_NO_CHECK|MU_STREAM_NO_CLOSE);
if (start == 0 && size == (size_t) -1)
{
......@@ -721,6 +722,7 @@ fetch_io (mu_stream_t stream, size_t start, size_t size, size_t max)
}
else if (size + 2 < size) /* Check for integer overflow */
{
mu_stream_destroy (&rfc, NULL);
return RESP_BAD;
}
else
......@@ -751,6 +753,7 @@ fetch_io (mu_stream_t stream, size_t start, size_t size, size_t max)
util_send (" \"\"");
free (buffer);
}
mu_stream_destroy (&rfc, NULL);
return RESP_OK;
}
......
......@@ -149,8 +149,9 @@ extern int mu_header_aget_field_value_unfold (mu_header_t header, size_t num,
char **pvalue);
extern int mu_header_get_stream (mu_header_t, mu_stream_t *);
extern int mu_header_set_stream (mu_header_t, mu_stream_t, void *);
/* FIXME: This function does not exist:
extern int mu_header_set_stream (mu_header_t, mu_stream_t, void *);
*/
extern int mu_header_size (mu_header_t, size_t *);
extern int mu_header_lines (mu_header_t, size_t *);
......
......@@ -159,11 +159,23 @@ _folder_mbox_init (mu_folder_t folder)
return ENOMEM;
status = mu_url_aget_path (folder->url, &dfolder->dirname);
if (status == MU_ERR_NOENT)
{
dfolder->dirname = malloc (2);
if (dfolder->dirname == NULL)
status = ENOMEM;
else
{
strcpy (dfolder->dirname, ".");
status = 0;
}
}
if (status)
{
free (dfolder);
folder->data = NULL;
return ENOMEM;
return status;
}
folder->_destroy = folder_mbox_destroy;
......
......@@ -35,7 +35,7 @@ First draft: Alain Magloire.
#endif
#include <filter0.h>
#include <stream0.h>
#include <mailutils/iterator.h>
#include <mailutils/stream.h>
#include <mailutils/errno.h>
......@@ -124,6 +124,8 @@ static int
filter_close (mu_stream_t stream)
{
mu_filter_t filter = mu_stream_get_owner (stream);
if (stream->flags & MU_STREAM_NO_CLOSE)
return 0;
return mu_stream_close (filter->stream);
}
......@@ -161,7 +163,7 @@ mu_filter_get_list (mu_list_t *plist)
int
mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, const char *name,
int type, int direction)
int type, int direction)
{
mu_iterator_t iterator = NULL;
mu_filter_record_t filter_record = NULL;
......
......@@ -36,7 +36,7 @@ char *mu_locale_set;
char *
mu_set_locale (const char *locale)
{
#if defined HAVE_SETLOCALE && defined ENABLE_NLS
#if defined HAVE_SETLOCALE
return setlocale (LC_ALL, locale);
#else
return NULL;
......
......@@ -59,6 +59,12 @@ mh_alias_expand (const char *str, mu_address_t *paddr, int *incl)
mu_address_t addr;
int status;
if (!str || !*str)
{
*paddr = NULL;
return 0;
}
if (incl)
*incl = 0;
status = mu_address_create_hint (&addr, str, NULL, 0);
......