summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-05-02 23:21:01 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-05-02 23:21:01 +0300
commit19f93a88c9a2cd1bbe66472514db16c13a333984 (patch)
treebbb163a5e17b96594e16aa117306500c7773565c
parente8562195618922fa03c6e8ff2036238f1da7b0a4 (diff)
downloadmailutils-19f93a88c9a2cd1bbe66472514db16c13a333984.tar.gz
mailutils-19f93a88c9a2cd1bbe66472514db16c13a333984.tar.bz2
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.
-rw-r--r--readmsg/msglist.c23
-rw-r--r--readmsg/readmsg.c19
2 files changed, 31 insertions, 11 deletions
diff --git a/readmsg/msglist.c b/readmsg/msglist.c
index fb4ff99bf..b42e325cc 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 52c7512ea..7fdc63b27 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)

Return to:

Send suggestions and report system problems to the System administrator.