[PATCH 11/13] mghttpd: Allow to have no timegm().
Christian Mauderer
christian.mauderer at embedded-brains.de
Thu Apr 21 08:49:51 UTC 2016
From: Christian Mauderer <Christian.Mauderer at embedded-brains.de>
We currently don't have a timegm function. There seems to be no easy
way to replace this function with POSIX functions in a thread save
way. This patch just avoids the call.
Note that with this solution, the caching feature is effectively
disabled.
---
cpukit/mghttpd/civetweb.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/cpukit/mghttpd/civetweb.c b/cpukit/mghttpd/civetweb.c
index edc13d6..41c3eed 100644
--- a/cpukit/mghttpd/civetweb.c
+++ b/cpukit/mghttpd/civetweb.c
@@ -4918,6 +4918,7 @@ get_month_index(const char *s)
/* Parse UTC date-time string, and return the corresponding time_t value. */
+#if !defined(NO_TIMEGM)
static time_t
parse_date_string(const char *datetime)
{
@@ -4971,6 +4972,7 @@ parse_date_string(const char *datetime)
return result;
}
+#endif /* !NO_TIMEGM */
/* Protect against directory disclosure attack by removing '..',
@@ -7051,6 +7053,7 @@ substitute_index_file(struct mg_connection *conn,
static int
is_not_modified(const struct mg_connection *conn, const struct file *filep)
{
+#if !defined(NO_TIMEGM)
char etag[64];
const char *ims = mg_get_header(conn, "If-Modified-Since");
const char *inm = mg_get_header(conn, "If-None-Match");
@@ -7060,6 +7063,9 @@ is_not_modified(const struct mg_connection *conn, const struct file *filep)
}
return (inm != NULL && !mg_strcasecmp(etag, inm))
|| (ims != NULL && (filep->last_modified <= parse_date_string(ims)));
+#else /* NO_TIMEGM */
+ return false;
+#endif /* !NO_TIMEGM */
}
--
1.8.4.5
More information about the devel
mailing list