diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-10-10 12:54:52 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-10-10 12:54:52 +0300 |
commit | 5589f8787925cb3b05078ecfd55c54b36aed637d (patch) | |
tree | 0e626e7d233e5a03fe7aadf6c67a276dcb811de1 /mu/libexec | |
parent | 090c7b9a38373ec605535b9bf22ecce2a1433c17 (diff) | |
download | mailutils-5589f8787925cb3b05078ecfd55c54b36aed637d.tar.gz mailutils-5589f8787925cb3b05078ecfd55c54b36aed637d.tar.bz2 |
Use mu_prtstr to safely print string values
Diffstat (limited to 'mu/libexec')
-rw-r--r-- | mu/libexec/imap.c | 30 | ||||
-rw-r--r-- | mu/libexec/pop.c | 8 | ||||
-rw-r--r-- | mu/libexec/smtp.c | 2 |
3 files changed, 22 insertions, 18 deletions
diff --git a/mu/libexec/imap.c b/mu/libexec/imap.c index 37d494a7a..b44757677 100644 --- a/mu/libexec/imap.c +++ b/mu/libexec/imap.c @@ -203,7 +203,6 @@ format_date (mu_stream_t str, char *name, mu_stream_printf (str, "\n"); } -#define S(str) ((str) ? (str) : "") static void print_param (mu_stream_t ostr, const char *prefix, mu_assoc_t assoc, @@ -269,7 +268,8 @@ print_imapenvelope (mu_stream_t ostr, struct mu_imapenvelope *env, int level) indent += 4; mu_stream_printf (ostr, "%*sTime: ", indent, ""); mu_c_streamftime (mu_strout, "%c%n", &env->date, &env->tz); - mu_stream_printf (ostr, "%*sSubject: %s\n", indent, "", S(env->subject)); + mu_stream_printf (ostr, "%*sSubject: %s\n", indent, "", + mu_prstr (env->subject)); print_address (ostr, "From", env->from, indent); print_address (ostr, "Sender", env->sender, indent); print_address (ostr, "Reply-to", env->reply_to, indent); @@ -277,34 +277,38 @@ print_imapenvelope (mu_stream_t ostr, struct mu_imapenvelope *env, int level) print_address (ostr, "Cc", env->cc, indent); print_address (ostr, "Bcc", env->bcc, indent); mu_stream_printf (ostr, "%*sIn-Reply-To: %s\n", indent, "", - S(env->in_reply_to)); + mu_prstr (env->in_reply_to)); mu_stream_printf (ostr, "%*sMessage-ID: %s\n", indent, "", - S(env->message_id)); + mu_prstr (env->message_id)); } static void print_bs (mu_stream_t ostr, struct mu_bodystructure *bs, int level) { int indent = level << 2; - mu_stream_printf (ostr, "%*sbody_type=%s\n", indent, "", S(bs->body_type)); + mu_stream_printf (ostr, "%*sbody_type=%s\n", indent, "", + mu_prstr (bs->body_type)); mu_stream_printf (ostr, "%*sbody_subtype=%s\n", indent, "", - S(bs->body_subtype)); + mu_prstr (bs->body_subtype)); print_param (ostr, "Parameters", bs->body_param, indent); - mu_stream_printf (ostr, "%*sbody_id=%s\n", indent, "", S(bs->body_id)); - mu_stream_printf (ostr, "%*sbody_descr=%s\n", indent, "", S(bs->body_descr)); + mu_stream_printf (ostr, "%*sbody_id=%s\n", indent, "", + mu_prstr (bs->body_id)); + mu_stream_printf (ostr, "%*sbody_descr=%s\n", indent, "", + mu_prstr (bs->body_descr)); mu_stream_printf (ostr, "%*sbody_encoding=%s\n", indent, "", - S(bs->body_encoding)); + mu_prstr (bs->body_encoding)); mu_stream_printf (ostr, "%*sbody_size=%lu\n", indent, "", (unsigned long) bs->body_size); /* Optional */ - mu_stream_printf (ostr, "%*sbody_md5=%s\n", indent, "", S(bs->body_md5)); + mu_stream_printf (ostr, "%*sbody_md5=%s\n", indent, "", + mu_prstr (bs->body_md5)); mu_stream_printf (ostr, "%*sbody_disposition=%s\n", indent, "", - S(bs->body_disposition)); + mu_prstr (bs->body_disposition)); print_param (ostr, "Disposition Parameters", bs->body_disp_param, indent); mu_stream_printf (ostr, "%*sbody_language=%s\n", indent, "", - S(bs->body_language)); + mu_prstr (bs->body_language)); mu_stream_printf (ostr, "%*sbody_location=%s\n", indent, "", - S(bs->body_location)); + mu_prstr (bs->body_location)); mu_stream_printf (ostr, "%*sType ", indent, ""); switch (bs->body_message_type) diff --git a/mu/libexec/pop.c b/mu/libexec/pop.c index a884ea030..2bfbaa439 100644 --- a/mu/libexec/pop.c +++ b/mu/libexec/pop.c @@ -205,7 +205,7 @@ com_capa (int argc, char **argv) { char *capa = NULL; mu_iterator_current (iterator, (void **) &capa); - mu_printf ("CAPA: %s\n", capa ? capa : ""); + mu_printf ("CAPA: %s\n", mu_prstr (capa)); } mu_iterator_destroy (&iterator); } @@ -230,7 +230,7 @@ com_uidl (int argc, char **argv) { char *uidl = NULL; mu_iterator_current (uidl_iterator, (void **) &uidl); - mu_stream_printf (out, "UIDL: %s\n", uidl ? uidl : ""); + mu_stream_printf (out, "UIDL: %s\n", mu_prstr (uidl)); } mu_iterator_destroy (&uidl_iterator); } @@ -242,7 +242,7 @@ com_uidl (int argc, char **argv) unsigned int msgno = strtoul (argv[1], NULL, 10); status = mu_pop3_uidl (pop3, msgno, &uidl); if (status == 0) - mu_printf ("Msg: %d UIDL: %s\n", msgno, uidl ? uidl : ""); + mu_printf ("Msg: %d UIDL: %s\n", msgno, mu_prstr (uidl)); free (uidl); } return status; @@ -265,7 +265,7 @@ com_list (int argc, char **argv) { char *list = NULL; mu_iterator_current (list_iterator, (void **) &list); - mu_stream_printf (out, "LIST: %s\n", (list) ? list : ""); + mu_stream_printf (out, "LIST: %s\n", mu_prstr (list)); } mu_iterator_destroy (&list_iterator); mu_stream_destroy (&out); diff --git a/mu/libexec/smtp.c b/mu/libexec/smtp.c index e4be668a1..f97e7dac6 100644 --- a/mu/libexec/smtp.c +++ b/mu/libexec/smtp.c @@ -297,7 +297,7 @@ com_capa (int argc, char **argv) { char *capa = NULL; mu_iterator_current (iterator, (void **) &capa); - mu_printf ("CAPA: %s\n", capa ? capa : ""); + mu_printf ("CAPA: %s\n", mu_prstr (capa)); } mu_iterator_destroy (&iterator); } |