From b89cf34b53a15e34d5e3ef2cdf545252ccd65dc2 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 12 Oct 2018 08:39:12 -0600 Subject: [PATCH] Replace sudo_fatal(NULL) with an "unable to allocate memory" message that includes the function name. --- plugins/sudoers/sudoreplay.c | 4 ++-- src/exec_monitor.c | 22 +++++++++++----------- src/exec_nopty.c | 28 ++++++++++++++-------------- src/exec_pty.c | 28 ++++++++++++++-------------- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c index 9ca08ecec..f7f14f1be 100644 --- a/plugins/sudoers/sudoreplay.c +++ b/plugins/sudoers/sudoreplay.c @@ -571,10 +571,10 @@ xterm_get_size(int *new_rows, int *new_cols) /* Setup an event for reading the terminal size */ evbase = sudo_ev_base_alloc(); if (evbase == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); gc.ev = sudo_ev_alloc(ttyfd, SUDO_EV_READ, getsize_cb, &gc); if (gc.ev == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); /* Read back terminal size response */ if (sudo_ev_add(evbase, gc.ev, &gc.timeout, false) == -1) diff --git a/src/exec_monitor.c b/src/exec_monitor.c index b0a362f50..e09f2212c 100644 --- a/src/exec_monitor.c +++ b/src/exec_monitor.c @@ -457,13 +457,13 @@ fill_exec_closure_monitor(struct monitor_closure *mc, /* Setup event base and events. */ mc->evbase = sudo_ev_base_alloc(); if (mc->evbase == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); /* Event for command status via errfd. */ mc->errpipe_event = sudo_ev_alloc(errfd, SUDO_EV_READ|SUDO_EV_PERSIST, mon_errpipe_cb, mc); if (mc->errpipe_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(mc->evbase, mc->errpipe_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); @@ -471,7 +471,7 @@ fill_exec_closure_monitor(struct monitor_closure *mc, mc->backchannel_event = sudo_ev_alloc(backchannel, SUDO_EV_READ|SUDO_EV_PERSIST, mon_backchannel_cb, mc); if (mc->backchannel_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(mc->evbase, mc->backchannel_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); @@ -479,56 +479,56 @@ fill_exec_closure_monitor(struct monitor_closure *mc, mc->sigint_event = sudo_ev_alloc(SIGINT, SUDO_EV_SIGINFO, mon_signal_cb, mc); if (mc->sigint_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(mc->evbase, mc->sigint_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); mc->sigquit_event = sudo_ev_alloc(SIGQUIT, SUDO_EV_SIGINFO, mon_signal_cb, mc); if (mc->sigquit_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(mc->evbase, mc->sigquit_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); mc->sigtstp_event = sudo_ev_alloc(SIGTSTP, SUDO_EV_SIGINFO, mon_signal_cb, mc); if (mc->sigtstp_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(mc->evbase, mc->sigtstp_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); mc->sigterm_event = sudo_ev_alloc(SIGTERM, SUDO_EV_SIGINFO, mon_signal_cb, mc); if (mc->sigterm_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(mc->evbase, mc->sigterm_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); mc->sighup_event = sudo_ev_alloc(SIGHUP, SUDO_EV_SIGINFO, mon_signal_cb, mc); if (mc->sighup_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(mc->evbase, mc->sighup_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); mc->sigusr1_event = sudo_ev_alloc(SIGUSR1, SUDO_EV_SIGINFO, mon_signal_cb, mc); if (mc->sigusr1_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(mc->evbase, mc->sigusr1_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); mc->sigusr2_event = sudo_ev_alloc(SIGUSR2, SUDO_EV_SIGINFO, mon_signal_cb, mc); if (mc->sigusr2_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(mc->evbase, mc->sigusr2_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); mc->sigchld_event = sudo_ev_alloc(SIGCHLD, SUDO_EV_SIGINFO, mon_signal_cb, mc); if (mc->sigchld_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(mc->evbase, mc->sigchld_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); diff --git a/src/exec_nopty.c b/src/exec_nopty.c index 3ba34fdb6..e7941cb9d 100644 --- a/src/exec_nopty.c +++ b/src/exec_nopty.c @@ -204,13 +204,13 @@ fill_exec_closure_nopty(struct exec_closure_nopty *ec, /* 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 errfd. */ ec->errpipe_event = sudo_ev_alloc(errfd, SUDO_EV_READ|SUDO_EV_PERSIST, errpipe_cb, ec); if (ec->errpipe_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(ec->evbase, ec->errpipe_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); sudo_debug_printf(SUDO_DEBUG_INFO, "error pipe fd %d\n", errfd); @@ -219,77 +219,77 @@ fill_exec_closure_nopty(struct exec_closure_nopty *ec, ec->sigint_event = sudo_ev_alloc(SIGINT, SUDO_EV_SIGINFO, signal_cb_nopty, 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_nopty, 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_nopty, 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_nopty, 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_nopty, 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_nopty, 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->sigpipe_event = sudo_ev_alloc(SIGPIPE, SUDO_EV_SIGINFO, signal_cb_nopty, ec); if (ec->sigpipe_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(ec->evbase, ec->sigpipe_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_nopty, 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_nopty, 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_nopty, 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->sigcont_event = sudo_ev_alloc(SIGCONT, SUDO_EV_SIGINFO, signal_cb_nopty, ec); if (ec->sigcont_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(ec->evbase, ec->sigcont_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); @@ -297,7 +297,7 @@ fill_exec_closure_nopty(struct exec_closure_nopty *ec, ec->siginfo_event = sudo_ev_alloc(SIGINFO, SUDO_EV_SIGINFO, signal_cb_nopty, ec); if (ec->siginfo_event == NULL) - sudo_fatal(NULL); + sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory")); if (sudo_ev_add(ec->evbase, ec->siginfo_event, NULL, false) == -1) sudo_fatal(U_("unable to add event to queue")); #endif diff --git a/src/exec_pty.c b/src/exec_pty.c index 4c26479ec..d2088cfc4 100644 --- a/src/exec_pty.c +++ b/src/exec_pty.c @@ -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) { -- 2.40.0