All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Haitao <penght@cn.fujitsu.com>
To: Steve Grubb <sgrubb@redhat.com>
Cc: audit-list <linux-audit@redhat.com>
Subject: [PATCH] Fix a bug of executing "ausearch -te today PM"
Date: Thu, 04 Sep 2008 16:56:41 +0800	[thread overview]
Message-ID: <48BFA2C9.90700@cn.fujitsu.com> (raw)

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 <penght@cn.fujitsu.com>

---
 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

             reply	other threads:[~2008-09-04  8:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-04  8:56 Peng Haitao [this message]
2008-10-18 15:26 ` [PATCH] Fix a bug of executing "ausearch -te today PM" Steve Grubb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48BFA2C9.90700@cn.fujitsu.com \
    --to=penght@cn.fujitsu.com \
    --cc=linux-audit@redhat.com \
    --cc=sgrubb@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.