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(a)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
Show replies by date
Hello Peng,
On Thursday 04 September 2008 04:56:41 Peng Haitao wrote:
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.
I didn't forget this bug. I wanted to investigate its root cause and see what
the problem was. The solution is that I shouldn't have called the "goto
set_it;" unless the variable ti was NULL. I have committed the following
changes to address this problem and clean up a couple more items:
https://fedorahosted.org/audit/changeset/139
Thanks for reporting the bug.
-Steve