From f2f5c2949c44f17e77f1cee225ddcc7c33c11083 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 14 Jul 2015 14:47:12 -0600 Subject: [PATCH] Add line number to debug log for memory allocation errors. --- lib/util/event.c | 4 ++-- lib/util/event_poll.c | 4 ++-- lib/util/event_select.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/util/event.c b/lib/util/event.c index 703f8f243..f618bb7df 100644 --- a/lib/util/event.c +++ b/lib/util/event.c @@ -80,7 +80,7 @@ sudo_ev_base_alloc_v1(void) base = calloc(1, sizeof(*base)); if (base == NULL) { - sudo_debug_printf(SUDO_DEBUG_ERROR, + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, "%s: unable to allocate base", __func__); debug_return_ptr(NULL); } @@ -122,7 +122,7 @@ sudo_ev_alloc_v1(int fd, short events, sudo_ev_callback_t callback, void *closur ev = calloc(1, sizeof(*ev)); if (ev == NULL) { - sudo_debug_printf(SUDO_DEBUG_ERROR, + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, "%s: unable to allocate event", __func__); debug_return_ptr(NULL); } diff --git a/lib/util/event_poll.c b/lib/util/event_poll.c index e238c3813..5266a2b2f 100644 --- a/lib/util/event_poll.c +++ b/lib/util/event_poll.c @@ -50,7 +50,7 @@ sudo_ev_base_alloc_impl(struct sudo_event_base *base) base->pfd_max = 32; base->pfds = reallocarray(NULL, base->pfd_max, sizeof(struct pollfd)); if (base->pfds == NULL) { - sudo_debug_printf(SUDO_DEBUG_ERROR, + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, "%s: unable to allocate %d pollfds", __func__, base->pfd_max); base->pfd_max = 0; debug_return_int(-1); @@ -84,7 +84,7 @@ sudo_ev_add_impl(struct sudo_event_base *base, struct sudo_event *ev) pfds = reallocarray(base->pfds, base->pfd_max, 2 * sizeof(struct pollfd)); if (pfds == NULL) { - sudo_debug_printf(SUDO_DEBUG_ERROR, + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, "%s: unable to allocate %d pollfds", __func__, base->pfd_max * 2); debug_return_int(-1); } diff --git a/lib/util/event_select.c b/lib/util/event_select.c index 75e830775..b6380faec 100644 --- a/lib/util/event_select.c +++ b/lib/util/event_select.c @@ -59,8 +59,8 @@ sudo_ev_base_alloc_impl(struct sudo_event_base *base) if (base->readfds_in == NULL || base->writefds_in == NULL || base->readfds_out == NULL || base->writefds_out == NULL) { - sudo_debug_printf(SUDO_DEBUG_WARN, "%s: unable to calloc(1, %zu)", - __func__, sizeof(fd_mask)); + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, + "%s: unable to calloc(1, %zu)", __func__, sizeof(fd_mask)); sudo_ev_base_free_impl(base); debug_return_int(-1); } @@ -97,7 +97,7 @@ sudo_ev_add_impl(struct sudo_event_base *base, struct sudo_event *ev) wfds_out = reallocarray(base->writefds_out, n, sizeof(fd_mask)); if (rfds_in == NULL || wfds_in == NULL || rfds_out == NULL || wfds_out == NULL) { - sudo_debug_printf(SUDO_DEBUG_WARN, + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, "%s: unable to reallocarray(%d, %zu)", __func__, n, sizeof(fd_mask)); free(rfds_in); -- 2.50.1