Replace sudo_fatal(NULL) with an "unable to allocate memory" message

that includes the function name.
This commit is contained in:
Todd C. Miller
2018-10-12 08:39:12 -06:00
parent 9e269e0acd
commit b89cf34b53
4 changed files with 41 additions and 41 deletions

View File

@@ -1149,13 +1149,13 @@ fill_exec_closure_pty(struct exec_closure_pty *ec, struct command_status *cstat,
/* Setup event base and events. */
ec->evbase = sudo_ev_base_alloc();
if (ec->evbase == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* Event for command status via backchannel. */
ec->backchannel_event = sudo_ev_alloc(backchannel,
SUDO_EV_READ|SUDO_EV_PERSIST, backchannel_cb, ec);
if (ec->backchannel_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->backchannel_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
sudo_debug_printf(SUDO_DEBUG_INFO, "backchannel fd %d\n", backchannel);
@@ -1164,70 +1164,70 @@ fill_exec_closure_pty(struct exec_closure_pty *ec, struct command_status *cstat,
ec->sigint_event = sudo_ev_alloc(SIGINT,
SUDO_EV_SIGINFO, signal_cb_pty, ec);
if (ec->sigint_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->sigint_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
ec->sigquit_event = sudo_ev_alloc(SIGQUIT,
SUDO_EV_SIGINFO, signal_cb_pty, ec);
if (ec->sigquit_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->sigquit_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
ec->sigtstp_event = sudo_ev_alloc(SIGTSTP,
SUDO_EV_SIGINFO, signal_cb_pty, ec);
if (ec->sigtstp_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->sigtstp_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
ec->sigterm_event = sudo_ev_alloc(SIGTERM,
SUDO_EV_SIGINFO, signal_cb_pty, ec);
if (ec->sigterm_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->sigterm_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
ec->sighup_event = sudo_ev_alloc(SIGHUP,
SUDO_EV_SIGINFO, signal_cb_pty, ec);
if (ec->sighup_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->sighup_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
ec->sigalrm_event = sudo_ev_alloc(SIGALRM,
SUDO_EV_SIGINFO, signal_cb_pty, ec);
if (ec->sigalrm_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->sigalrm_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
ec->sigusr1_event = sudo_ev_alloc(SIGUSR1,
SUDO_EV_SIGINFO, signal_cb_pty, ec);
if (ec->sigusr1_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->sigusr1_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
ec->sigusr2_event = sudo_ev_alloc(SIGUSR2,
SUDO_EV_SIGINFO, signal_cb_pty, ec);
if (ec->sigusr2_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->sigusr2_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
ec->sigchld_event = sudo_ev_alloc(SIGCHLD,
SUDO_EV_SIGINFO, signal_cb_pty, ec);
if (ec->sigchld_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->sigchld_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
ec->sigwinch_event = sudo_ev_alloc(SIGWINCH,
SUDO_EV_SIGINFO, signal_cb_pty, ec);
if (ec->sigwinch_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(ec->evbase, ec->sigwinch_event, NULL, false) == -1)
sudo_fatal(U_("unable to add event to queue"));
@@ -1235,7 +1235,7 @@ fill_exec_closure_pty(struct exec_closure_pty *ec, struct command_status *cstat,
ec->fwdchannel_event = sudo_ev_alloc(backchannel,
SUDO_EV_WRITE, fwdchannel_cb, ec);
if (ec->fwdchannel_event == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* Set the default event base. */
sudo_ev_base_setdef(ec->evbase);
@@ -1653,7 +1653,7 @@ del_io_events(bool nonblocking)
/* Create temporary event base for flushing. */
evbase = sudo_ev_base_alloc();
if (evbase == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* Avoid reading from /dev/tty, just flush existing data. */
SLIST_FOREACH(iob, &iobufs, entries) {