commit 87d8fd784b078aafeb2603d51e6369e9101278ca
parent 51efd84b6efbf14b4f2d5fb80de2fced8d073afa
Author: Joris Vink <joris@coders.se>
Date: Fri, 5 Jul 2013 22:03:05 +0200
do not attempt to log the user-agent if it's not available.
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/accesslog.c b/src/accesslog.c
@@ -151,7 +151,14 @@ kore_accesslog(struct http_request *req)
logpacket.time_req = req->end - req->start;
kore_strlcpy(logpacket.host, req->host, sizeof(logpacket.host));
kore_strlcpy(logpacket.path, req->path, sizeof(logpacket.path));
- kore_strlcpy(logpacket.agent, req->agent, sizeof(logpacket.agent));
+
+ if (req->agent != NULL) {
+ kore_strlcpy(logpacket.agent,
+ req->agent, sizeof(logpacket.agent));
+ } else {
+ kore_strlcpy(logpacket.agent, "unknown",
+ sizeof(logpacket.agent));
+ }
len = send(accesslog_fd[1], &logpacket, sizeof(logpacket), 0);
if (len == -1) {