Commit a03f9a76 a03f9a768f7f9752495b8822baa9b0da4fdffeb4 by Sergey Poznyakoff

Bugfix.

* libproto/imap/mbox.c (imap_envelope_sender): Fix operation when buf == NULL
or buflen == 0.
1 parent c36b5e0f
......@@ -1453,31 +1453,31 @@ imap_envelope_sender (mu_envelope_t envelope, char *buffer, size_t buflen,
{
mu_message_t msg = mu_envelope_get_owner (envelope);
mu_header_t header;
const char *sender, *email = NULL;
int status;
if (buflen == 0)
return 0;
mu_message_get_header (msg, &header);
status = mu_header_get_value (header, MU_HEADER_SENDER, buffer, buflen, plen);
status = mu_header_sget_value (header, MU_HEADER_SENDER, &sender);
if (status == EAGAIN)
return status;
else if (status != 0)
status = mu_header_get_value (header, MU_HEADER_FROM, buffer, buflen, plen);
status = mu_header_sget_value (header, MU_HEADER_FROM, &sender);
if (status == 0)
{
size_t len;
mu_address_t address;
if (mu_address_create (&address, buffer) == 0)
if (mu_address_create (&address, sender) == 0)
{
mu_address_get_email (address, 1, buffer, buflen, plen);
mu_address_sget_email (address, 1, &email);
mu_address_destroy (&address);
}
}
else if (status != EAGAIN)
{
strncpy (buffer, "Unknown", buflen)[buflen - 1] = '0';
if (!email)
return MU_ERR_NOENT;
len = mu_cpystr (buffer, email, buflen);
if (plen)
*plen = strlen (buffer);
*plen = len;
}
return status;
}
......
......@@ -54,7 +54,7 @@ int reuse_lmtp_address = 1;
const char *program_version = "maidag (" PACKAGE_STRING ")";
static char doc[] =
N_("GNU maildag -- the mail delivery agent")
N_("GNU maidag -- the mail delivery agent")
"\v"
N_("Debug flags are:\n\
g - guimb stack traces\n\
......