[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patching an itch (part 1)
From: |
Chip Seraphine |
Subject: |
Patching an itch (part 1) |
Date: |
Wed, 05 Nov 2003 17:02:03 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.2.1) Gecko/20030121 |
Here's a couple of very small local patches I've been using for a while here.
Not sure wether or not they are of sufficiently general interest to warrant
inclusion, but I figure I'd let Mark decide that :-)
This one allows for the builder to optionally define CF_LOG_DFLT. If this is
done, that level is used for 'cfinform' messages. I did this because some log
monitoring software considers 'notice' to be worthy of forwarding on to an
admin,
so I wanted routine cfengine traffic to go to the 'inform' priority instead.
It also slightly changes the way Pekka Savola's "%-stripper" code works, so that
it only replaces % signs if they appear to actually escape something. (This
makes certain log messages more readable.) It also adds an ifndef around so
that sites using a modern/secure syslogd can turn this off altogether when
compiling by defining NO_SAFE_SYSLOG_BUFFER.
--- cfengine-2.1.0p1/src/log.c Fri Oct 3 16:15:17 2003
+++ cfengine-2.1.0p1-new/src/log.c Wed Nov 5 14:36:45 2003
@@ -101,18 +102,23 @@
strncpy(buffer,string,1022);
buffer[1023] = '\0';
+#ifndef NO_SAFE_SYSLOG_BUFFER
/* Check for %s %m which someone might be able to insert into
an error message in order to get a syslog buffer overflow...
bug reported by Pekka Savola */
+/* Slight tweak: Only do this if the following character looks
+ like an expansion of some kind, so that %m => %? but 10% is
+ still 10% */
+
for (sp = buffer; *sp != '\0'; sp++)
{
- if (*sp == '%')
+ if (*sp == '%' && (*(sp+1) > 0x20))
{
*sp = '?';
}
}
-
+#endif
#if defined HAVE_PTHREAD_H && (defined HAVE_LIBPTHREAD || defined
BUILDTIN_GCC_THREAD)
if (!SILENT && (pthread_mutex_lock(&MUTEX_SYSCALL) != 0))
@@ -147,7 +153,7 @@
if (LOGGING && IsPrivileged() && !DONTDO)
{
- syslog(LOG_NOTICE, "%s", buffer);
+ syslog(CF_LOG_DFLT, "%s", buffer);
if (strlen(errstr) != 0)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Patching an itch (part 1),
Chip Seraphine <=