... created by ACLFilledChecklist::syncAle().
::syncAle() is the only place in the codebase that assigns a URL that
AccessLogEntry is expected to free(), which AccessLogEntry doesn't do.
This results in a memory leak.
This is submitted on behalf of Bloomberg L.P.
#include "LogTags.h"
#include "MessageSizes.h"
#include "Notes.h"
+#include "sbuf/SBuf.h"
#if ICAP_CLIENT
#include "adaptation/icap/Elements.h"
#endif
/// Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)
SBuf getLogMethod() const;
- const char *url;
+ SBuf url;
/// TCP/IP level details about the client connection
Comm::ConnectionPointer tcpClient;
HTTPMSGLOCK(al->adapted_request);
}
- if (!al->url) {
+ if (al->url.isEmpty()) {
showDebugWarning("URL");
- al->url = xstrdup(request->url.absolute().c_str());
+ al->url = request->url.absolute();
}
}
/// Convert a string to NULL pointer if it is ""
#define strOrNull(s) ((s)==NULL||(s)[0]=='\0'?NULL:(s))
+const SBuf Format::Dash("-");
+
Format::Format::Format(const char *n) :
format(NULL),
next(NULL)
break;
case LFT_REQUEST_URI:
- out = al->url;
+ if (!al->url.isEmpty()) {
+ const SBuf &s = al->url;
+ sb.append(s.rawContent(), s.length());
+ out = sb.termedBuf();
+ }
break;
case LFT_REQUEST_VERSION_OLD_2X:
#include "base/RefCount.h"
#include "ConfigParser.h"
+#include "sbuf/SBuf.h"
/*
* Squid configuration allows users to define custom formats in
namespace Format
{
+extern const SBuf Dash;
+
class Token;
// XXX: inherit from linked list
const SBuf method(al->getLogMethod());
- logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s:%s%s",
+ logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " " SQUIDSBUFPH " %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s:%s%s",
clientip,
user_ident ? user_ident : dash_str,
user_auth ? user_auth : dash_str,
Time::FormatHttpd(squid_curtime),
SQUIDSBUFPRINT(method),
- al->url,
+ SQUIDSBUFPRINT(al->url),
AnyP::ProtocolType_str[al->http.version.protocol],
al->http.version.major, al->http.version.minor,
al->http.code,
const SBuf method(al->getLogMethod());
- logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " %s:%s%s",
+ logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " " SQUIDSBUFPH " %s/%d.%d\" %d %" PRId64 " %s:%s%s",
clientip,
user_ident ? user_ident : dash_str,
user_auth ? user_auth : dash_str,
Time::FormatHttpd(squid_curtime),
SQUIDSBUFPRINT(method),
- al->url,
+ SQUIDSBUFPRINT(al->url),
AnyP::ProtocolType_str[al->http.version.protocol],
al->http.version.major, al->http.version.minor,
al->http.code,
const SBuf method(al->getLogMethod());
- logfilePrintf(logfile, "%9ld.%03d %6ld %s %s/%03d %" PRId64 " " SQUIDSBUFPH " %s %s %s%s/%s %s%s",
+ logfilePrintf(logfile, "%9ld.%03d %6ld %s %s/%03d %" PRId64 " " SQUIDSBUFPH " " SQUIDSBUFPH " %s %s%s/%s %s%s",
(long int) current_time.tv_sec,
(int) current_time.tv_usec / 1000,
tvToMsec(al->cache.trTime),
al->http.code,
al->http.clientReplySz.messageTotal(),
SQUIDSBUFPRINT(method),
- al->url,
+ SQUIDSBUFPRINT(al->url),
user ? user : dash_str,
al->hier.ping.timedout ? "TIMEOUT_" : "",
hier_code_str[al->hier.code],
char clientip[MAX_IPSTRLEN];
al->getLogClientIp(clientip, MAX_IPSTRLEN);
- logfilePrintf(logfile, "%9ld.%03d %s %s %s\n",
+ const SBuf url = !al->url.isEmpty() ? al->url : ::Format::Dash;
+
+ logfilePrintf(logfile, "%9ld.%03d %s %s " SQUIDSBUFPH "\n",
(long int) current_time.tv_sec,
(int) current_time.tv_usec / 1000,
clientip,
referer,
- al->url ? al->url : "-");
+ SQUIDSBUFPRINT(url));
}
accessLogLogTo(CustomLog* log, AccessLogEntry::Pointer &al, ACLChecklist * checklist)
{
- if (al->url == NULL)
- al->url = dash_str;
+ if (al->url.isEmpty())
+ al->url = Format::Dash;
if (!al->http.content_type || *al->http.content_type == '\0')
al->http.content_type = dash_str;
else {
unsigned int ibuf[365];
size_t isize;
- xstrncpy((char *) ibuf, al->url, 364 * sizeof(int));
- isize = ((strlen(al->url) + 8) / 8) * 2;
+ xstrncpy((char *) ibuf, al->url.c_str(), 364 * sizeof(int));
+ isize = ((al->url.length() + 8) / 8) * 2;
if (isize > 364)
isize = 364;