commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, stream-cleanup, updated. rel-2_1-106-gafbdbd


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, stream-cleanup, updated. rel-2_1-106-gafbdbd8
Date: Sat, 28 Aug 2010 23:36:23 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=afbdbd89e1edd58916bf504ffc41f0884a6992c9

The branch, stream-cleanup has been updated
       via  afbdbd89e1edd58916bf504ffc41f0884a6992c9 (commit)
       via  a9608e62e3a82b2d97f4c2594370dfeb217865c9 (commit)
       via  f8f17dc3083536dee2ea16e1d3ce1ee8cf0d2045 (commit)
       via  eea4191dbfe090237da49c01fb3b9924a1216621 (commit)
       via  54602578633b24e84b0caf5be588cdeda8a3bd5c (commit)
       via  446ba82c52a3b232b1dceb25633852cdf24d4b1a (commit)
       via  2bb67bb6814eb54b6e8466aeef5ce7cac80b853b (commit)
       via  dc579c0356464e7e9ce9d25ab60475703bde52d4 (commit)
      from  19f93a88c9a2cd1bbe66472514db16c13a333984 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit afbdbd89e1edd58916bf504ffc41f0884a6992c9
Author: Sergey Poznyakoff <address@hidden>
Date:   Sun Aug 29 02:36:03 2010 +0300

    Fix mime creation and Sieve reject/redirect actions.
    
    * examples/mta.c (finalize_option): New variable.
    (message_finalize): Don't modify the message if finalize_option
    is 0.
    * include/mailutils/sys/message.h (_mu_message)
    <orig_header_size>: New member.
    * include/mailutils/sys/mime.h (_mu_mime) <part_stream>: New member.
    * libmu_sieve/actions.c (mime_create_reason)
    (mime_create_ds): Use mu_body_get_streamref.
    (mime_create_quote): Use mu_body_get_streamref/mu_message_get_streamref.
    (sieve_action_reject): Set the To: header.
    * mailbox/message.c (mu_message_get_header): Set orig_header_size.
    (mu_message_get_body): Use orig_header_size instead of relying
    on mu_header_size.
    * mailbox/mime.c (_mime_part_size): New static.
    (_mime_body_stream_size): New method.
    (_mime_body_seek): Rename to _mime_body_stream_seek.
    (_mime_body_read): Rewrite and rename to _mime_body_stream_read.
    (_mime_body_ioctl): Rename to _mime_body_stream_ioctl.
    (create_mime_body_stream): Take mu_mime_t as the 2nd parameter.
    Initialize sp->stream.size and sp->mime.
    (_mime_body_size): Rewrite using _mime_part_size.
    (mu_mime_destroy): Destroy part_stream.
    * sieve/testsuite/Redirect: Reflect new mta behavior.
    * sieve/testsuite/Reject: Likewise.

commit a9608e62e3a82b2d97f4c2594370dfeb217865c9
Author: Sergey Poznyakoff <address@hidden>
Date:   Sat Aug 28 23:10:40 2010 +0300

    Further bugfixes.
    
    * libproto/mbox/mbox.c (_msg_stream_setup): Fix abridgement limits.
    (mbox_expunge_unlocked): Don't write extra newline after each
    message.
    * mailbox/stream.c (mu_stream_seek): ESPIPE does not constitute
    a permanent error.

commit f8f17dc3083536dee2ea16e1d3ce1ee8cf0d2045
Author: Sergey Poznyakoff <address@hidden>
Date:   Sat Aug 28 22:42:04 2010 +0300

    Fix mime test.
    
    * mailbox/mime.c (mu_mime_get_part): Fix the end limit for the
    part's abridgement.
    * mailbox/streamref.c (_streamref_seek): Fix ESPIPE condition.

commit eea4191dbfe090237da49c01fb3b9924a1216621
Author: Sergey Poznyakoff <address@hidden>
Date:   Sat Aug 28 18:39:43 2010 +0300

    pop3d: bugfixes.
    
    * include/mailutils/message.h (mu_message_set_stream): Mark as deprecated.
    * pop3d/retr.c (pop3d_retr): Rewind the stream obtained from
    mu_message_get_stream.
    * pop3d/top.c (pop3d_top): Rewind the streams obtained from
    mu_body_get_stream and mu_header_get_stream.

commit 54602578633b24e84b0caf5be588cdeda8a3bd5c
Author: Sergey Poznyakoff <address@hidden>
Date:   Sat Aug 28 16:58:08 2010 +0300

    Fix encode2047 test.
    
    * mailbox/base64.c (_base64_encoder): Fix the use
    of uninitialized variable.
    * mailbox/rfc2047.c (mu_rfc2047_encode): Rewind the
    input stream before reading from it.

commit 446ba82c52a3b232b1dceb25633852cdf24d4b1a
Author: Sergey Poznyakoff <address@hidden>
Date:   Sat Aug 28 16:36:14 2010 +0300

    Fix decode2047 test.
    
    * mailbox/filter_iconv.c (mu_filter_iconv_create): Set filter flags.
    * mailbox/fltstream.c (mu_filter_stream_create): Likewise.
    * mailbox/qpflt.c (_qp_decoder): Handle '_'.

commit 2bb67bb6814eb54b6e8466aeef5ce7cac80b853b
Author: Sergey Poznyakoff <address@hidden>
Date:   Sat Aug 28 16:08:07 2010 +0300

    Fix base64 test.
    
    * examples/base64.c (c_copy): Handle printable mode (-p).
    (reset_line_length): New function.
    (main): New option -lN sets the maximum length for output
    lines to N (0 means unlimited).
    * mailbox/testsuite/mailbox/base64.exp: Use -l0 in the
    Decode test.

commit dc579c0356464e7e9ce9d25ab60475703bde52d4
Author: Sergey Poznyakoff <address@hidden>
Date:   Sat Aug 28 17:22:40 2010 +0300

    Bugfixes
    
    * include/mailutils/header.h (mu_header_invalidate): New proto.
    * mailbox/header.c (mu_header_invalidate): New function.
    
    * libmu_argp/muinit.c (get_canonical_name): Avoid coredumping
    if argp_program_version is NULL.
    * mailbox/base64.c (mu_base64_decode): Fix inconsistent return
    code.
    * mailbox/debug.c (mu_debug_destroy): Allow for debug->stream == NULL.
    
    * mailbox/mapfile_stream.c (_mapfile_truncate): Incorrect size
    was used when unmapping.
    * mailbox/message.c (mu_message_create_copy): Use a temporary
    memory stream.
    (mu_message_get_body): Comment out the check for MESSAGE_INTERNAL_STREAM.
    (_message_get_stream): Initialize message header and body.
    
    * mailbox/progmailer.c (mu_progmailer_send): Check  return
    from the mu_header_get_streamref.
    
    * mailbox/stream.c (_stream_scandelim, _stream_readdelim): If
    size is 0, return MU_ERR_BUFSPACE.

-----------------------------------------------------------------------

Summary of changes:
 examples/base64.c                    |   54 ++++++-
 examples/mta.c                       |   19 ++-
 include/mailutils/header.h           |    1 +
 include/mailutils/message.h          |    4 +-
 include/mailutils/sys/message.h      |    3 +-
 include/mailutils/sys/mime.h         |    1 +
 lib/allocsa.valgrind                 |    7 -
 libmu_argp/muinit.c                  |    6 +-
 libmu_sieve/actions.c                |   33 +++-
 libproto/mbox/mbox.c                 |   12 +--
 mailbox/base64.c                     |    4 +-
 mailbox/debug.c                      |   15 +-
 mailbox/filter_iconv.c               |    1 +
 mailbox/fltstream.c                  |    3 +-
 mailbox/header.c                     |    9 +
 mailbox/mapfile_stream.c             |    2 +-
 mailbox/message.c                    |   65 +++++---
 mailbox/mime.c                       |  190 +++++++++++++-------
 mailbox/progmailer.c                 |   17 ++-
 mailbox/qpflt.c                      |    6 +
 mailbox/rfc2047.c                    |    2 +-
 mailbox/stream.c                     |    6 +
 mailbox/streamref.c                  |    2 +-
 mailbox/testsuite/mailbox/base64.exp |    4 +-
 pop3d/retr.c                         |    5 +-
 pop3d/top.c                          |    8 +-
 sieve/testsuite/Redirect             |   94 +++++-----
 sieve/testsuite/Reject               |  328 +++++++++++++++++-----------------
 28 files changed, 540 insertions(+), 361 deletions(-)
 delete mode 100644 lib/allocsa.valgrind

diff --git a/examples/base64.c b/examples/base64.c
index 3785a6a..cc0a7e8 100644
--- a/examples/base64.c
+++ b/examples/base64.c
@@ -35,7 +35,28 @@ int printable = 0;
 static void
 c_copy (mu_stream_t out, mu_stream_t in)
 {
-  MU_ASSERT (mu_stream_copy (out, in, 0));
+  if (printable)
+    {
+      char c;
+      size_t size;
+      
+      while (mu_stream_read (in, &c, 1, &size) == 0 && size > 0)
+       {
+         int rc;
+         
+         if (printable && !ISPRINT (c))
+           {
+             char outbuf[24];
+             sprintf (outbuf, "\\%03o", (unsigned char) c);
+             rc = mu_stream_write (out, outbuf, strlen (outbuf), NULL);
+           }
+         else
+           rc = mu_stream_write (out, &c, 1, NULL);
+       }
+    }
+  else
+    MU_ASSERT (mu_stream_copy (out, in, 0));
+  mu_stream_write (out, "\n", 1, NULL);
   mu_stream_close (out);
   mu_stream_close (in);
   if (verbose)
@@ -44,6 +65,23 @@ c_copy (mu_stream_t out, mu_stream_t in)
             (unsigned long) mu_stream_bytes_out (out));
 }
 
+/* Set the maximum line length for the filter NAME to LENGTH.
+   FIXME: This is a kludge. Perhaps API should provide a function
+   for that. */
+static void
+reset_line_length (const char *name, size_t length)
+{
+  mu_list_t list;
+  int status;
+  mu_filter_record_t frec;
+  
+  mu_filter_get_list (&list);
+  status = mu_list_locate (list, (void*)name, (void**)&frec);
+  if (status == 0)
+    frec->max_line_length = length;
+  /* don't bail out, leave that to mu_filter_create */
+}
+
 int
 main (int argc, char * argv [])
 {
@@ -54,8 +92,10 @@ main (int argc, char * argv [])
   char *input = NULL, *output = NULL;
   char *encoding = "base64";
   mu_off_t shift = 0;
+  size_t line_length;
+  int line_length_option = 0;
   
-  while ((c = getopt (argc, argv, "deE:hi:o:ps:vw")) != EOF)
+  while ((c = getopt (argc, argv, "deE:hi:l:o:ps:vw")) != EOF)
     switch (c)
       {
       case 'i':
@@ -78,8 +118,13 @@ main (int argc, char * argv [])
        mode = MU_FILTER_ENCODE;
        break;
 
+      case 'l':
+       line_length = strtoul (optarg, NULL, 10);
+       line_length_option = 1;
+       break;
+       
       case 'p':
-       printable = 1; /* FIXME: Not implemented */
+       printable = 1;
        break;
 
       case 's':
@@ -115,6 +160,9 @@ main (int argc, char * argv [])
     MU_ASSERT (mu_stdio_stream_create (&out, MU_STDOUT_FD, 0));
   MU_ASSERT (mu_stream_open (out));
 
+  if (line_length_option)
+    reset_line_length (encoding, line_length);
+  
   if (flags == MU_STREAM_READ)
     {
       MU_ASSERT (mu_filter_create (&flt, in, encoding, mode,
diff --git a/examples/mta.c b/examples/mta.c
index 1604955..4d27774 100644
--- a/examples/mta.c
+++ b/examples/mta.c
@@ -73,6 +73,18 @@ int dot = 1;             /* Message is terminated by a lone 
dot on a line */
 
 mu_address_t recipients = NULL;
 char *progname;
+/* FIXME: If finalize_option is set, mta should try to finalize
+   received messages the way sendmail does, i.e. to add To: or
+   Cc: headers, if they are missing, etc. The code to do so is
+   already included, but the modified message is not reproduced
+   on diagnostic output because mta_send reads it from the stream,
+   which does not reflect modifications to the header.
+
+   Ideally, the mu_message_get_streamref function should notice the
+   change in the header (and/or the body) and return a temporary
+   stream, which will read the modified values.  This is left as
+   as TODO for a later time.                  2010-09-29, Sergey */
+int finalize_option = 0; 
 
 int mta_stdin (int argc, char **argv);
 int mta_smtp (int argc, char **argv);
@@ -361,7 +373,7 @@ message_finalize (mu_message_t msg, int warn)
   
   mu_message_get_header (msg, &header);
 
-  if (warn && from_person)
+  if (finalize_option && warn && from_person)
     {
       struct passwd *pwd = getpwuid (getuid ());
       char *warn = malloc (strlen (pwd->pw_name) + 1 +
@@ -400,7 +412,8 @@ message_finalize (mu_message_t msg, int warn)
          free (value);
        }  
          
-      if (mu_header_aget_value (header, MU_HEADER_BCC, &value) == 0)
+      if (finalize_option &&
+         mu_header_aget_value (header, MU_HEADER_BCC, &value) == 0)
        {
          if (add_recipient (value))
            {
@@ -412,7 +425,7 @@ message_finalize (mu_message_t msg, int warn)
        }  
     }
 
-  if (!have_to)
+  if (finalize_option && !have_to)
     {
       size_t n;
       int c;
diff --git a/include/mailutils/header.h b/include/mailutils/header.h
index d162112..57a1107 100644
--- a/include/mailutils/header.h
+++ b/include/mailutils/header.h
@@ -78,6 +78,7 @@ extern "C" {
 
 extern int mu_header_create (mu_header_t *, const char *, size_t);
 extern void mu_header_destroy (mu_header_t *);
+extern int mu_header_invalidate (mu_header_t);
 
 extern int mu_header_is_modified (mu_header_t);
 extern int mu_header_clear_modified (mu_header_t);
diff --git a/include/mailutils/message.h b/include/mailutils/message.h
index fcc4e5d..8a2416f 100644
--- a/include/mailutils/message.h
+++ b/include/mailutils/message.h
@@ -55,7 +55,9 @@ extern int mu_message_set_body (mu_message_t, mu_body_t, void 
*);
 extern int mu_message_get_stream (mu_message_t, mu_stream_t *)
                                    __attribute__((deprecated));
 extern int mu_message_get_streamref (mu_message_t, mu_stream_t *);
-extern int mu_message_set_stream (mu_message_t, mu_stream_t, void *);
+
+extern int mu_message_set_stream (mu_message_t, mu_stream_t, void *)
+  __attribute__((deprecated));
 
 extern int mu_message_get_attribute (mu_message_t, mu_attribute_t *);
 extern int mu_message_set_attribute (mu_message_t, mu_attribute_t, void *);
diff --git a/include/mailutils/sys/message.h b/include/mailutils/sys/message.h
index 8e30382..ec91372 100644
--- a/include/mailutils/sys/message.h
+++ b/include/mailutils/sys/message.h
@@ -47,7 +47,8 @@ struct _mu_message
   mu_mime_t mime;
   mu_observable_t observable;
   mu_mailbox_t mailbox;
-
+  size_t orig_header_size;
+  
   /* Reference count.  */
   int ref;
 
diff --git a/include/mailutils/sys/mime.h b/include/mailutils/sys/mime.h
index 0feae4f..bc0d652 100644
--- a/include/mailutils/sys/mime.h
+++ b/include/mailutils/sys/mime.h
@@ -64,6 +64,7 @@ struct _mu_mime
   int             boundary_len;
   int             preamble;
   int             postamble;
+  mu_stream_t     part_stream;
   /* parser state */
   char           *cur_line;
   int             line_ndx;
diff --git a/lib/allocsa.valgrind b/lib/allocsa.valgrind
deleted file mode 100644
index f4c77d6..0000000
--- a/lib/allocsa.valgrind
+++ /dev/null
@@ -1,7 +0,0 @@
-# Suppress a valgrind message about use of uninitialized memory in freesa().
-# This use is OK because it provides only a speedup.
-{
-    freesa
-    Memcheck:Cond
-    fun:freesa
-}
diff --git a/libmu_argp/muinit.c b/libmu_argp/muinit.c
index 805fc30..9433fdd 100644
--- a/libmu_argp/muinit.c
+++ b/libmu_argp/muinit.c
@@ -75,8 +75,10 @@ get_canonical_name ()
 {
   char *name;
   size_t len;
-  char *p = strchr (argp_program_version, ' ');
-  if (!p)
+  char *p;
+
+  if (!argp_program_version ||
+      !(p = strchr (argp_program_version, ' ')))
     return strdup (mu_program_name);
   len = p - argp_program_version;
   name = malloc (len + 1);
diff --git a/libmu_sieve/actions.c b/libmu_sieve/actions.c
index 595b6e1..1beb8f9 100644
--- a/libmu_sieve/actions.c
+++ b/libmu_sieve/actions.c
@@ -154,7 +154,7 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const 
char *text)
  
   mu_message_create (&newmsg, NULL);
   mu_message_get_body (newmsg, &body);
-  mu_body_get_stream (body, &stream);
+  mu_body_get_streamref (body, &stream);
 
   time (&t);
   tm = localtime (&t);
@@ -171,6 +171,8 @@ mime_create_reason (mu_mime_t mime, mu_message_t msg, const 
char *text)
   mu_stream_printf (stream, "Reason given was as follows:\n\n");
   mu_stream_printf (stream, "%s", text);
   mu_stream_close (stream);
+  mu_stream_destroy (&stream);
+  
   mu_header_create (&hdr, content_header, strlen (content_header));
   mu_message_set_header (newmsg, hdr, NULL);
   mu_mime_add_part (mime, newmsg);
@@ -196,7 +198,7 @@ mime_create_ds (mu_mime_t mime, mu_message_t orig)
   mu_message_get_header (newmsg, &hdr); 
   mu_header_set_value (hdr, "Content-Type", "message/delivery-status", 1);
   mu_message_get_body (newmsg, &body);
-  mu_body_get_stream (body, &stream);
+  mu_body_get_streamref (body, &stream);
   mu_stream_printf (stream, "Reporting-UA: sieve; %s\n", PACKAGE_STRING);
 
   mu_message_get_envelope (orig, &env);
@@ -226,7 +228,9 @@ mime_create_ds (mu_mime_t mime, mu_message_t orig)
   mu_stream_printf (stream, "Last-Attempt-Date: %s\n", datestr);
 
   mu_stream_close (stream);
-  mu_mime_add_part(mime, newmsg);
+  mu_stream_destroy (&stream);
+  
+  mu_mime_add_part (mime, newmsg);
   mu_message_unref (newmsg);
 }
 
@@ -241,25 +245,30 @@ mime_create_quote (mu_mime_t mime, mu_message_t msg)
   size_t n;
   char buffer[512];
   mu_body_t body;
-    
+  int rc;
+  
   mu_message_create (&newmsg, NULL);
   mu_message_get_header (newmsg, &hdr); 
   mu_header_set_value (hdr, "Content-Type", "message/rfc822", 1);
   mu_message_get_body (newmsg, &body);
-  mu_body_get_stream (body, &ostream);
-  mu_message_get_stream (msg, &istream);
-  
+  mu_body_get_streamref (body, &ostream);
+  mu_message_get_streamref (msg, &istream);
+
+  rc = 0;/* FIXME: use mu_stream_copy */
   while (mu_stream_read (istream, buffer, sizeof buffer - 1, &n) == 0
         && n != 0)
     {
-      int rc = mu_stream_write (ostream, buffer, n, NULL);
+      rc = mu_stream_write (ostream, buffer, n, NULL);
       if (rc)
-       return EIO;
+       break;
     }
+  mu_stream_destroy (&istream);
   mu_stream_close (ostream);
+  mu_stream_destroy (&ostream);
+  
   mu_mime_add_part (mime, newmsg);
   mu_message_unref (newmsg);
-  return 0;
+  return rc;
 }
   
 static int
@@ -292,6 +301,7 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t 
args, mu_list_t tags)
   mu_message_t newmsg;
   char *addrtext;
   mu_address_t from, to;
+  mu_header_t hdr;
   
   mu_sieve_value_t *val = mu_sieve_value_get (args, 0);
   if (!val)
@@ -308,6 +318,9 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t 
args, mu_list_t tags)
   mu_mime_get_message (mime, &newmsg);
 
   mu_sieve_get_message_sender (mach->msg, &addrtext);
+  mu_message_get_header (newmsg, &hdr);
+  mu_header_prepend (hdr, MU_HEADER_TO, addrtext);
+
   rc = mu_address_create (&to, addrtext);
   if (rc)
     {
diff --git a/libproto/mbox/mbox.c b/libproto/mbox/mbox.c
index 98d288d..c81701e 100644
--- a/libproto/mbox/mbox.c
+++ b/libproto/mbox/mbox.c
@@ -298,7 +298,7 @@ _msg_stream_setup (mu_message_t msg, mbox_message_t mum)
   status = mu_streamref_create_abridged (&stream,
                                         mum->mud->mailbox->stream,
                                         mum->envel_from_end,
-                                        mum->body_end);
+                                        mum->body_end - 1);
   if (status == 0)
     status = mu_message_set_stream (msg, stream, mum);
   return status;
@@ -1272,16 +1272,6 @@ mbox_expunge_unlocked (mu_mailbox_t mailbox, size_t 
dirty, int remove_deleted,
              return status;
            }
        }
-
-      status = mu_stream_write (tempstr, "\n", 1, NULL);
-      if (status)
-       {
-         mu_error (_("%s:%d: error writing to temporary stream: %s"),
-                   __FILE__, __LINE__,
-                   mu_strerror (status));
-         return status;
-       }
-
     }
 
   /* Caution: before moving data back to the mailbox see
diff --git a/mailbox/base64.c b/mailbox/base64.c
index fd0131e..8ceba26 100644
--- a/mailbox/base64.c
+++ b/mailbox/base64.c
@@ -88,7 +88,7 @@ mu_base64_decode (const unsigned char *input, size_t 
input_len,
          || input[2] > 127 || ((input[2] != '=') && (b64val[input[2]] == -1))
          || input[3] > 127 || ((input[3] != '=')
                                && (b64val[input[3]] == -1)))
-       return -1;
+       return EINVAL;
       *out++ = (b64val[input[0]] << 2) | (b64val[input[1]] >> 4);
       if (input[2] != '=')
        {
@@ -197,7 +197,7 @@ _base64_encoder (void *xd MU_ARG_UNUSED,
       break;
     }
   
-  if (isize <= 3)
+  if (iobuf->isize <= 3)
     {
       if (cmd == mu_filter_lastbuf)
        pad = 1;
diff --git a/mailbox/debug.c b/mailbox/debug.c
index 4c31674..93fab7c 100644
--- a/mailbox/debug.c
+++ b/mailbox/debug.c
@@ -55,13 +55,16 @@ mu_debug_destroy (mu_debug_t *pdebug, void *owner)
       mu_debug_t debug = *pdebug;
       if (debug->owner == owner)
        {
-         mu_off_t len = 0;
-         int rc = mu_stream_size (debug->stream, &len);
-         if (rc == 0 && len)
-           /* Flush leftover data */
-           mu_debug_printf (debug, 0, "\n");
+         if (debug->stream)
+           {
+             mu_off_t len = 0;
+             int rc = mu_stream_size (debug->stream, &len);
+             if (rc == 0 && len)
+               /* Flush leftover data */
+               mu_debug_printf (debug, 0, "\n");
 
-         mu_stream_destroy (&debug->stream);
+             mu_stream_destroy (&debug->stream);
+           }
          if (debug->destroy)
            debug->destroy (debug->data);
          free (*pdebug);
diff --git a/mailbox/filter_iconv.c b/mailbox/filter_iconv.c
index 8d34285..6674ba4 100644
--- a/mailbox/filter_iconv.c
+++ b/mailbox/filter_iconv.c
@@ -463,6 +463,7 @@ mu_filter_iconv_create (mu_stream_t *s, mu_stream_t 
transport,
   iptr->stream.ctl = _icvt_ioctl;
   iptr->stream.wait = _icvt_wait;
   iptr->stream.seek = _icvt_seek;
+  iptr->stream.flags = MU_STREAM_READ | MU_STREAM_SEEK;
   *s = (mu_stream_t)iptr;
   return 0;
 }
diff --git a/mailbox/fltstream.c b/mailbox/fltstream.c
index 90575a4..8f6260a 100644
--- a/mailbox/fltstream.c
+++ b/mailbox/fltstream.c
@@ -425,7 +425,8 @@ mu_filter_stream_create (mu_stream_t *pflt,
     fs->stream.seek = filter_seek;
   fs->stream.ctl = filter_ctl;
   fs->stream.error_string = filter_error_string;
-
+  fs->stream.flags = flags;
+  
   fs->transport = str;
   fs->xcode = xcode;
   fs->xdata = xdata;
diff --git a/mailbox/header.c b/mailbox/header.c
index 669093c..f49ea86 100644
--- a/mailbox/header.c
+++ b/mailbox/header.c
@@ -911,6 +911,15 @@ mu_header_size (mu_header_t header, size_t *psize)
   return status;
 }
 
+int
+mu_header_invalidate (mu_header_t hdr)
+{
+  if (hdr == NULL)
+    return EINVAL;
+  mu_hdrent_free_list (hdr);
+  return 0;
+}
+
 
 static void
 mu_hdrent_fixup (mu_header_t hdr, struct mu_hdrent *ent)
diff --git a/mailbox/mapfile_stream.c b/mailbox/mapfile_stream.c
index 0b60147..89b3e47 100644
--- a/mailbox/mapfile_stream.c
+++ b/mailbox/mapfile_stream.c
@@ -129,7 +129,7 @@ _mapfile_truncate (mu_stream_t stream, mu_off_t len)
   if (mfs->ptr == MAP_FAILED)
     return EINVAL;
   /* Remap.  */
-  if (mfs->ptr && munmap (mfs->ptr, len) != 0)
+  if (mfs->ptr && munmap (mfs->ptr, mfs->size) != 0)
     {
       int err = errno;
       mfs->ptr = MAP_FAILED;
diff --git a/mailbox/message.c b/mailbox/message.c
index a792ebb..1d95c71 100644
--- a/mailbox/message.c
+++ b/mailbox/message.c
@@ -558,33 +558,36 @@ mu_message_create_copy (mu_message_t *to, mu_message_t 
from)
 {
   int status = 0;
   mu_stream_t fromstr = NULL;
-  mu_stream_t tostr = NULL;
-  size_t n = 0;
-  char buf[512];
+  mu_stream_t tmp = NULL;
 
   if (!to)
     return MU_ERR_OUT_PTR_NULL;
   if (!from)
     return EINVAL;
 
-  if ((status = mu_message_create (to, NULL)))
+  status = mu_memory_stream_create (&tmp, MU_STREAM_RDWR|MU_STREAM_SEEK);
+  if (status)
     return status;
 
-  mu_message_get_streamref (from, &fromstr);
-  mu_message_get_streamref (*to, &tostr);
+  status = mu_message_get_streamref (from, &fromstr);
+  if (status)
+    {
+      mu_stream_destroy (&tmp);
+      return status;
+    }
 
-  status = mu_stream_seek (fromstr, 0, MU_SEEK_SET, NULL);
+  status = mu_stream_copy (tmp, fromstr, 0);
   if (status == 0)
-    while ((status = mu_stream_readline (fromstr, buf, sizeof (buf), &n)) == 0
-          && n > 0)
-      mu_stream_write (tostr, buf, n, NULL);
+    {
+      status = mu_message_create (to, NULL);
+      if (status == 0)
+       mu_message_set_stream (*to, tmp, NULL);
+    }
 
-  mu_stream_destroy (&fromstr);
-  mu_stream_destroy (&tostr);
-  
   if (status)
-    mu_message_destroy (to, NULL);
-  
+    mu_stream_destroy (&tmp);
+  mu_stream_destroy (&fromstr);
+
   return status;
 }
 
@@ -674,6 +677,9 @@ mu_message_get_header (mu_message_t msg, mu_header_t *phdr)
        return status;
       if (msg->stream)
        mu_header_set_fill (header, message_header_fill, msg);
+      status = mu_header_size (header, &msg->orig_header_size);
+      if (status)
+       return status;
       msg->header = header;
     }
   *phdr = msg->header;
@@ -710,21 +716,19 @@ mu_message_get_body (mu_message_t msg, mu_body_t *pbody)
       int status = mu_body_create (&body, msg);
       if (status != 0)
        return status;
-      /* If a stream is already set use it to create the body stream.  */
+      /* If a stream is already set, use it to create the body stream.  */
       /* FIXME: I'm not sure if the second condition is really needed */
-      if (msg->stream && (msg->flags & MESSAGE_INTERNAL_STREAM))
+      if (msg->stream/* && (msg->flags & MESSAGE_INTERNAL_STREAM)*/)
        {
-         size_t size = 0;
          mu_stream_t stream;
          int flags = 0;
-         
-         status = mu_header_size (msg->header, &size);
-         if (status)
-           return status;
+
+         /* FIXME: The actual mu_header_size cannot be used as offset,
+            because the headers might have been modified in between. */
          
          mu_stream_get_flags (msg->stream, &flags);
          status = mu_streamref_create_abridged (&stream, msg->stream,
-                                                size, 0);
+                                                msg->orig_header_size, 0);
          if (status)
            {
              mu_body_destroy (&body, msg);
@@ -779,7 +783,20 @@ _message_get_stream (mu_message_t msg, mu_stream_t 
*pstream, int ref)
 
   if (msg->stream == NULL)
     {
-      int status = _message_stream_create (&msg->stream, msg, MU_STREAM_RDWR);
+      int status;
+      mu_header_t hdr;
+      mu_body_t body;
+
+      /* FIXME: Kind of a kludge: make sure the message has header
+        and body initialized. */
+      status = mu_message_get_header (msg, &hdr);
+      if (status)
+       return status;
+      status = mu_message_get_body (msg, &body);
+      if (status)
+       return status;
+      
+      status = _message_stream_create (&msg->stream, msg, MU_STREAM_RDWR);
       if (status)
        return status;
       msg->flags |= MESSAGE_INTERNAL_STREAM;
diff --git a/mailbox/mime.c b/mailbox/mime.c
index f6f6d75..e1e2145 100644
--- a/mailbox/mime.c
+++ b/mailbox/mime.c
@@ -529,15 +529,52 @@ _mime_set_content_type (mu_mime_t mime)
 }
 
 
+static int
+_mime_part_size (mu_mime_t mime, size_t *psize)
+{
+  int i, ret;
+  size_t size, total = 0;
+
+  if (mime->nmtp_parts == 0)
+    return EINVAL;
+
+  if ((ret = _mime_set_content_type (mime)) != 0)
+    return ret;
+  for (i = 0; i < mime->nmtp_parts; i++)
+    {
+      mu_message_size (mime->mtp_parts[i]->msg, &size);
+      total += size;
+      if (mime->nmtp_parts > 1)        /* boundary line */
+       total += strlen (mime->boundary) + 3;
+    }
+  if (mime->nmtp_parts > 1)    /* ending boundary line */
+    total += 2;
+  *psize = total;
+  return 0;
+}
+
+
 struct _mime_body_stream
 {
   struct _mu_stream stream;
   mu_mime_t mime;
 };
 
+static int
+_mime_body_stream_size (mu_stream_t stream, mu_off_t *psize)
+{
+  struct _mime_body_stream *mstr = (struct _mime_body_stream *)stream;
+  mu_mime_t mime = mstr->mime;
+  size_t sz;
+  int rc = _mime_part_size (mime, &sz);
+  if (rc == 0)
+    *psize = sz;
+  return rc;
+}
+
 /* FIXME: The seek method is defective */
 static int
-_mime_body_seek (mu_stream_t stream, mu_off_t off, mu_off_t *presult)
+_mime_body_stream_seek (mu_stream_t stream, mu_off_t off, mu_off_t *presult)
 {
   struct _mime_body_stream *mstr = (struct _mime_body_stream *)stream;
   mu_mime_t mime = mstr->mime;
@@ -558,30 +595,39 @@ _mime_body_seek (mu_stream_t stream, mu_off_t off, 
mu_off_t *presult)
   return 0;
 }
 
-#define ADD_CHAR(buf, c, offset, buflen, nbytes) do {\
- *(buf)++ = c;\
- (offset)++;\
- (nbytes)++;\
- if (--(buflen) == 0) return 0;\
-} while (0)
+#define ADD_CHAR(buf, c, offset, buflen, total, nbytes)        \
+  do                                                   \
+    {                                                  \
+      *(buf)++ = c;                                    \
+      (offset)++;                                      \
+      (total)++;                                       \
+      if (--(buflen) == 0)                             \
+       {                                               \
+         *(nbytes) = total;                            \
+         return 0;                                     \
+       }                                               \
+    }                                                  \
+  while (0)
 
 static int
-_mime_body_read (mu_stream_t stream, char *buf, size_t buflen, size_t *nbytes)
+_mime_body_stream_read (mu_stream_t stream, char *buf, size_t buflen, size_t 
*nbytes)
 {
   struct _mime_body_stream *mstr = (struct _mime_body_stream *)stream;
   mu_mime_t mime = mstr->mime;
   int                ret = 0;
-  size_t             part_nbytes = 0;
-  mu_stream_t        msg_stream = NULL;
-
+  size_t             total = 0;
+  
   if (mime->nmtp_parts == 0)
     return EINVAL;
-
+  
   if ((ret = _mime_set_content_type (mime)) == 0)
     {
       do
        {
-         mu_stream_destroy (&msg_stream);
+         size_t             part_nbytes = 0;
+
+         if (buflen == 0)
+           break;
          if (mime->nmtp_parts > 1)
            {
              size_t len;
@@ -599,7 +645,8 @@ _mime_body_read (mu_stream_t stream, char *buf, size_t 
buflen, size_t *nbytes)
                  while (mime->preamble)
                    {
                      mime->preamble--;
-                     ADD_CHAR (buf, '-', mime->cur_offset, buflen, *nbytes);
+                     ADD_CHAR (buf, '-', mime->cur_offset, buflen,
+                               total, nbytes);
                    }
                  len = strlen (mime->boundary) - mime->boundary_len;
                  while (mime->boundary_len)
@@ -607,57 +654,89 @@ _mime_body_read (mu_stream_t stream, char *buf, size_t 
buflen, size_t *nbytes)
                      mime->boundary_len--;
                      ADD_CHAR (buf,
                                mime->boundary[len++],
-                               mime->cur_offset, buflen, *nbytes);
+                               mime->cur_offset, buflen,
+                               total, nbytes);
                    }
                  while (mime->postamble)
                    {
                      mime->postamble--;
-                     ADD_CHAR (buf, '-', mime->cur_offset, buflen, *nbytes);
+                     ADD_CHAR (buf, '-', mime->cur_offset, buflen,
+                               total, nbytes);
                    }
                  mime->flags &=
                    ~(MIME_INSERT_BOUNDARY | MIME_ADDING_BOUNDARY);
                  mime->part_offset = 0;
-                 ADD_CHAR (buf, '\n', mime->cur_offset, buflen, *nbytes);
+                 ADD_CHAR (buf, '\n', mime->cur_offset, buflen,
+                           total, nbytes);
+               }
+
+             if (!mime->part_stream)
+               {
+                 if (mime->cur_part >= mime->nmtp_parts)
+                   {
+                     *nbytes = total;
+                     return 0;
+                   }
+                 ret = mu_message_get_streamref 
(mime->mtp_parts[mime->cur_part]->msg,
+                                                 &mime->part_stream);
                }
-             if (mime->cur_part >= mime->nmtp_parts)
-               return 0;
-             mu_message_get_streamref (mime->mtp_parts[mime->cur_part]->msg,
-                                       &msg_stream);
            }
-         else
+         else if (!mime->part_stream)
            {
              mu_body_t part_body;
 
              if (mime->cur_part >= mime->nmtp_parts)
-               return 0;
+               {
+                 *nbytes = total;
+                 return 0;
+               }
              mu_message_get_body (mime->mtp_parts[mime->cur_part]->msg,
                                   &part_body);
-             mu_body_get_streamref (part_body, &msg_stream);
+             ret = mu_body_get_streamref (part_body, &mime->part_stream);
            }
-         mu_stream_seek (msg_stream, mime->part_offset, MU_SEEK_SET, NULL);
-         ret = mu_stream_read (msg_stream, buf, buflen, &part_nbytes);
-         if (part_nbytes)
+         if (ret)
+           break;
+         ret = mu_stream_seek (mime->part_stream, mime->part_offset,
+                               MU_SEEK_SET, NULL);
+         if (ret)
            {
-             mime->part_offset += part_nbytes;
-             mime->cur_offset += part_nbytes;
-             if (nbytes)
-               *nbytes += part_nbytes;
+             mu_stream_destroy (&mime->part_stream);
+             break;
            }
-         if (ret == 0 && part_nbytes == 0)
+         while (buflen > 0 &&
+                (ret = mu_stream_read (mime->part_stream, buf, buflen,
+                                       &part_nbytes)) == 0)
            {
-             mime->flags |= MIME_INSERT_BOUNDARY;
-             mime->cur_part++;
-             ADD_CHAR (buf, '\n', mime->cur_offset, buflen, *nbytes);
+             if (part_nbytes)
+               {
+                 mime->part_offset += part_nbytes;
+                 mime->cur_offset += part_nbytes;
+                 total += part_nbytes;
+                 buflen -= part_nbytes;
+                 buf += part_nbytes;
+               }
+             else 
+               {
+                 mu_stream_destroy (&mime->part_stream);
+                 mime->flags |= MIME_INSERT_BOUNDARY;
+                 mime->cur_part++;
+                 ADD_CHAR (buf, '\n', mime->cur_offset, buflen,
+                           total, nbytes);
+                 break;
+               }
            }
        }
-      while (ret == 0 && part_nbytes == 0
-            && mime->cur_part <= mime->nmtp_parts);
+      while (ret == 0 && mime->cur_part <= mime->nmtp_parts);
     }
+  if (ret)
+    mu_stream_destroy (&mime->part_stream);
+  
+  *nbytes = total;
   return ret;
 }
 
 static int
-_mime_body_ioctl (mu_stream_t stream, int code, void *arg)
+_mime_body_stream_ioctl (mu_stream_t stream, int code, void *arg)
 {
   struct _mime_body_stream *mstr = (struct _mime_body_stream *)stream;
   mu_mime_t mime = mstr->mime;
@@ -687,16 +766,18 @@ _mime_body_ioctl (mu_stream_t stream, int code, void *arg)
 }
 
 static int
-create_mime_body_stream (mu_stream_t *pstr)
+create_mime_body_stream (mu_stream_t *pstr, mu_mime_t mime)
 {
   struct _mime_body_stream *sp =
     (struct _mime_body_stream *)_mu_stream_create (sizeof (*sp),
                                                   MU_STREAM_READ | 
MU_STREAM_SEEK);
   if (!sp)
     return ENOMEM;
-  sp->stream.read = _mime_body_read;
-  sp->stream.seek = _mime_body_seek;
-  sp->stream.ctl = _mime_body_ioctl;
+  sp->stream.read = _mime_body_stream_read;
+  sp->stream.seek = _mime_body_stream_seek;
+  sp->stream.ctl = _mime_body_stream_ioctl;
+  sp->stream.size = _mime_body_stream_size;
+  sp->mime = mime;
   *pstr = (mu_stream_t) sp;
   return 0;
 }
@@ -707,25 +788,7 @@ _mime_body_size (mu_body_t body, size_t *psize)
 {
   mu_message_t       msg = mu_body_get_owner (body);
   mu_mime_t          mime = mu_message_get_owner (msg);
-  int                i, ret;
-  size_t             size;
-
-  if (mime->nmtp_parts == 0)
-    return EINVAL;
-
-  if ((ret = _mime_set_content_type (mime)) != 0)
-    return ret;
-  for (i = 0; i < mime->nmtp_parts; i++)
-    {
-      mu_message_size (mime->mtp_parts[i]->msg, &size);
-      *psize += size;
-      if (mime->nmtp_parts > 1)        /* boundary line */
-       *psize += strlen (mime->boundary) + 3;
-    }
-  if (mime->nmtp_parts > 1)    /* ending boundary line */
-    *psize += 2;
-
-  return 0;
+  return _mime_part_size (mime, psize);
 }
 
 static int
@@ -843,6 +906,7 @@ mu_mime_destroy (mu_mime_t *pmime)
          free (mime->mtp_parts);
        }
       mu_stream_destroy (&mime->stream);
+      mu_stream_destroy (&mime->part_stream);
       if (mime->msg && mime->flags & MIME_NEW_MESSAGE)
        mu_message_destroy (&mime->msg, mime);
       if (mime->content_type)
@@ -887,7 +951,7 @@ mu_mime_get_part (mu_mime_t mime, size_t part, mu_message_t 
*msg)
              ret = mu_streamref_create_abridged (&stream, mime->stream,
                                                  mime_part->offset,
                                                  mime_part->offset +
-                                                    mime_part->len);
+                                                   mime_part->len - 1);
              if (ret == 0)
                {
                  mu_stream_set_flags (stream,
@@ -964,7 +1028,7 @@ mu_mime_get_message (mu_mime_t mime, mu_message_t *msg)
                      mu_message_set_body (mime->msg, body, mime);
                      mu_body_set_size (body, _mime_body_size, mime->msg);
                      mu_body_set_lines (body, _mime_body_lines, mime->msg);
-                     ret = create_mime_body_stream (&body_stream);
+                     ret = create_mime_body_stream (&body_stream, mime);
                      if (ret == 0)
                        {
                          mu_body_set_stream (body, body_stream, mime->msg);
diff --git a/mailbox/progmailer.c b/mailbox/progmailer.c
index 75f0f59..f39440f 100644
--- a/mailbox/progmailer.c
+++ b/mailbox/progmailer.c
@@ -188,8 +188,13 @@ mu_progmailer_send (struct _mu_progmailer *pm, 
mu_message_t msg)
   if (!pm || !msg)
     return EINVAL;
   mu_message_get_header (msg, &hdr);
-  mu_header_get_streamref (hdr, &stream);
-
+  status = mu_header_get_streamref (hdr, &stream);
+  if (status)
+    {
+      MU_DEBUG1 (pm->debug, MU_DEBUG_ERROR,
+                "cannot get header stream: %s\n", mu_strerror (status));
+      return status;
+    }
   MU_DEBUG (pm->debug, MU_DEBUG_TRACE, "Sending headers...\n");
   mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
   while ((status = mu_stream_readline (stream, buffer, sizeof (buffer),
@@ -225,7 +230,13 @@ mu_progmailer_send (struct _mu_progmailer *pm, 
mu_message_t msg)
   
   MU_DEBUG (pm->debug, MU_DEBUG_TRACE, "Sending body...\n");
   mu_message_get_body (msg, &body);
-  mu_body_get_streamref (body, &stream);
+  status = mu_body_get_streamref (body, &stream);
+  if (status)
+    {
+      MU_DEBUG1 (pm->debug, MU_DEBUG_ERROR,
+                "cannot get body stream: %s\n", mu_strerror (status));
+      return status;
+    }
 
   mu_stream_seek (stream, 0, MU_SEEK_SET, NULL);
   while ((status = mu_stream_read (stream, buffer, sizeof (buffer),
diff --git a/mailbox/qpflt.c b/mailbox/qpflt.c
index 4d8db53..aaada1e 100644
--- a/mailbox/qpflt.c
+++ b/mailbox/qpflt.c
@@ -142,6 +142,12 @@ _qp_decoder (void *xd MU_ARG_UNUSED,
                  consumed += 2;
                }
            }
+         else if (c == '_')
+           {
+             *optr++ = ' ';
+             nbytes++;
+             consumed++;
+           }
          else
            {
              *optr++ = c;
diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c
index df19d9f..06d94c2 100644
--- a/mailbox/rfc2047.c
+++ b/mailbox/rfc2047.c
@@ -267,7 +267,7 @@ mu_rfc2047_encode (const char *charset, const char 
*encoding,
     return rc;
   
   mu_stream_write (input_stream, text, strlen (text), NULL);
-
+  mu_stream_seek (input_stream, 0, MU_SEEK_SET, NULL);
   rc = mu_filter_create (&output_stream, input_stream,
                         encoding, MU_FILTER_ENCODE, MU_STREAM_READ);
   if (rc == 0)
diff --git a/mailbox/stream.c b/mailbox/stream.c
index b064421..32db7c6 100644
--- a/mailbox/stream.c
+++ b/mailbox/stream.c
@@ -324,6 +324,8 @@ mu_stream_seek (mu_stream_t stream, mu_off_t offset, int 
whence,
       if ((rc = _stream_flush_buffer (stream, 1)))
        return rc;
       rc = stream->seek (stream, offset, &stream->offset);
+      if (rc == ESPIPE)
+       return rc;
       if (rc)
        return _stream_seterror (stream, rc, 1);
       _stream_cleareof (stream);
@@ -610,6 +612,8 @@ _stream_scandelim (mu_stream_t stream, char *buf, size_t 
size, int delim,
   size_t nread = 0;
   
   size--;
+  if (size == 0)
+    return MU_ERR_BUFSPACE;
   while (size)
     {
       char *p;
@@ -647,6 +651,8 @@ _stream_readdelim (mu_stream_t stream, char *buf, size_t 
size,
   size_t n = 0, rdn;
     
   size--;
+  if (size == 0)
+    return MU_ERR_BUFSPACE;
   for (n = 0;
        n < size && (rc = mu_stream_read (stream, &c, 1, &rdn)) == 0 && rdn;)
     {
diff --git a/mailbox/streamref.c b/mailbox/streamref.c
index 4949a85..dad96c6 100644
--- a/mailbox/streamref.c
+++ b/mailbox/streamref.c
@@ -169,7 +169,7 @@ _streamref_seek (struct _mu_stream *str, mu_off_t off, 
mu_off_t *ppos)
       size -= sp->start;
     }
   
-  if (off < 0 || off >= size)
+  if (off < 0 || off > size)
     return sp->stream.last_err = ESPIPE;
   rc = mu_stream_seek (sp->transport, sp->start + off, MU_SEEK_SET,
                       &sp->offset);
diff --git a/mailbox/testsuite/mailbox/base64.exp 
b/mailbox/testsuite/mailbox/base64.exp
index 64e8168..b86ca6f 100644
--- a/mailbox/testsuite/mailbox/base64.exp
+++ b/mailbox/testsuite/mailbox/base64.exp
@@ -29,7 +29,9 @@ mu_exec -message "encode" -arg -i${srcdir}/Encode \
 
 ## Expect chokes on binary data, so let's switch base64 to printable
 ## octal output.
-mu_exec -message "decode" -arg -i${srcdir}/Decode -arg -dp \
+## The -l0 option ensures that the output is not split by inserting
+## additional newlines.
+mu_exec -message "decode" -arg -i${srcdir}/Decode -arg -dpl0 \
 
"\\000\\001\\002\\003\\004\\005\\006\\007\\010\\011\\012\\013\\014\\015\\016\\017\\020\\021\\022\\023\\024\\025\\026\\027\\030\\031\\032\\033\\034\\035\\036\\037
 
!\"#$%&'()*+,-./0123456789:;<=>address@hidden|}~\\177\\200\\201\\202\\203\\204\\205\\206\\207\\210\\211\\212\\213\\214\\215\\216\\217\\220\\221\\222\\223\\224\\225\\226\\227\\230\\231\\232\\233\\234\\235\\236\\237\\240\\241\\242\\243\\244\\245\\246\\247\\250\\251\\252\\253\\254\\255\\256\\257\\260\\261\\262\\263\\264\\265\\266\\267\\270\\271\\272\\273\\274\\275\\276\\277\\300\\301\\302\\303\\304\\305\\306\\307\\310\\311\\312\\313\\314\\315\\316\\317\\320\\321\\322\\323\\324\\325\\326\\327\\330\\331\\332\\333\\334\\335\\336\\337\\340\\341\\342\\343\\344\\345\\346\\347\\350\\351\\352\\353\\354\\355\\356\\357\\360\\361\\362\\363\\364\\365\\366\\367\\370\\371\\372\\373\\374\\375\\376\\377"
 
 # End of base64.exp
diff --git a/pop3d/retr.c b/pop3d/retr.c
index 8d3030d..c5e44f5 100644
--- a/pop3d/retr.c
+++ b/pop3d/retr.c
@@ -45,7 +45,10 @@ pop3d_retr (char *arg)
     return ERR_MESG_DELE;
 
   /* FIXME: Use crlf filter + mu_stream_copy instead of the loop below */
-  mu_message_get_stream (msg, &stream);
+  if (mu_message_get_stream (msg, &stream)
+      || mu_stream_seek (stream, 0, MU_SEEK_SET, NULL))
+    return ERR_UNKNOWN;
+  
   pop3d_outf ("+OK\r\n");
 
   prev_nl = 1;
diff --git a/pop3d/top.c b/pop3d/top.c
index 0506a64..c51356d 100644
--- a/pop3d/top.c
+++ b/pop3d/top.c
@@ -60,7 +60,9 @@ pop3d_top (char *arg)
   /* Header.  */
   mu_message_get_header (msg, &hdr);
   /* FIXME: Use crlf filter + mu_stream_copy instead of the below loop */
-  mu_header_get_stream (hdr, &stream);
+  if (mu_header_get_stream (hdr, &stream)
+      || mu_stream_seek (stream, 0, MU_SEEK_SET, NULL))
+    return ERR_UNKNOWN;
   n = 0;
   while (mu_stream_readline (stream, buf, sizeof(buf), &n) == 0
         && n > 0)
@@ -82,7 +84,9 @@ pop3d_top (char *arg)
 
       mu_message_get_body (msg, &body);
       /* FIXME: Use the crlf filter + mu_stream_copy */
-      mu_body_get_stream (body, &stream);
+      if (mu_body_get_stream (body, &stream)
+         || mu_stream_seek (stream, 0, MU_SEEK_SET, NULL))
+       return ERR_UNKNOWN;
       n = 0;
       while (mu_stream_readline (stream, buf, sizeof(buf), &n) == 0
             && n > 0 && lines > 0)
diff --git a/sieve/testsuite/Redirect b/sieve/testsuite/Redirect
index 806d86f..3063f3a 100644
--- a/sieve/testsuite/Redirect
+++ b/sieve/testsuite/Redirect
@@ -26,62 +26,56 @@ PATTERN END
 FILE BEGIN
 ENVELOPE FROM: address@hidden
 ENVELOPE TO: <address@hidden>
--re
-   0: X-Authentication-Warning: [^ \t]+ set sender using -f flag
-   1: X-Loop-Prevention: address@hidden
-   2: From: address@hidden
-   3: To: address@hidden
-   4: Subject: I have a present for you
-   5: X-Caffeine: C8H10N4O2
-   6: 
-   7: Look, I'm sorry about the whole anvil thing, and I really
-   8: didn't mean to try and drop it on you from the top of the
-   9: cliff.  I want to try to make it up to you.  I've got some
-  10: great birdseed over here at my place--top of the line
-  11: stuff--and if you come by, I'll have it all wrapped up
-  12: for you.  I'm really sorry for all the problems I've caused
-  13: for you over the years, but I know we can work this out.
-  14: 
-  15: -- 
-  16: Wile E. Coyote   "Super Genius"   address@hidden
-  17: 
+   0: X-Loop-Prevention: address@hidden
+   1: From: address@hidden
+   2: To: address@hidden
+   3: Subject: I have a present for you
+   4: X-Caffeine: C8H10N4O2
+   5: 
+   6: Look, I'm sorry about the whole anvil thing, and I really
+   7: didn't mean to try and drop it on you from the top of the
+   8: cliff.  I want to try to make it up to you.  I've got some
+   9: great birdseed over here at my place--top of the line
+  10: stuff--and if you come by, I'll have it all wrapped up
+  11: for you.  I'm really sorry for all the problems I've caused
+  12: for you over the years, but I know we can work this out.
+  13: 
+  14: -- 
+  15: Wile E. Coyote   "Super Genius"   address@hidden
+  16:
 END OF MESSAGE
 ENVELOPE FROM: address@hidden
 ENVELOPE TO: <address@hidden>
--re
-   0: X-Authentication-Warning: [^ \t]+ set sender using -f flag
-   1: X-Loop-Prevention: address@hidden
-   2: From: address@hidden
-   3: To: address@hidden
-   4: Subject: $$$ YOU, TOO, CAN BE A MILLIONAIRE! $$$
-   5: Date: TBD
-   6: X-Number: 0015
-   7:
-   8: YOU MAY HAVE ALREADY WON TEN MILLION DOLLARS, BUT I DOUBT
-   9: IT!  SO JUST POST THIS TO SIX HUNDRED NEWSGROUPS!  IT WILL
-  10: GUARANTEE THAT YOU GET AT LEAST FIVE RESPONSES WITH MONEY!
-  11: MONEY! MONEY! COLD HARD CASH!  YOU WILL RECEIVE OVER
-  12: $20,000 IN LESS THAN TWO MONTHS!  AND IT'S LEGAL!!!!!!!!!
-  13: !!!!!!!!!!!!!!!!!!111111111!!!!!!!11111111111!!1  JUST
-  14: SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW!
-  15: 
+   0: X-Loop-Prevention: address@hidden
+   1: From: address@hidden
+   2: To: address@hidden
+   3: Subject: $$$ YOU, TOO, CAN BE A MILLIONAIRE! $$$
+   4: Date: TBD
+   5: X-Number: 0015
+   6:
+   7: YOU MAY HAVE ALREADY WON TEN MILLION DOLLARS, BUT I DOUBT
+   8: IT!  SO JUST POST THIS TO SIX HUNDRED NEWSGROUPS!  IT WILL
+   9: GUARANTEE THAT YOU GET AT LEAST FIVE RESPONSES WITH MONEY!
+  10: MONEY! MONEY! COLD HARD CASH!  YOU WILL RECEIVE OVER
+  11: $20,000 IN LESS THAN TWO MONTHS!  AND IT'S LEGAL!!!!!!!!!
+  12: !!!!!!!!!!!!!!!!!!111111111!!!!!!!11111111111!!1  JUST
+  13: SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW!
+  14: 
 END OF MESSAGE
 ENVELOPE FROM: address@hidden
 ENVELOPE TO: <address@hidden>
--re
-   0: X-Authentication-Warning: [^ \t]+ set sender using -f flag
-   1: X-Loop-Prevention: address@hidden
-   2: Received: (from address@hidden)
-   3:  by dontmailme.org id fERKR9N16790
-   4:  for address@hidden; Fri, 28 Dec 2001 22:18:08 +0200
-   5: Date: Fri, 28 Dec 2001 23:28:08 +0200
-   6: From: Bar <address@hidden>
-   7: To: Foo Bar <address@hidden>
-   8: Message-Id: <address@hidden>
-   9: Subject: Coffee
-  10: 
-  11: How about some coffee?
-  12: 
+   0: X-Loop-Prevention: address@hidden
+   1: Received: (from address@hidden)
+   2:  by dontmailme.org id fERKR9N16790
+   3:  for address@hidden; Fri, 28 Dec 2001 22:18:08 +0200
+   4: Date: Fri, 28 Dec 2001 23:28:08 +0200
+   5: From: Bar <address@hidden>
+   6: To: Foo Bar <address@hidden>
+   7: Message-Id: <address@hidden>
+   8: Subject: Coffee
+   9: 
+  10: How about some coffee?
+  11: 
 END OF MESSAGE
 FILE END
 TEST END
diff --git a/sieve/testsuite/Reject b/sieve/testsuite/Reject
index d8ed5e8..0794cd3 100644
--- a/sieve/testsuite/Reject
+++ b/sieve/testsuite/Reject
@@ -26,179 +26,173 @@ PATTERN END
 FILE BEGIN
 ENVELOPE FROM: address@hidden
 ENVELOPE TO: <address@hidden>
-   0: To: <address@hidden>
--re
-   1: X-Authentication-Warning: [^ \t]+ set sender using -f flag
--re
-   2: Content-Type: multipart/mixed; boundary="[0-9:=-]+"
-   3: MIME-Version: 1.0
-   4:
--re
-   5: [0-9:=-]+
-   6: Content-Type: text/plain;charset=UTF-8
-   7: Content-Transfer-Encoding: 8bit
-   8:
--re
-   9: The original message was received at [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 
0-3][0-9] [ 0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]* 
from address@hidden
-  10: Message was refused by recipient's mail filtering program.
-  11: Reason given was as follows:
-  12: 
-  13: I don't want to read these messages.
-  14: 
-  15: Regards.
-  16:
--re
-  17: [0-9:=-]+
-  18: Content-Type: message/delivery-status
-  19:
--re
-  20: Reporting-UA: sieve; GNU Mailutils [0-9][0-9.]*
--re
-  21: Arrival-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
-  22: Final-Recipient: RFC822; address@hidden
-  23: Action: deleted
-  24: Disposition: automatic-action/MDN-sent-automatically;deleted
--re
-  25: Last-Attempt-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
-  26:
--re
-  27: [0-9:=-]+
-  28: Content-Type: message/rfc822
-  29: 
-  30: From: address@hidden
-  31: To: address@hidden
-  32: Subject: I have a present for you
-  33: X-Caffeine: C8H10N4O2
-  34: 
-  35: Look, I'm sorry about the whole anvil thing, and I really
-  36: didn't mean to try and drop it on you from the top of the
-  37: cliff.  I want to try to make it up to you.  I've got some
-  38: great birdseed over here at my place--top of the line
-  39: stuff--and if you come by, I'll have it all wrapped up
-  40: for you.  I'm really sorry for all the problems I've caused
-  41: for you over the years, but I know we can work this out.
-  42: 
-  43: -- 
-  44: Wile E. Coyote   "Super Genius"   address@hidden
-  45:
--re
-  46: [0-9:=-]+
-  47: 
+   0: To: address@hidden
+-re
+   1: Content-Type: multipart/mixed; boundary="[0-9:=-]+"
+   2: MIME-Version: 1.0
+   3:
+-re
+   4: [0-9:=-]+
+   5: Content-Type: text/plain;charset=UTF-8
+   6: Content-Transfer-Encoding: 8bit
+   7:
+-re
+   8: The original message was received at [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 
0-3][0-9] [ 0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]* 
from address@hidden
+   9: Message was refused by recipient's mail filtering program.
+  10: Reason given was as follows:
+  11: 
+  12: I don't want to read these messages.
+  13: 
+  14: Regards.
+  15:
+-re
+  16: [0-9:=-]+
+  17: Content-Type: message/delivery-status
+  18:
+-re
+  19: Reporting-UA: sieve; GNU Mailutils [0-9][0-9.]*
+-re
+  20: Arrival-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
+  21: Final-Recipient: RFC822; address@hidden
+  22: Action: deleted
+  23: Disposition: automatic-action/MDN-sent-automatically;deleted
+-re
+  24: Last-Attempt-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
+  25:
+-re
+  26: [0-9:=-]+
+  27: Content-Type: message/rfc822
+  28: 
+  29: From: address@hidden
+  30: To: address@hidden
+  31: Subject: I have a present for you
+  32: X-Caffeine: C8H10N4O2
+  33: 
+  34: Look, I'm sorry about the whole anvil thing, and I really
+  35: didn't mean to try and drop it on you from the top of the
+  36: cliff.  I want to try to make it up to you.  I've got some
+  37: great birdseed over here at my place--top of the line
+  38: stuff--and if you come by, I'll have it all wrapped up
+  39: for you.  I'm really sorry for all the problems I've caused
+  40: for you over the years, but I know we can work this out.
+  41: 
+  42: -- 
+  43: Wile E. Coyote   "Super Genius"   address@hidden
+  44:
+-re
+  45: [0-9:=-]+
+  46: 
 END OF MESSAGE
 ENVELOPE FROM: address@hidden
 ENVELOPE TO: <address@hidden>
-   0: To: <address@hidden>
--re
-   1: X-Authentication-Warning: [^ \t]+ set sender using -f flag
--re
-   2: Content-Type: multipart/mixed; boundary="[0-9:=-]+"
-   3: MIME-Version: 1.0
-   4:
--re
-   5: [0-9:=-]+
-   6: Content-Type: text/plain;charset=UTF-8
-   7: Content-Transfer-Encoding: 8bit
-   8:
--re
-   9: The original message was received at [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 
0-3][0-9] [ 0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]* 
from address@hidden
-  10: Message was refused by recipient's mail filtering program.
-  11: Reason given was as follows:
-  12: 
-  13: I don't want to read these messages.
-  14: 
-  15: Regards.
-  16:
--re
-  17: [0-9:=-]+
-  18: Content-Type: message/delivery-status
-  19:
--re
-  20: Reporting-UA: sieve; GNU Mailutils [0-9][0-9.]*
--re
-  21: Arrival-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
-  22: Final-Recipient: RFC822; address@hidden
-  23: Action: deleted
-  24: Disposition: automatic-action/MDN-sent-automatically;deleted
--re
-  25: Last-Attempt-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
-  26:
--re
-  27: [0-9:=-]+
-  28: Content-Type: message/rfc822
-  29: 
-  30: From: address@hidden
-  31: To: address@hidden
-  32: Subject: $$$ YOU, TOO, CAN BE A MILLIONAIRE! $$$
-  33: Date: TBD
-  34: X-Number: 0015
-  35:
-  36: YOU MAY HAVE ALREADY WON TEN MILLION DOLLARS, BUT I DOUBT
-  37: IT!  SO JUST POST THIS TO SIX HUNDRED NEWSGROUPS!  IT WILL
-  38: GUARANTEE THAT YOU GET AT LEAST FIVE RESPONSES WITH MONEY!
-  39: MONEY! MONEY! COLD HARD CASH!  YOU WILL RECEIVE OVER
-  40: $20,000 IN LESS THAN TWO MONTHS!  AND IT'S LEGAL!!!!!!!!!
-  41: !!!!!!!!!!!!!!!!!!111111111!!!!!!!11111111111!!1  JUST
-  42: SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW!
-  43:
--re
-  44: [0-9:=-]+
-  45:
+   0: To: address@hidden
+-re
+   1: Content-Type: multipart/mixed; boundary="[0-9:=-]+"
+   2: MIME-Version: 1.0
+   3:
+-re
+   4: [0-9:=-]+
+   5: Content-Type: text/plain;charset=UTF-8
+   6: Content-Transfer-Encoding: 8bit
+   7:
+-re
+   8: The original message was received at [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 
0-3][0-9] [ 0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]* 
from address@hidden
+   9: Message was refused by recipient's mail filtering program.
+  10: Reason given was as follows:
+  11: 
+  12: I don't want to read these messages.
+  13: 
+  14: Regards.
+  15:
+-re
+  16: [0-9:=-]+
+  17: Content-Type: message/delivery-status
+  18:
+-re
+  19: Reporting-UA: sieve; GNU Mailutils [0-9][0-9.]*
+-re
+  20: Arrival-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
+  21: Final-Recipient: RFC822; address@hidden
+  22: Action: deleted
+  23: Disposition: automatic-action/MDN-sent-automatically;deleted
+-re
+  24: Last-Attempt-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
+  25:
+-re
+  26: [0-9:=-]+
+  27: Content-Type: message/rfc822
+  28: 
+  29: From: address@hidden
+  30: To: address@hidden
+  31: Subject: $$$ YOU, TOO, CAN BE A MILLIONAIRE! $$$
+  32: Date: TBD
+  33: X-Number: 0015
+  34:
+  35: YOU MAY HAVE ALREADY WON TEN MILLION DOLLARS, BUT I DOUBT
+  36: IT!  SO JUST POST THIS TO SIX HUNDRED NEWSGROUPS!  IT WILL
+  37: GUARANTEE THAT YOU GET AT LEAST FIVE RESPONSES WITH MONEY!
+  38: MONEY! MONEY! COLD HARD CASH!  YOU WILL RECEIVE OVER
+  39: $20,000 IN LESS THAN TWO MONTHS!  AND IT'S LEGAL!!!!!!!!!
+  40: !!!!!!!!!!!!!!!!!!111111111!!!!!!!11111111111!!1  JUST
+  41: SEND $5 IN SMALL, UNMARKED BILLS TO THE ADDRESSES BELOW!
+  42:
+-re
+  43: [0-9:=-]+
+  44:
 END OF MESSAGE
 ENVELOPE FROM: address@hidden
 ENVELOPE TO: <address@hidden>
-   0: To: <address@hidden>
--re
-   1: X-Authentication-Warning: [^ \t]+ set sender using -f flag
--re
-   2: Content-Type: multipart/mixed; boundary="[0-9:=-]+"
-   3: MIME-Version: 1.0
-   4:
--re
-   5: [0-9:=-]+
-   6: Content-Type: text/plain;charset=UTF-8
-   7: Content-Transfer-Encoding: 8bit
-   8:
--re
-   9: The original message was received at [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 
0-3][0-9] [ 0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]* 
from address@hidden
-  10: Message was refused by recipient's mail filtering program.
-  11: Reason given was as follows:
-  12: 
-  13: I don't want to read these messages.
-  14: 
-  15: Regards.
-  16:
--re
-  17: [0-9:=-]+
-  18: Content-Type: message/delivery-status
-  19:
--re
-  20: Reporting-UA: sieve; GNU Mailutils [0-9][0-9.]*
--re
-  21: Arrival-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
-  22: Final-Recipient: RFC822; address@hidden
-  23: Action: deleted
-  24: Disposition: automatic-action/MDN-sent-automatically;deleted
--re
-  25: Last-Attempt-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
-  26:
--re
-  27: [0-9:=-]+
-  28: Content-Type: message/rfc822
-  29: 
-  30: Received: (from address@hidden)
-  31:  by dontmailme.org id fERKR9N16790
-  32:  for address@hidden; Fri, 28 Dec 2001 22:18:08 +0200
-  33: Date: Fri, 28 Dec 2001 23:28:08 +0200
-  34: From: Bar <address@hidden>
-  35: To: Foo Bar <address@hidden>
-  36: Message-Id: <address@hidden>
-  37: Subject: Coffee
-  38: 
-  39: How about some coffee?
-  40:
--re
-  41: [0-9:=-]+
-  42: 
+   0: To: address@hidden
+-re
+   1: Content-Type: multipart/mixed; boundary="[0-9:=-]+"
+   2: MIME-Version: 1.0
+   3:
+-re
+   4: [0-9:=-]+
+   5: Content-Type: text/plain;charset=UTF-8
+   6: Content-Transfer-Encoding: 8bit
+   7:
+-re
+   8: The original message was received at [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 
0-3][0-9] [ 0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]* 
from address@hidden
+   9: Message was refused by recipient's mail filtering program.
+  10: Reason given was as follows:
+  11: 
+  12: I don't want to read these messages.
+  13: 
+  14: Regards.
+  15:
+-re
+  16: [0-9:=-]+
+  17: Content-Type: message/delivery-status
+  18:
+-re
+  19: Reporting-UA: sieve; GNU Mailutils [0-9][0-9.]*
+-re
+  20: Arrival-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
+  21: Final-Recipient: RFC822; address@hidden
+  22: Action: deleted
+  23: Disposition: automatic-action/MDN-sent-automatically;deleted
+-re
+  24: Last-Attempt-Date: [A-Z][a-z][a-z], [A-Z][a-z][a-z] [ 0-3][0-9] [ 
0-2][0-9]:[0-6][0-9]:[0-6][0-9] [0-9][0-9][0-9][0-9] [a-zA-Z0-9]*
+  25:
+-re
+  26: [0-9:=-]+
+  27: Content-Type: message/rfc822
+  28: 
+  29: Received: (from address@hidden)
+  30:  by dontmailme.org id fERKR9N16790
+  31:  for address@hidden; Fri, 28 Dec 2001 22:18:08 +0200
+  32: Date: Fri, 28 Dec 2001 23:28:08 +0200
+  33: From: Bar <address@hidden>
+  34: To: Foo Bar <address@hidden>
+  35: Message-Id: <address@hidden>
+  36: Subject: Coffee
+  37: 
+  38: How about some coffee?
+  39:
+-re
+  40: [0-9:=-]+
+  41: 
 END OF MESSAGE
 FILE END
 TEST END


hooks/post-receive
-- 
GNU Mailutils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]