From fe0e953e9b20dbd0929fbd6aefc53711c9c456d7 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 21 Oct 2013 16:00:29 -0600 Subject: [PATCH] Fix AND operator broken by changes to fix OR. --- plugins/sudoers/sudoreplay.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c index 1f7fe90c4..31f089746 100644 --- a/plugins/sudoers/sudoreplay.c +++ b/plugins/sudoers/sudoreplay.c @@ -783,10 +783,13 @@ match_expr(struct search_node *head, struct log_info *log, bool last_match) case ST_TODATE: res = log->tstamp <= sn->u.tstamp; break; + default: + fatalx(_("unknown search type %d"), sn->type); + /* NOTREACHED */ } if (sn->negated) res = !res; - matched = sn->or ? (res || last_match) : res; + matched = sn->or ? (res || last_match) : (res && last_match); last_match = matched; } debug_return_bool(matched); @@ -799,7 +802,7 @@ parse_logfile(char *logfile) char *buf = NULL, *cp, *ep; size_t bufsize = 0, cwdsize = 0, cmdsize = 0; struct log_info *li = NULL; - debug_decl(list_session, SUDO_DEBUG_UTIL) + debug_decl(parse_logfile, SUDO_DEBUG_UTIL) fp = fopen(logfile, "r"); if (fp == NULL) { @@ -906,7 +909,7 @@ list_session(char *logfile, REGEX_T *re, const char *user, const char *tty) goto done; /* Match on search expression if there is one. */ - if (search_expr && !match_expr(search_expr, li, false)) + if (search_expr && !match_expr(search_expr, li, true)) goto done; /* Convert from /var/log/sudo-sessions/00/00/01/log to 000001 */ -- 2.40.0