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-98-g19f93a8


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, stream-cleanup, updated. rel-2_1-98-g19f93a8
Date: Sun, 02 May 2010 22:34:18 +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=19f93a88c9a2cd1bbe66472514db16c13a333984

The branch, stream-cleanup has been updated
       via  19f93a88c9a2cd1bbe66472514db16c13a333984 (commit)
       via  e8562195618922fa03c6e8ff2036238f1da7b0a4 (commit)
      from  b4ed41dcc3d0617358b9497d93c675e786109c5c (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 19f93a88c9a2cd1bbe66472514db16c13a333984
Author: Sergey Poznyakoff <address@hidden>
Date:   Sun May 2 23:21:01 2010 +0300

    Fix readmsg.
    
    Readmsg passes all tests successfully.
    
    * readmsg/msglist.c (msglist): Check return from mu_message_get_streamref.
    * readmsg/readmsg.c (print_header, print_body): Check return values.

commit e8562195618922fa03c6e8ff2036238f1da7b0a4
Author: Sergey Poznyakoff <address@hidden>
Date:   Sun May 2 23:20:39 2010 +0300

    Bugfixes
    
    * mailbox/header.c (header_seek): Do not dereference
    hstr->hdr->size directly, because it may not be initialized yet.
    Use mu_header_size instead.
    * mailbox/message.c (_message_stream_readdelim): Break the loop
    if mu_stream_readdelim returned error or EOF.

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

Summary of changes:
 mailbox/header.c  |   10 ++++++++--
 mailbox/message.c |    2 ++
 readmsg/msglist.c |   23 +++++++++++++++--------
 readmsg/readmsg.c |   19 ++++++++++++++++---
 4 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/mailbox/header.c b/mailbox/header.c
index 9c8fb9f..669093c 100644
--- a/mailbox/header.c
+++ b/mailbox/header.c
@@ -934,8 +934,14 @@ int
 header_seek (mu_stream_t str, mu_off_t off, mu_off_t *presult)
 { 
   struct _mu_header_stream *hstr = (struct _mu_header_stream *) str;
-
-  if (off < 0 || off > hstr->hdr->size)
+  size_t size;
+  int status;
+    
+  status = mu_header_size (hstr->hdr, &size);
+  if (status)
+    return status;
+  
+  if (off < 0 || off > size)
     return ESPIPE;
   hstr->off = off;
   *presult = off;
diff --git a/mailbox/message.c b/mailbox/message.c
index 8111b48..a792ebb 100644
--- a/mailbox/message.c
+++ b/mailbox/message.c
@@ -240,6 +240,8 @@ _message_stream_readdelim (struct _mu_stream *str, char 
*buf, size_t bufsize,
       if (sp->state == _mss_eof)
        break;
       rc = mu_stream_readdelim (sp->transport, buf, bufsize, delim, &n);
+      if (rc || n == 0)
+       break;
       nread += n;
       buf += n;
       bufsize -= n;
diff --git a/readmsg/msglist.c b/readmsg/msglist.c
index fb4ff99..b42e325 100644
--- a/readmsg/msglist.c
+++ b/readmsg/msglist.c
@@ -118,24 +118,31 @@ msglist (mu_mailbox_t mbox, int show_all, int argc, char 
**argv,
          int found = 0;
          for (j = 1; j <= total; j++)
            {
+             int status;
              char buf[128];
              size_t len = 0;
              mu_message_t msg = NULL;
              mu_stream_t stream = NULL;
 
              mu_mailbox_get_message (mbox, j, &msg);
-             mu_message_get_streamref (msg, &stream);
-             while (mu_stream_readline (stream, buf, sizeof buf, &len) == 0
-                    && len > 0)
+             status = mu_message_get_streamref (msg, &stream);
+             if (status)
+               mu_error (_("cannot read message: %s"),
+                         mu_strerror (status));
+             else
                {
-                 if (strstr (buf, argv[i]) != NULL)
+                 while (mu_stream_readline (stream, buf, sizeof buf, &len) == 0
+                        && len > 0)
                    {
-                     addset (set, n, j);
-                     found = 1;
-                     break;
+                     if (strstr (buf, argv[i]) != NULL)
+                       {
+                         addset (set, n, j);
+                         found = 1;
+                         break;
+                       }
                    }
+                 mu_stream_destroy (&stream);
                }
-             mu_stream_destroy (&stream);
              if (found && !show_all)
                break;
            }
diff --git a/readmsg/readmsg.c b/readmsg/readmsg.c
index 52c7512..7fdc63b 100644
--- a/readmsg/readmsg.c
+++ b/readmsg/readmsg.c
@@ -222,11 +222,18 @@ print_header (mu_message_t message, int unix_header, int 
weedc, char **weedv)
     }
   else
     {
+      int status;
       size_t count;
       size_t i;
 
-      mu_header_get_field_count (header, &count);
-
+      status = mu_header_get_field_count (header, &count);
+      if (status)
+       {
+         mu_error (_("cannot get number of headers: %s"),
+                   mu_strerror (status));
+         return;
+       }
+      
       for (i = 1; i <= count; i++)
        {
          int j;
@@ -259,6 +266,7 @@ print_header (mu_message_t message, int unix_header, int 
weedc, char **weedv)
 static void
 print_body (mu_message_t message)
 {
+  int status;
   char buf[128];
   mu_body_t body = NULL;
   mu_stream_t stream = NULL;
@@ -266,7 +274,12 @@ print_body (mu_message_t message)
   mu_message_get_body (message, &body);
 
   /* FIXME: Use mu_stream_copy */
-  mu_body_get_streamref (body, &stream);
+  status = mu_body_get_streamref (body, &stream);
+  if (status)
+    {
+      mu_error (_("cannot get body stream: %s"), mu_strerror (status));
+      return;
+    }
 
   while (mu_stream_read (stream, buf, sizeof (buf) - 1, &len) == 0
         && len != 0)


hooks/post-receive
-- 
GNU Mailutils




reply via email to

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