[or-cvs] r17688: {tor} One log.c XXX021 was a misunderstanding. Also, clip log mess (in tor/trunk: . src/common)
nickm at seul.org
nickm at seul.org
Thu Dec 18 17:18:09 UTC 2008
Author: nickm
Date: 2008-12-18 12:18:06 -0500 (Thu, 18 Dec 2008)
New Revision: 17688
Modified:
tor/trunk/ChangeLog
tor/trunk/src/common/log.c
Log:
One log.c XXX021 was a misunderstanding. Also, clip log messages passed to syslog to their maximum length when there is a maximum.
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2008-12-18 16:56:00 UTC (rev 17687)
+++ tor/trunk/ChangeLog 2008-12-18 17:18:06 UTC (rev 17688)
@@ -40,6 +40,9 @@
pairs. Partial implementation of proposal 157.
- Clients now never report any stream end reason except 'MISC'.
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):
- New CONSENSUS_ARRIVED event to note when a new consensus has
Modified: tor/trunk/src/common/log.c
===================================================================
--- tor/trunk/src/common/log.c 2008-12-18 16:56:00 UTC (rev 17687)
+++ tor/trunk/src/common/log.c 2008-12-18 17:18:06 UTC (rev 17688)
@@ -299,10 +299,24 @@
}
if (lf->is_syslog) {
#ifdef HAVE_SYSLOG_H
- /* XXXX Some syslog implementations have scary limits on the length of
- * what you can pass them. Can/should we detect this? */
- syslog(severity, "%s", end_of_prefix);
+ char *m = end_of_prefix;
+#ifdef MAXLINE
+ /* 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
lf = lf->next;
continue;
} else if (lf->callback) {
@@ -739,9 +753,8 @@
"OR", "EDGE", "ACCT", "HIST", NULL
};
-/** Return the log domain for which <b>domain</b> is the name, or 0 if there
- * is no such name. */
-/*XXXX021 0 could mean "no such domain" or LD_GENERAL. Fix that. */
+/** Return a bitmask for the log domain for which <b>domain</b> is the name,
+ * or 0 if there is no such name. */
static log_domain_mask_t
parse_log_domain(const char *domain)
{
More information about the tor-commits
mailing list