* [PATCH] Fix a bug of executing "ausearch -te today PM"
@ 2008-09-04 8:56 Peng Haitao
2008-10-18 15:26 ` Steve Grubb
0 siblings, 1 reply; 2+ messages in thread
From: Peng Haitao @ 2008-09-04 8:56 UTC (permalink / raw)
To: Steve Grubb; +Cc: audit-list
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix a bug of executing "ausearch -te today PM"
2008-09-04 8:56 [PATCH] Fix a bug of executing "ausearch -te today PM" Peng Haitao
@ 2008-10-18 15:26 ` Steve Grubb
0 siblings, 0 replies; 2+ messages in thread
From: Steve Grubb @ 2008-10-18 15:26 UTC (permalink / raw)
To: Peng Haitao; +Cc: audit-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-18 15:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-04 8:56 [PATCH] Fix a bug of executing "ausearch -te today PM" Peng Haitao
2008-10-18 15:26 ` Steve Grubb
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox