[icinga-checkins] icinga.org: icinga-core/r1.8: classic-ui: segfault when reading malformed log entries #3528

git at icinga.org git at icinga.org
Mon Mar 4 19:21:42 CET 2013


Module: icinga-core
Branch: r1.8
Commit: c76567f406dbb95331c384a6ade2377867ff0cd7
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=c76567f406dbb95331c384a6ade2377867ff0cd7

Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date:   Tue Jan 22 20:53:45 2013 +0100

classic-ui: segfault when reading malformed log entries #3528

refs: #3528

now we check if temp_buffer is actually filled before we pass it
on to strstr.

Conflicts:
	Changelog

---

 Changelog      |    1 +
 cgi/readlogs.c |    9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/Changelog b/Changelog
index 81bafb8..daeaac4 100644
--- a/Changelog
+++ b/Changelog
@@ -16,6 +16,7 @@ UPGRADE NOTES
 
 FIXES
 * classic ui: fixed JSON output is insufficiently escaped #3541 - RB
+* classic ui: fixed segfault when reading malformed log entries #3528 - RB
 
 * idoutils: idomod leaks memory on core reload #3749 - GB
 
diff --git a/cgi/readlogs.c b/cgi/readlogs.c
index 3c3d87a..90867e3 100644
--- a/cgi/readlogs.c
+++ b/cgi/readlogs.c
@@ -382,7 +382,11 @@ int get_log_entries(logentry **entry_list, logfilter **filter_list, char **error
 
 			/* get timestamp */
 			temp_buffer = strtok(input, "]");
-			timestamp = (temp_buffer == NULL) ? 0L : strtoul(temp_buffer + 1, NULL, 10);
+
+			if (temp_buffer == NULL)
+				continue;
+
+			timestamp = strtoul(temp_buffer + 1, NULL, 10);
 
 			/* skip line if out of range */
 			if ((ts_end >= 0 && timestamp > ts_end) || (ts_start >= 0 && timestamp < ts_start))
@@ -391,6 +395,9 @@ int get_log_entries(logentry **entry_list, logfilter **filter_list, char **error
 			/* get log entry text */
 			temp_buffer = strtok(NULL, "\n");
 
+			if (temp_buffer == NULL)
+				continue;
+
 			/* if we search for something, check if it entry matches search_string */
 			if (search_string != NULL) {
 				if (regexec(&preg, temp_buffer, 0, NULL, 0) == REG_NOMATCH)





More information about the icinga-checkins mailing list