summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-06-13 13:39:31 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-06-13 13:39:31 +0300
commitf90b6805119ea3561e7852a21993742c5b160115 (patch)
tree48a794d6e81551218cc376a71f253786a946ca0b
parent830a53abae7c0754535124846635c89e7e8cff1f (diff)
downloadmailutils-f90b6805119ea3561e7852a21993742c5b160115.tar.gz
mailutils-f90b6805119ea3561e7852a21993742c5b160115.tar.bz2
Fix eventual segmentation violation in imap4d
The coredump occurred if a recently started child received a termination signal before initializing iostream. * imap4d/bye.c (imap4d_bye0): Rename to imap4d_bye_command. All uses changed. * imap4d/io.c (io_untagged_response): Check if iostream is initialized.
-rw-r--r--imap4d/bye.c4
-rw-r--r--imap4d/imap4d.h6
-rw-r--r--imap4d/io.c21
-rw-r--r--imap4d/logout.c2
4 files changed, 21 insertions, 12 deletions
diff --git a/imap4d/bye.c b/imap4d/bye.c
index 47a95976b..6765e9edb 100644
--- a/imap4d/bye.c
+++ b/imap4d/bye.c
@@ -20,7 +20,7 @@
int
imap4d_bye (int reason)
{
- return imap4d_bye0 (reason, NULL);
+ return imap4d_bye_command (reason, NULL);
}
static jmp_buf pipejmp;
@@ -32,7 +32,7 @@ sigpipe (int sig)
}
int
-imap4d_bye0 (int reason, struct imap4d_command *command)
+imap4d_bye_command (int reason, struct imap4d_command *command)
{
int status = EX_SOFTWARE;
diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h
index 5d5287b5a..7a0cdafc1 100644
--- a/imap4d/imap4d.h
+++ b/imap4d/imap4d.h
@@ -252,7 +252,8 @@ void io_getline (char **pbuf, size_t *psize, size_t *pnbytes);
void io_setio (int, int, struct mu_tls_config *);
void io_flush (void);
int io_wait_input (int);
-
+void io_enable_crlf (int);
+
imap4d_tokbuf_t imap4d_tokbuf_init (void);
void imap4d_tokbuf_destroy (imap4d_tokbuf_t *tok);
int imap4d_tokbuf_argc (imap4d_tokbuf_t tok);
@@ -392,7 +393,7 @@ extern void imap4d_set_observer (mu_mailbox_t mbox);
extern RETSIGTYPE imap4d_master_signal (int);
extern RETSIGTYPE imap4d_child_signal (int);
extern int imap4d_bye (int);
-extern int imap4d_bye0 (int reason, struct imap4d_command *command);
+extern int imap4d_bye_command (int, struct imap4d_command *);
void imap4d_enter_critical (void);
void imap4d_leave_critical (void);
@@ -462,7 +463,6 @@ int util_attribute_matches_flag (mu_attribute_t attr, const char *item);
int util_uidvalidity (mu_mailbox_t smbox, unsigned long *uidvp);
-int util_is_master (void);
void util_bye (void);
void util_chdir (const char *homedir);
int is_atom (const char *s);
diff --git a/imap4d/io.c b/imap4d/io.c
index aafbe44c7..a66e6b79a 100644
--- a/imap4d/io.c
+++ b/imap4d/io.c
@@ -289,6 +289,21 @@ io_untagged_response (int rc, const char *format, ...)
int status;
va_list ap;
+ if (iostream == NULL)
+ {
+ if (rc == RESP_BYE)
+ /* RESP_BYE can be emitted when iostream has not been initialized,
+ e.g. when a recently started child receives termination signal
+ during initialization. */
+ return 0;
+ mu_diag_output (MU_DIAG_ERROR,
+ /* TANSLATORS: %s is replaced with the untagged response
+ name, followed by a space character. */
+ _("iostream is NULL while trying to send the %suntagged response"),
+ sc2string (rc));
+ exit (EX_SOFTWARE);
+ }
+
mu_stream_printf (iostream, "* %s", sc2string (rc));
va_start (ap, format);
status = mu_stream_vprintf (iostream, format, ap);
@@ -388,12 +403,6 @@ io_flush ()
mu_stream_flush (iostream);
}
-int
-util_is_master ()
-{
- return iostream == NULL;
-}
-
void
io_getline (char **pbuf, size_t *psize, size_t *pnbytes)
{
diff --git a/imap4d/logout.c b/imap4d/logout.c
index 9ffdc8f28..69e5224f2 100644
--- a/imap4d/logout.c
+++ b/imap4d/logout.c
@@ -34,6 +34,6 @@ imap4d_logout (struct imap4d_session *session,
{
if (imap4d_tokbuf_argc (tok) != 2)
return io_completion_response (command, RESP_BAD, "Invalid arguments");
- imap4d_bye0 (OK, command);
+ imap4d_bye_command (OK, command);
return 0;
}

Return to:

Send suggestions and report system problems to the System administrator.