summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-07-23 08:04:38 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-07-23 08:04:38 +0300
commit018df5d628f4e093f7e45c00b48ffc11b234d8cf (patch)
treec360d39b523c8327c6b029531b7a0f345dc4eecd
parentbd46cf8d48852639e10e66a87500f7b9ec18e1ef (diff)
downloadmailutils-018df5d628f4e093f7e45c00b48ffc11b234d8cf.tar.gz
mailutils-018df5d628f4e093f7e45c00b48ffc11b234d8cf.tar.bz2
Minor fix
Check return from mu_message_get_num_parts
-rw-r--r--imap4d/fetch.c32
-rw-r--r--imap4d/search.c24
-rw-r--r--libmu_scm/tests/testsuite.at2
-rw-r--r--libmu_sieve/extensions/moderator.c9
-rw-r--r--libmu_sieve/tests.c15
-rw-r--r--mail/decode.c39
-rw-r--r--mh/burst.c8
-rw-r--r--mh/mhn.c12
8 files changed, 92 insertions, 49 deletions
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index 51921dd6b..fa0cea6c0 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -491,7 +491,6 @@ bodystructure (mu_message_t msg, int extension)
491static int 491static int
492fetch_bodystructure0 (mu_message_t message, int extension) 492fetch_bodystructure0 (mu_message_t message, int extension)
493{ 493{
494 size_t nparts = 1;
495 size_t i; 494 size_t i;
496 int is_multipart = 0; 495 int is_multipart = 0;
497 496
@@ -500,20 +499,27 @@ fetch_bodystructure0 (mu_message_t message, int extension)
500 { 499 {
501 mu_content_type_t ct; 500 mu_content_type_t ct;
502 mu_header_t header = NULL; 501 mu_header_t header = NULL;
502 size_t nparts;
503 int rc; 503 int rc;
504 504
505 mu_message_get_num_parts (message, &nparts); 505 rc = mu_message_get_num_parts (message, &nparts);
506 506 if (rc)
507 /* Get all the sub messages. */ 507 {
508 for (i = 1; i <= nparts; i++) 508 mu_diag_funcall (MU_DIAG_ERR, "mu_message_get_num_parts", NULL, rc);
509 { 509 }
510 mu_message_t msg = NULL; 510 else
511 mu_message_get_part (message, i, &msg); 511 {
512 io_sendf ("("); 512 /* Get all the sub messages. */
513 fetch_bodystructure0 (msg, extension); 513 for (i = 1; i <= nparts; i++)
514 io_sendf (")"); 514 {
515 } /* for () */ 515 mu_message_t msg = NULL;
516 516 mu_message_get_part (message, i, &msg);
517 io_sendf ("(");
518 fetch_bodystructure0 (msg, extension);
519 io_sendf (")");
520 } /* for () */
521 }
522
517 mu_message_get_header (message, &header); 523 mu_message_get_header (message, &header);
518 524
519 /* The subtype. */ 525 /* The subtype. */
diff --git a/imap4d/search.c b/imap4d/search.c
index 8bc9770c1..003796447 100644
--- a/imap4d/search.c
+++ b/imap4d/search.c
@@ -1019,17 +1019,23 @@ _match_multipart (struct parsebuf *pb, mu_message_t msg, char *text)
1019 { 1019 {
1020 size_t i, nparts; 1020 size_t i, nparts;
1021 1021
1022 mu_message_get_num_parts (msg, &nparts); 1022 rc = mu_message_get_num_parts (msg, &nparts);
1023 1023 if (rc)
1024 for (i = 1; i <= nparts; i++)
1025 { 1024 {
1026 mu_message_t submsg = NULL; 1025 mu_diag_funcall (MU_DIAG_ERR, "mu_message_get_num_parts", NULL, rc);
1027 1026 }
1028 if (mu_message_get_part (msg, i, &submsg) == 0) 1027 else
1028 {
1029 for (i = 1; i <= nparts; i++)
1029 { 1030 {
1030 result = _match_multipart (pb, submsg, text); 1031 mu_message_t submsg = NULL;
1031 if (result) 1032
1032 break; 1033 if (mu_message_get_part (msg, i, &submsg) == 0)
1034 {
1035 result = _match_multipart (pb, submsg, text);
1036 if (result)
1037 break;
1038 }
1033 } 1039 }
1034 } 1040 }
1035 } 1041 }
diff --git a/libmu_scm/tests/testsuite.at b/libmu_scm/tests/testsuite.at
index 6bd194757..ba445f7b9 100644
--- a/libmu_scm/tests/testsuite.at
+++ b/libmu_scm/tests/testsuite.at
@@ -14,7 +14,7 @@ m4_define([MU_GUILE_CHECK],
14[AT_DATA([input.scm],[dnl 14[AT_DATA([input.scm],[dnl
15(use-modules ((mailutils mailutils)) 15(use-modules ((mailutils mailutils))
16 ((mailutils ancilla))) 16 ((mailutils ancilla)))
17(mu-register-format "mbox") 17(mu-register-format "mbox")
18[$1] 18[$1]
19]) 19])
20m4_if(MU_TEST_MAILBOX,,,[MUT_MBCOPY($abs_top_srcdir/testsuite/MU_TEST_MAILBOX,mbox)]) 20m4_if(MU_TEST_MAILBOX,,,[MUT_MBCOPY($abs_top_srcdir/testsuite/MU_TEST_MAILBOX,mbox)])
diff --git a/libmu_sieve/extensions/moderator.c b/libmu_sieve/extensions/moderator.c
index 3544d88f9..4fe2e8375 100644
--- a/libmu_sieve/extensions/moderator.c
+++ b/libmu_sieve/extensions/moderator.c
@@ -284,8 +284,13 @@ moderator_action (mu_sieve_machine_t mach)
284 mu_sieve_abort (mach); 284 mu_sieve_abort (mach);
285 } 285 }
286 286
287 mu_message_get_num_parts (msg, &nparts); 287 rc = mu_message_get_num_parts (msg, &nparts);
288 288 if (rc)
289 {
290 mu_sieve_error (mach, "mu_message_get_num_parts: %s", mu_strerror (rc));
291 mu_sieve_abort (mach);
292 }
293
289 if (nparts != 3) /* Mailman moderation requests have three parts */ 294 if (nparts != 3) /* Mailman moderation requests have three parts */
290 { 295 {
291 mu_sieve_error (mach, _("expected 3 parts, but found %lu"), 296 mu_sieve_error (mach, _("expected 3 parts, but found %lu"),
diff --git a/libmu_sieve/tests.c b/libmu_sieve/tests.c
index da3872f1c..c346747e4 100644
--- a/libmu_sieve/tests.c
+++ b/libmu_sieve/tests.c
@@ -176,17 +176,24 @@ sieve_test_header (mu_sieve_machine_t mach)
176 v = mu_sieve_get_arg_untyped (mach, 1); 176 v = mu_sieve_get_arg_untyped (mach, 1);
177 177
178 clos.message = mach->msg; 178 clos.message = mach->msg;
179 clos.nparts = 0;
179 180
180 if (mu_sieve_get_tag (mach, "mime", SVT_VOID, NULL)) 181 if (mu_sieve_get_tag (mach, "mime", SVT_VOID, NULL))
181 { 182 {
182 int ismime = 0; 183 int ismime = 0;
183 184
184 mu_message_is_multipart (mach->msg, &ismime); 185 rc = mu_message_is_multipart (mach->msg, &ismime);
186 if (rc)
187 mu_diag_funcall (MU_DIAG_ERR, "mu_message_is_multipart",
188 NULL, rc);
185 if (ismime) 189 if (ismime)
186 mu_message_get_num_parts (mach->msg, &clos.nparts); 190 {
191 rc = mu_message_get_num_parts (mach->msg, &clos.nparts);
192 if (rc)
193 mu_diag_funcall (MU_DIAG_ERR, "mu_message_get_num_parts",
194 NULL, rc);
195 }
187 } 196 }
188 else
189 clos.nparts = 0;
190 197
191 rc = mu_sieve_vlist_compare (mach, h, v, retrieve_header, NULL, &clos); 198 rc = mu_sieve_vlist_compare (mach, h, v, retrieve_header, NULL, &clos);
192 return rc; 199 return rc;
diff --git a/mail/decode.c b/mail/decode.c
index 869fe2f3b..647f8cff3 100644
--- a/mail/decode.c
+++ b/mail/decode.c
@@ -172,7 +172,6 @@ mime_descend (struct mime_descend_closure *closure,
172 mime_descend_fn fun, void *data) 172 mime_descend_fn fun, void *data)
173{ 173{
174 int status = 0; 174 int status = 0;
175 size_t nparts = 0;
176 mu_header_t hdr = NULL; 175 mu_header_t hdr = NULL;
177 char *type; 176 char *type;
178 char *encoding; 177 char *encoding;
@@ -195,23 +194,31 @@ mime_descend (struct mime_descend_closure *closure,
195 if (ismime) 194 if (ismime)
196 { 195 {
197 unsigned int j; 196 unsigned int j;
198 197 size_t nparts;
199 mu_message_get_num_parts (closure->message, &nparts); 198
200 199 status = mu_message_get_num_parts (closure->message, &nparts);
201 for (j = 1; j <= nparts; j++) 200 if (status)
202 { 201 {
203 mu_message_t message = NULL; 202 mu_diag_funcall (MU_DIAG_ERR, "mu_message_get_num_parts", NULL,
204 203 status);
205 if (mu_message_get_part (closure->message, j, &message) == 0) 204 }
205 else
206 {
207 for (j = 1; j <= nparts; j++)
206 { 208 {
207 msgset_t *set = msgset_expand (msgset_dup (closure->msgset), 209 mu_message_t message = NULL;
208 msgset_make_1 (j)); 210
209 subclosure.msgset = set; 211 if (mu_message_get_part (closure->message, j, &message) == 0)
210 subclosure.message = message; 212 {
211 status = mime_descend (&subclosure, fun, data); 213 msgset_t *set = msgset_expand (msgset_dup (closure->msgset),
212 msgset_free (set); 214 msgset_make_1 (j));
213 if (status) 215 subclosure.msgset = set;
214 break; 216 subclosure.message = message;
217 status = mime_descend (&subclosure, fun, data);
218 msgset_free (set);
219 if (status)
220 break;
221 }
215 } 222 }
216 } 223 }
217 } 224 }
diff --git a/mh/burst.c b/mh/burst.c
index b512fa0bb..af04317bd 100644
--- a/mh/burst.c
+++ b/mh/burst.c
@@ -75,8 +75,14 @@ int
75burst_mime (mu_message_t msg) 75burst_mime (mu_message_t msg)
76{ 76{
77 size_t i, nparts; 77 size_t i, nparts;
78 int rc;
78 79
79 mu_message_get_num_parts (msg, &nparts); 80