mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
ACCESS_LOG: truncate referrer always leaving enough room for at least an empty useragent and delimiters
This commit is contained in:
parent
f8fad0d350
commit
4046239bc8
1 changed files with 10 additions and 2 deletions
|
@ -3270,9 +3270,17 @@ lws_access_log(struct lws *wsi)
|
|||
if (!p1)
|
||||
p1 = "";
|
||||
|
||||
l = lws_snprintf(ass, sizeof(ass) - 1, "%s %d %lu \"%s\" \"%s\"\n",
|
||||
/*
|
||||
* We do this in two parts to restrict an oversize referrer such that
|
||||
* we will always have space left to append an empty useragent, while
|
||||
* maintaining the structure of the log text
|
||||
*/
|
||||
l = lws_snprintf(ass, sizeof(ass) - 7, "%s %d %lu \"%s",
|
||||
wsi->access_log.header_log,
|
||||
wsi->access_log.response, wsi->access_log.sent, p1, p);
|
||||
wsi->access_log.response, wsi->access_log.sent, p1);
|
||||
if (strlen(p) > sizeof(ass) - 6 - l)
|
||||
p[sizeof(ass) - 6 - l] = '\0';
|
||||
l += lws_snprintf(ass + l, sizeof(ass) - 1 - l, "\" \"%s\"\n", p);
|
||||
|
||||
if (wsi->vhost->log_fd != (int)LWS_INVALID_FILE) {
|
||||
if (write(wsi->vhost->log_fd, ass, l) != l)
|
||||
|
|
Loading…
Add table
Reference in a new issue