[icinga-checkins] icinga.org: icinga-core/master: Fixed cgi/ cgiutils.c NULL value with segfault in get_time_string #11048
git at icinga.org
git at icinga.org
Tue Feb 2 23:28:26 CET 2016
Module: icinga-core
Branch: master
Commit: a3f736edf2da803ca422b26d436da5389a51665a
URL: https://git.icinga.org/?p=icinga-core.git;a=commit;h=a3f736edf2da803ca422b26d436da5389a51665a
Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date: Tue Feb 2 21:48:36 2016 +0100
Fixed cgi/cgiutils.c NULL value with segfault in get_time_string #11048
Refs: #11048
whatthecommit: Well, it's doing something.
---
cgi/cgiutils.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index 528ca8d..147ffea 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -1809,6 +1809,18 @@ void get_time_string(time_t *raw_time, char *buffer, int buffer_length, int type
else
tm_ptr = localtime(&t);
+ if (tm_ptr==NULL) {
+ //we read at least the local time
+ t = time(NULL);
+ tm_ptr = gmtime(&t);
+ }
+
+ if (tm_ptr==NULL) {
+ snprintf(buffer, buffer_length, "Error retrieving current time!");
+ buffer[buffer_length - 1] = '\x0';
+ return;
+ }
+
hour = tm_ptr->tm_hour;
minute = tm_ptr->tm_min;
second = tm_ptr->tm_sec;
More information about the icinga-checkins
mailing list