From: Todd C. Miller Date: Thu, 4 May 2017 17:10:42 +0000 (-0600) Subject: Check sudo_ev_add() return value. Coverity CID 168362 X-Git-Tag: SUDO_1_8_20^2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1a047b156d0da64f89306bff927e92ee461d02f4;p=sudo Check sudo_ev_add() return value. Coverity CID 168362 --- diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c index 84ae0aab6..6f83c3255 100644 --- a/plugins/sudoers/sudoreplay.c +++ b/plugins/sudoers/sudoreplay.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2016 Todd C. Miller + * Copyright (c) 2009-2017 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -448,7 +448,8 @@ replay_session(const double max_wait, const char *decimal) timeout.tv_usec = (to_wait - timeout.tv_sec) * 1000000.0; /* Run event event loop to delay and get keyboard input. */ - sudo_ev_add(evbase, input_ev, &timeout, false); + if (sudo_ev_add(evbase, input_ev, &timeout, false) == -1) + sudo_fatal(U_("unable to add event to queue")); sudo_ev_loop(evbase, 0); /* Even if we are not replaying, we still have to delay. */ @@ -553,7 +554,8 @@ replay_session(const double max_wait, const char *decimal) /* Run event event loop to write output. */ /* XXX - should use a single event loop with a circular buffer. */ - sudo_ev_add(evbase, output_ev, NULL, false); + if (sudo_ev_add(evbase, output_ev, NULL, false) == -1) + sudo_fatal(U_("unable to add event to queue")); sudo_ev_loop(evbase, 0); } } @@ -623,7 +625,8 @@ write_output(int fd, int what, void *v) } /* Reschedule event to write remainder. */ - sudo_ev_add(sudo_ev_get_base(wc->wevent), wc->wevent, NULL, false); + if (sudo_ev_add(NULL, wc->wevent, NULL, false) == -1) + sudo_fatal(U_("unable to add event to queue")); debug_return; } @@ -1119,7 +1122,6 @@ static void check_input(int fd, int what, void *v) { struct sudo_event *ev = v; - struct sudo_event_base *evbase = sudo_ev_get_base(ev); struct timeval tv, *timeout = NULL; static bool paused = 0; char ch; @@ -1167,7 +1169,8 @@ check_input(int fd, int what, void *v) timeout = &tv; } /* Re-enable event. */ - sudo_ev_add(evbase, ev, timeout, false); + if (sudo_ev_add(NULL, ev, timeout, false) == -1) + sudo_fatal(U_("unable to add event to queue")); } debug_return; }