From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peng Haitao Subject: [PATCH] Fix a bug of executing "ausearch -te today PM" Date: Thu, 04 Sep 2008 16:56:41 +0800 Message-ID: <48BFA2C9.90700@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: Steve Grubb Cc: audit-list List-Id: linux-audit@redhat.com Hello steve, executing "ausearch -te today PM" should be report error, but its result is equal to the result of executing "ausearch -te today" in audit > 1.7.4. Signed-off-by: Peng Haitao --- src/ausearch-time.c | 45 +++++++++++++++++++++------------------------ 1 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/ausearch-time.c b/src/ausearch-time.c index 5fc6d48..a9537d4 100644 --- a/src/ausearch-time.c +++ b/src/ausearch-time.c @@ -259,7 +259,6 @@ int ausearch_time_start(const char *da, const char *ti) { /* If da == NULL, use current date */ /* If ti == NULL, then use midnight 00:00:00 */ - int rc = 0; struct tm d, t; char *ret; int keyword=-1; @@ -282,8 +281,13 @@ int ausearch_time_start(const char *da, const char *ti) } } else { keyword=lookup_time(da); - if (keyword == T_RECENT || keyword == T_NOW) - goto set_it; + if (keyword == T_RECENT || keyword == T_NOW) { + start_time = mktime(&d); + if (start_time == -1) { + fprintf(stderr, "Error converting start time\n"); + return -1; + } + } } } @@ -315,20 +319,14 @@ int ausearch_time_start(const char *da, const char *ti) fprintf(stderr, "Error - year is %d\n", d.tm_year+1900); return -1; } -set_it: - start_time = mktime(&d); - if (start_time == -1) { - fprintf(stderr, "Error converting start time\n"); - rc = -1; - } - return rc; + + return 0; } int ausearch_time_end(const char *da, const char *ti) { /* If date == NULL, use current date */ /* If ti == NULL, use current time */ - int rc = 0; struct tm d, t; char *ret; @@ -348,12 +346,16 @@ int ausearch_time_end(const char *da, const char *ti) } } else { int keyword=lookup_time(da); - if (keyword == T_RECENT || keyword == T_NOW) - goto set_it; - // Special case today - if (keyword == T_TODAY) { - set_tm_now(&d); - goto set_it; + if (keyword == T_RECENT || keyword == T_NOW || keyword == T_TODAY) { + // Special case today + if (keyword == T_TODAY) { + set_tm_now(&d); + } + end_time = mktime(&d); + if (end_time == -1) { + fprintf(stderr, "Error converting end time\n"); + return -1; + } } } } @@ -390,12 +392,7 @@ int ausearch_time_end(const char *da, const char *ti) fprintf(stderr, "Error - year is %d\n", d.tm_year+1900); return -1; } -set_it: - end_time = mktime(&d); - if (end_time == -1) { - fprintf(stderr, "Error converting end time\n"); - rc = -1; - } - return rc; + + return 0; } -- 1.5.3 -- Regards Peng Haitao