summaryrefslogtreecommitdiff
path: root/libmu_scm
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-10-10 11:46:44 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-10-10 12:30:51 +0300
commit090c7b9a38373ec605535b9bf22ecce2a1433c17 (patch)
tree194e423048cd6f9f785f5da9692b6a955204b515 /libmu_scm
parent8f23330dc69d1a1e3ccf3687afdcb93cf19b4f76 (diff)
downloadmailutils-090c7b9a38373ec605535b9bf22ecce2a1433c17.tar.gz
mailutils-090c7b9a38373ec605535b9bf22ecce2a1433c17.tar.bz2
Check for NULL return from mu_address_aget_ and mu_address_sget_ family functions
It is possible that these functions return success and place NULL in the result variable. Make sure this possibility is checked throughout the code. * libmailutils/base/usremail.c (mu_set_user_email): Check for NULL return value from mu_address_[as]get. * libmailutils/mailbox/msgenv.c (message_envelope_sender) * libmailutils/tests/addr.c (parse) * libmu_scm/mu_message.c (mu_scm_message_print): * libproto/mailer/prog.c (_expand_rcpt) * libproto/mailer/smtp.c (_rcpt_to_addr) (mu_address_sget_email) * maidag/lmtp.c (check_address): * mail/from.c (hdr_from): * mail/util.c (util_get_sender): * mh/mh_format.c (addr_cmp, builtin_proper) (builtin_addr, builtin_pers, builtin_note) (builtin_mbox, builtin_path, builtin_formataddr) * mh/mh_whom.c (scan_addrs): * libmu_sieve/util.c (mu_sieve_vlist_compare): Skip NULL returns from retr. * libmu_sieve/actions.c (check_redirect_loop): Error checking. * include/mailutils/types.hin (mu_prstr): New function. * libmu_cpp/address.cc: Use mu_prstr to ensure the printable representation of string. * python/libmu_py/address.c: Likewise. * libmu_scm/mu_address.c (_get_address_part): Likewise. * libmailutils/string/wordsplit.c (expvar): Treat NULL value as "".
Diffstat (limited to 'libmu_scm')
-rw-r--r--libmu_scm/mu_address.c2
-rw-r--r--libmu_scm/mu_message.c33
2 files changed, 20 insertions, 15 deletions
diff --git a/libmu_scm/mu_address.c b/libmu_scm/mu_address.c
index c793e902c..53d4ce204 100644
--- a/libmu_scm/mu_address.c
+++ b/libmu_scm/mu_address.c
@@ -56,7 +56,7 @@ _get_address_part (const char *func_name, address_get_fp fun,
mu_address_destroy (&addr);
if (status == 0)
- ret = scm_from_locale_string (str);
+ ret = scm_from_locale_string (mu_prstr (str));
else
{
free (str);
diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c
index ad642c73d..fcad77ae7 100644
--- a/libmu_scm/mu_message.c
+++ b/libmu_scm/mu_message.c
@@ -54,7 +54,7 @@ _get_envelope_sender (mu_envelope_t env)
{
mu_address_t addr;
const char *buffer;
- char *ptr;
+ char *ptr = NULL;
if (mu_envelope_sget_sender (env, &buffer)
|| mu_address_create (&addr, buffer))
@@ -65,7 +65,7 @@ _get_envelope_sender (mu_envelope_t env)
mu_address_destroy (&addr);
return NULL;
}
-
+
mu_address_destroy (&addr);
return ptr;
}
@@ -76,7 +76,6 @@ mu_scm_message_print (SCM message_smob, SCM port, scm_print_state * pstate)
struct mu_message *mum = (struct mu_message *) SCM_CDR (message_smob);
mu_envelope_t env = NULL;
const char *buffer;
- const char *p;
size_t m_size = 0, m_lines = 0;
struct tm tm;
struct mu_timezone tz;
@@ -93,18 +92,21 @@ mu_scm_message_print (SCM message_smob, SCM port, scm_print_state * pstate)
}
else
{
+ char *p;
+ char const *s;
+
p = _get_envelope_sender (env);
scm_puts ("\"", port);
if (p)
{
scm_puts (p, port);
- free ((void *) p);
+ free (p);
}
else
scm_puts ("UNKNOWN", port);
- if (mu_envelope_sget_date (env, &p) == 0
- && mu_scan_datetime (p, MU_DATETIME_FROM, &tm, &tz, NULL) == 0)
+ if (mu_envelope_sget_date (env, &s) == 0
+ && mu_scan_datetime (s, MU_DATETIME_FROM, &tm, &tz, NULL) == 0)
{
strftime (datebuf, sizeof (datebuf), "%a %b %e %H:%M", &tm);
buffer = datebuf;
@@ -435,7 +437,6 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0,
mu_message_t msg;
mu_envelope_t env = NULL;
int status;
- SCM ret;
SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME);
msg = mu_scm_message_get (mesg);
@@ -443,14 +444,18 @@ SCM_DEFINE_PUBLIC (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0,
if (status == 0)
{
char *p = _get_envelope_sender (env);
- ret = scm_from_locale_string (p);
- free (p);
+ if (p)
+ {
+ SCM ret = scm_from_locale_string (p);
+ free (p);
+ return ret;
+ }
}
- else
- mu_scm_error (FUNC_NAME, status,
- "Cannot get envelope of message ~A",
- scm_list_1 (mesg));
- return ret;
+
+ mu_scm_error (FUNC_NAME, status,
+ "Cannot get envelope of message ~A",
+ scm_list_1 (mesg));
+ return SCM_UNDEFINED;
}
#undef FUNC_NAME

Return to:

Send suggestions and report system problems to the System administrator.