Bugfix.
* libproto/imap/mbox.c (imap_envelope_sender): Fix operation when buf == NULL or buflen == 0.
Showing
2 changed files
with
13 additions
and
13 deletions
... | @@ -1453,31 +1453,31 @@ imap_envelope_sender (mu_envelope_t envelope, char *buffer, size_t buflen, | ... | @@ -1453,31 +1453,31 @@ imap_envelope_sender (mu_envelope_t envelope, char *buffer, size_t buflen, |
1453 | { | 1453 | { |
1454 | mu_message_t msg = mu_envelope_get_owner (envelope); | 1454 | mu_message_t msg = mu_envelope_get_owner (envelope); |
1455 | mu_header_t header; | 1455 | mu_header_t header; |
1456 | const char *sender, *email = NULL; | ||
1456 | int status; | 1457 | int status; |
1457 | 1458 | ||
1458 | if (buflen == 0) | ||
1459 | return 0; | ||
1460 | |||
1461 | mu_message_get_header (msg, &header); | 1459 | mu_message_get_header (msg, &header); |
1462 | status = mu_header_get_value (header, MU_HEADER_SENDER, buffer, buflen, plen); | 1460 | status = mu_header_sget_value (header, MU_HEADER_SENDER, &sender); |
1463 | if (status == EAGAIN) | 1461 | if (status == EAGAIN) |
1464 | return status; | 1462 | return status; |
1465 | else if (status != 0) | 1463 | else if (status != 0) |
1466 | status = mu_header_get_value (header, MU_HEADER_FROM, buffer, buflen, plen); | 1464 | status = mu_header_sget_value (header, MU_HEADER_FROM, &sender); |
1467 | if (status == 0) | 1465 | if (status == 0) |
1468 | { | 1466 | { |
1467 | size_t len; | ||
1469 | mu_address_t address; | 1468 | mu_address_t address; |
1470 | if (mu_address_create (&address, buffer) == 0) | 1469 | if (mu_address_create (&address, sender) == 0) |
1471 | { | 1470 | { |
1472 | mu_address_get_email (address, 1, buffer, buflen, plen); | 1471 | mu_address_sget_email (address, 1, &email); |
1473 | mu_address_destroy (&address); | 1472 | mu_address_destroy (&address); |
1474 | } | 1473 | } |
1475 | } | 1474 | |
1476 | else if (status != EAGAIN) | 1475 | if (!email) |
1477 | { | 1476 | return MU_ERR_NOENT; |
1478 | strncpy (buffer, "Unknown", buflen)[buflen - 1] = '0'; | 1477 | |
1478 | len = mu_cpystr (buffer, email, buflen); | ||
1479 | if (plen) | 1479 | if (plen) |
1480 | *plen = strlen (buffer); | 1480 | *plen = len; |
1481 | } | 1481 | } |
1482 | return status; | 1482 | return status; |
1483 | } | 1483 | } | ... | ... |
... | @@ -54,7 +54,7 @@ int reuse_lmtp_address = 1; | ... | @@ -54,7 +54,7 @@ int reuse_lmtp_address = 1; |
54 | 54 | ||
55 | const char *program_version = "maidag (" PACKAGE_STRING ")"; | 55 | const char *program_version = "maidag (" PACKAGE_STRING ")"; |
56 | static char doc[] = | 56 | static char doc[] = |
57 | N_("GNU maildag -- the mail delivery agent") | 57 | N_("GNU maidag -- the mail delivery agent") |
58 | "\v" | 58 | "\v" |
59 | N_("Debug flags are:\n\ | 59 | N_("Debug flags are:\n\ |
60 | g - guimb stack traces\n\ | 60 | g - guimb stack traces\n\ | ... | ... |
-
Please register or sign in to post a comment