One log.c XXX021 was a misunderstanding. Also, clip log messages passed to syslog to their maximum length when there is a maximum.

svn:r17688
This commit is contained in:
Nick Mathewson 2008-12-18 17:18:06 +00:00
parent 122170c1d3
commit b6f89a647a
2 changed files with 22 additions and 6 deletions

View File

@ -40,6 +40,9 @@ Changes in version 0.2.1.9-alpha - 2008-12-2?
pairs. Partial implementation of proposal 157. pairs. Partial implementation of proposal 157.
- Clients now never report any stream end reason except 'MISC'. - Clients now never report any stream end reason except 'MISC'.
Implements proposal 148. Implements proposal 148.
- On platforms with a maximum syslog string length, truncate syslog
messages to that length ourselves, rather than relying on the
system to do it for us.
o Minor features (controller): o Minor features (controller):
- New CONSENSUS_ARRIVED event to note when a new consensus has - New CONSENSUS_ARRIVED event to note when a new consensus has

View File

@ -299,9 +299,23 @@ logv(int severity, log_domain_mask_t domain, const char *funcname,
} }
if (lf->is_syslog) { if (lf->is_syslog) {
#ifdef HAVE_SYSLOG_H #ifdef HAVE_SYSLOG_H
/* XXXX Some syslog implementations have scary limits on the length of char *m = end_of_prefix;
* what you can pass them. Can/should we detect this? */ #ifdef MAXLINE
syslog(severity, "%s", end_of_prefix); /* Some syslog implementations have limits on the length of what you can
* pass them, and some very old ones do not detect overflow so well.
* Regrettably, they call their maximum line length MAXLINE. */
#if MAXLINE < 64
#warn "MAXLINE is a very low number; it might not be from syslog.h after all"
#endif
if (msg_len >= MAXLINE)
m = tor_strndup(end_of_prefix, MAXLINE-1);
#endif
syslog(severity, "%s", m);
#ifdef MAXLINE
if (m != end_of_prefix) {
tor_free(m);
}
#endif
#endif #endif
lf = lf->next; lf = lf->next;
continue; continue;
@ -739,9 +753,8 @@ static const char *domain_list[] = {
"OR", "EDGE", "ACCT", "HIST", NULL "OR", "EDGE", "ACCT", "HIST", NULL
}; };
/** Return the log domain for which <b>domain</b> is the name, or 0 if there /** Return a bitmask for the log domain for which <b>domain</b> is the name,
* is no such name. */ * or 0 if there is no such name. */
/*XXXX021 0 could mean "no such domain" or LD_GENERAL. Fix that. */
static log_domain_mask_t static log_domain_mask_t
parse_log_domain(const char *domain) parse_log_domain(const char *domain)
{ {