commit-mailutils
[Top][All Lists]
Advanced

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

[SCM] GNU Mailutils branch, master, updated. rel-2_1-70-gdbbf8da


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-70-gdbbf8da
Date: Wed, 14 Apr 2010 15:22:27 +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=dbbf8dae0bdd56d108f8bfda7614b4a3b895eae2

The branch, master has been updated
       via  dbbf8dae0bdd56d108f8bfda7614b4a3b895eae2 (commit)
       via  77b116b12786c1f9520e87868528494db61ce8af (commit)
      from  94adc8f49244e0abfd3ac47e0cfb2af2a063adc5 (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 dbbf8dae0bdd56d108f8bfda7614b4a3b895eae2
Author: Sergey Poznyakoff <address@hidden>
Date:   Wed Apr 14 18:23:42 2010 +0300

    Fix memory leaks in filter and filter_iconv code.
    
    * mailbox/filter.c (filter_destroy): Destroy the underlying
    stream, unless flag is given.
    (mu_filter_create): Treat last argument as stream flags.
    * mailbox/filter_iconv.c (_icvt_destroy): Free the icvt_stream
    structure.
    
    * examples/mimetest.c (message_display_parts): Pass
    MU_STREAM_NO_CLOSE to the invocation of mu_filter_create.
    * mail/decode.c (display_submessage): Likewise.
    * mailbox/attachment.c (mu_message_save_attachment): Likewise.
    * mh/mh_list.c (eval_body): Likewise.
    * mh/mhn.c (mhn_message_size, show_internal): Likewise.
    (finish_text_msg): Likewise; call mu_stream_destroy
    
    * imap4d/preauth.c (decode64_buf): remove unnecessary
    call to mu_stream_destroy.
    * libmu_auth/ldap.c (chk_md5, chk_smd5)
    (chk_sha, chk_ssha): Likewise.
    
    * mailbox/mutil.c: Fix indentation.

commit 77b116b12786c1f9520e87868528494db61ce8af
Author: Sergey Poznyakoff <address@hidden>
Date:   Wed Apr 14 18:21:52 2010 +0300

    Fix memory leak in mu_rfc2047_decode.
    
    * mailbox/rfc2047.c (getword): Change signature; return error
    code.
    (mu_rfc2047_decode): Reflect the above change.

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

Summary of changes:
 examples/mimetest.c    |    5 ++++-
 imap4d/preauth.c       |    1 -
 libmu_auth/ldap.c      |    5 -----
 mail/decode.c          |    3 ++-
 mailbox/attachment.c   |    3 ++-
 mailbox/filter.c       |   16 ++++++++++------
 mailbox/filter_iconv.c |    1 +
 mailbox/mutil.c        |    4 ++--
 mailbox/rfc2047.c      |   33 +++++++++++++++++----------------
 mh/mh_list.c           |    3 ++-
 mh/mhn.c               |   13 ++++++++-----
 11 files changed, 48 insertions(+), 39 deletions(-)

diff --git a/examples/mimetest.c b/examples/mimetest.c
index bca97af..923e4d0 100644
--- a/examples/mimetest.c
+++ b/examples/mimetest.c
@@ -251,7 +251,10 @@ message_display_parts (mu_message_t msg, int indent)
           printf ("%*.*sBegin\n", indent, indent, "");
           mu_message_get_body (part, &body);
           mu_body_get_stream (body, &str);
-          mu_filter_create (&str, str, encoding, 0, 0);
+          /* Make sure the original body stream is not closed when
+             str gets destroyed */
+          mu_filter_create (&str, str, encoding, MU_FILTER_DECODE,
+                           MU_STREAM_READ | MU_STREAM_NO_CLOSE);
           offset = 0;
           while (mu_stream_readline (str, buf, sizeof (buf),
                                     offset, &nbytes) == 0 && nbytes)
diff --git a/imap4d/preauth.c b/imap4d/preauth.c
index a9a2a5c..203cb29 100644
--- a/imap4d/preauth.c
+++ b/imap4d/preauth.c
@@ -217,7 +217,6 @@ decode64_buf (const char *name, unsigned char **pbuf, 
size_t *psize)
   mu_stream_sequential_write (str, name, namelen);
   mu_stream_read (flt, (char*) buf, sizeof buf, 0, &size);
   mu_stream_destroy (&flt, NULL);
-  mu_stream_destroy (&str, NULL);
   *pbuf = malloc (size);
   if (!*pbuf)
     return 1;
diff --git a/libmu_auth/ldap.c b/libmu_auth/ldap.c
index 70d3e0f..3fdedfb 100644
--- a/libmu_auth/ldap.c
+++ b/libmu_auth/ldap.c
@@ -602,7 +602,6 @@ chk_md5 (const char *db_pass, const char *pass)
 
   mu_stream_read (flt, (char*) d1, sizeof d1, 0, NULL);
   mu_stream_destroy (&flt, NULL);
-  mu_stream_destroy (&str, NULL);
   
   return memcmp (md5digest, d1, sizeof md5digest) == 0 ?
                   0 : MU_ERR_AUTH_FAILURE;
@@ -629,13 +628,11 @@ chk_smd5 (const char *db_pass, const char *pass)
   if (!d1)
     {
       mu_stream_destroy (&flt, NULL);
-      mu_stream_destroy (&str, NULL);
       return ENOMEM;
     }
   
   mu_stream_read (flt, (char*) d1, size, 0, &size);
   mu_stream_destroy (&flt, NULL);
-  mu_stream_destroy (&str, NULL);
 
   if (size <= 16)
     {
@@ -674,7 +671,6 @@ chk_sha (const char *db_pass, const char *pass)
 
   mu_stream_read (flt, (char*) d1, sizeof d1, 0, NULL);
   mu_stream_destroy (&flt, NULL);
-  mu_stream_destroy (&str, NULL);
   
   return memcmp (sha1digest, d1, sizeof sha1digest) == 0 ?
                   0 : MU_ERR_AUTH_FAILURE;
@@ -701,7 +697,6 @@ chk_ssha (const char *db_pass, const char *pass)
   if (!d1)
     {
       mu_stream_destroy (&flt, NULL);
-      mu_stream_destroy (&str, NULL);
       return ENOMEM;
     }
   
diff --git a/mail/decode.c b/mail/decode.c
index 2eb3a82..4beadc9 100644
--- a/mail/decode.c
+++ b/mail/decode.c
@@ -258,7 +258,8 @@ display_submessage (struct mime_descend_closure *closure, 
void *data)
 
       /* Can we decode.  */
       if (mu_filter_create(&d_stream, b_stream, closure->encoding,
-                          MU_FILTER_DECODE, MU_STREAM_READ) == 0)
+                          MU_FILTER_DECODE, 
+                          MU_STREAM_READ|MU_STREAM_NO_CLOSE) == 0)
        stream = d_stream;
       else
        stream = b_stream;
diff --git a/mailbox/attachment.c b/mailbox/attachment.c
index 26430fc..8f02b4f 100644
--- a/mailbox/attachment.c
+++ b/mailbox/attachment.c
@@ -313,7 +313,8 @@ mu_message_save_attachment (mu_message_t msg, const char 
*filename,
                content_encoding = "7bit";
              ret =
                mu_filter_create (&info->stream, istream, content_encoding,
-                                 MU_FILTER_DECODE, MU_STREAM_READ);
+                                 MU_FILTER_DECODE,
+                                 MU_STREAM_READ | MU_STREAM_NO_CLOSE);
              free (content_encoding_mem);
            }
        }
diff --git a/mailbox/filter.c b/mailbox/filter.c
index 6a2e4d1..e7ad3d2 100644
--- a/mailbox/filter.c
+++ b/mailbox/filter.c
@@ -46,6 +46,8 @@ static void
 filter_destroy (mu_stream_t stream)
 {
   mu_filter_t filter = mu_stream_get_owner (stream);
+  if (!(stream->flags & MU_STREAM_NO_CLOSE))
+    mu_stream_destroy (&filter->stream, mu_stream_get_owner (filter->stream));
   if (filter->_destroy)
     filter->_destroy (filter);
   if (filter->property)
@@ -165,7 +167,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 flags)
 {
   mu_iterator_t iterator = NULL;
   mu_filter_record_t filter_record = NULL;
@@ -204,14 +206,12 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t 
stream, const char *name,
 
   if (found)
     {
-      int flags = 0;
       mu_filter_t filter;
 
       filter = calloc (1, sizeof (*filter));
       if (filter == NULL)
        return ENOMEM;
 
-      mu_stream_get_flags (stream, &flags);
       status = mu_stream_create (pstream, flags | MU_STREAM_NO_CHECK, filter);
       if (status != 0)
        {
@@ -221,7 +221,11 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t 
stream, const char *name,
 
       filter->stream = stream;
       filter->filter_stream = *pstream;
-      filter->direction = (direction == 0) ? MU_STREAM_READ : direction;
+      filter->direction = (flags == 0) ? MU_STREAM_READ
+                             : (flags
+                                & (MU_STREAM_READ |
+                                   MU_STREAM_WRITE |
+                                   MU_STREAM_RDWR));
       filter->type = type;
 
       status = mu_property_create (&(filter->property), filter);
@@ -249,8 +253,8 @@ mu_filter_create (mu_stream_t *pstream, mu_stream_t stream, 
const char *name,
            }
         }
 
-      mu_stream_set_open (*pstream, filter_open, filter );
-      mu_stream_set_close (*pstream, filter_close, filter );
+      mu_stream_set_open (*pstream, filter_open, filter);
+      mu_stream_set_close (*pstream, filter_close, filter);
       mu_stream_set_read (*pstream, filter_read, filter);
       mu_stream_set_readline (*pstream, filter_readline, filter);
       mu_stream_set_write (*pstream, filter_write, filter);
diff --git a/mailbox/filter_iconv.c b/mailbox/filter_iconv.c
index c09d463..e47c5db 100644
--- a/mailbox/filter_iconv.c
+++ b/mailbox/filter_iconv.c
@@ -114,6 +114,7 @@ _icvt_destroy (mu_stream_t stream)
   s->buf = NULL;
   if (s->cd != (iconv_t) -1)
     iconv_close (s->cd);
+  free (s);
 }
 
 static int _icvt_read (mu_stream_t stream, char *optr, size_t osize,
diff --git a/mailbox/mutil.c b/mailbox/mutil.c
index 19dbcc1..70bce58 100644
--- a/mailbox/mutil.c
+++ b/mailbox/mutil.c
@@ -1329,8 +1329,8 @@ mu_decode_filter (mu_stream_t *pfilter, mu_stream_t input,
     {
       mu_stream_t cvt;
       status = mu_filter_iconv_create (&cvt, filter, fromcode, tocode,
-                                   MU_STREAM_NO_CLOSE,
-                                   mu_default_fallback_mode);
+                                      MU_STREAM_NO_CLOSE,
+                                      mu_default_fallback_mode);
       if (status == 0)
        {
          if (mu_stream_open (cvt))
diff --git a/mailbox/rfc2047.c b/mailbox/rfc2047.c
index ba11d58..64327d9 100644
--- a/mailbox/rfc2047.c
+++ b/mailbox/rfc2047.c
@@ -42,23 +42,26 @@ realloc_buffer (char **bufp, size_t *bufsizep, size_t incr)
   return 0;
 }
 
-static char *
-getword (const char **pstr, int delim)
+int
+getword (char **pret, const char **pstr, int delim)
 {
   size_t len;
   char *ret;
   const char *start = *pstr;
   const char *end = strchr (start, delim);
+
+  free (*pret);
   if (!end)
-    return NULL;
+    return MU_ERR_BAD_2047_INPUT;
   len = end - start;
   ret = malloc (len + 1);
   if (!ret)
-    return NULL;
+    return ENOMEM;
   memcpy (ret, start, len);
   ret[len] = 0;
   *pstr = end + 1;
-  return ret;
+  *pret = ret;
+  return 0;
 }
     
 int
@@ -119,23 +122,21 @@ mu_rfc2047_decode (const char *tocode, const char *input, 
char **ptostr)
          const char *sp = fromstr + 2;
          char tmp[128];
          
-         fromcode = getword (&sp, '?');
-         encoding_type = getword (&sp, '?');
-         encoded_text = getword (&sp, '?');
+         status = getword (&fromcode, &sp, '?');
+         if (status)
+           break;
+         status = getword (&encoding_type, &sp, '?');
+         if (status)
+           break;
+         status = getword (&encoded_text, &sp, '?');
+         if (status)
+           break;
          if (sp == NULL || sp[0] != '=')
            {
              status = MU_ERR_BAD_2047_INPUT;
              break;
            }
       
-         if (fromcode == NULL
-             || encoding_type == NULL
-             || encoded_text == NULL)
-           {
-             status = MU_ERR_BAD_2047_INPUT;
-             break;
-           }
-
          size = strlen (encoded_text);
 
          switch (encoding_type[0])
diff --git a/mh/mh_list.c b/mh/mh_list.c
index 489d028..6d8c651 100644
--- a/mh/mh_list.c
+++ b/mh/mh_list.c
@@ -699,7 +699,8 @@ eval_body (struct eval_env *env)
       if (encoding)
        {
          int rc = mu_filter_create(&dstr, input, encoding,
-                                MU_FILTER_DECODE, MU_STREAM_READ);
+                                   MU_FILTER_DECODE, 
+                                   MU_STREAM_READ | MU_STREAM_NO_CLOSE);
          if (rc == 0)
            input = dstr;
          free (encoding);
diff --git a/mh/mhn.c b/mh/mhn.c
index f37d63d..b54d109 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -1122,8 +1122,9 @@ mhn_message_size (mu_message_t msg, size_t *psize)
          mu_message_get_header (msg, &hdr);
          _get_content_encoding (hdr, &encoding);
 
-         rc = mu_filter_create(&dstr, bstr, encoding,
-                               MU_FILTER_DECODE, MU_STREAM_READ);
+         rc = mu_filter_create (&dstr, bstr, encoding,
+                                MU_FILTER_DECODE, 
+                                MU_STREAM_READ | MU_STREAM_NO_CLOSE);
          free (encoding);
          if (rc == 0)
            {
@@ -1272,8 +1273,8 @@ show_internal (mu_message_t msg, msg_part_t part, char 
*encoding, mu_stream_t ou
       return 0;
     }
   mu_body_get_stream (body, &bstr);
-  rc = mu_filter_create(&dstr, bstr, encoding,
-                    MU_FILTER_DECODE, MU_STREAM_READ);
+  rc = mu_filter_create (&dstr, bstr, encoding,
+                        MU_FILTER_DECODE, MU_STREAM_READ | MU_STREAM_NO_CLOSE);
   if (rc == 0)
     bstr = dstr;
   cat_message (out, bstr);
@@ -2052,10 +2053,12 @@ finish_text_msg (struct compose_env *env, mu_message_t 
*msg, int ascii)
       mu_message_get_body (*msg, &body);
       mu_body_get_stream (body, &input);
       rc = mu_filter_create (&fstr, input, "quoted-printable",
-                            MU_FILTER_ENCODE, MU_STREAM_READ);
+                            MU_FILTER_ENCODE, 
+                            MU_STREAM_READ | MU_STREAM_NO_CLOSE);
       if (rc == 0)
        {
          cat_message (output, fstr);
+         mu_stream_destroy (&fstr, NULL);
          mu_message_unref (*msg);
          *msg = newmsg;
        }


hooks/post-receive
-- 
GNU Mailutils




reply via email to

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