summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2005-07-29 08:22:50 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2005-07-29 08:22:50 +0000
commit17869a5ba296c5a39e4ea2481ca3d8c6948b7cdd (patch)
treebf46ca5f2e5c0c55876300d04c382c7bfa0114a1
parent9c4eb8b20401b6e36a0b877a111e3d02b62b13d2 (diff)
downloadrsyslog-17869a5ba296c5a39e4ea2481ca3d8c6948b7cdd.tar.gz
rsyslog-17869a5ba296c5a39e4ea2481ca3d8c6948b7cdd.tar.xz
rsyslog-17869a5ba296c5a39e4ea2481ca3d8c6948b7cdd.zip
fixed 'the semicolon bug' in the write database action. Also fixed a bug
that caused rsyslogd to dump core when the template for database was not found. There still is an issue with the other actions and invalid template names.
-rw-r--r--Makefile6
-rw-r--r--syslogd.c39
2 files changed, 31 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index c2b6b12e..67b9ffde 100644
--- a/Makefile
+++ b/Makefile
@@ -17,8 +17,8 @@ CC= gcc
# enables the MySQL code. By default, that one is commented out
# change the comment chars to activate it if you need MySQL!
# In this case, also look down further to uncomment the libs
-CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce $(NOLARGEFILE)
-#CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce -DWITH_DB -I/usr/local/include $(NOLARGEFILE)
+#CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce $(NOLARGEFILE)
+CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce -DWITH_DB -I/usr/local/include $(NOLARGEFILE)
LDFLAGS= -s
INSTALL = install
@@ -26,7 +26,7 @@ BINDIR = /usr/sbin
MANDIR = /usr/share/man
# Uncomment the following to use mysql.
-#LIBS = -lmysqlclient -L/usr/local/lib/mysql
+LIBS = -lmysqlclient -L/usr/local/lib/mysql
# There is one report that under an all ELF system there may be a need to
# explicilty link with libresolv.a. If linking syslogd fails you may wish
diff --git a/syslogd.c b/syslogd.c
index 074d4da6..8c625709 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -2250,7 +2250,7 @@ int main(argc, argv)
break;
case 'v':
printf("rsyslogd %s.%s\n", VERSION, PATCHLEVEL);
- exit (0);
+ exit(0);
case '?':
default:
usage();
@@ -4279,7 +4279,7 @@ void die(sig)
void doexit(sig)
int sig;
{
- exit (0);
+ exit(0);
}
#endif
@@ -4640,21 +4640,23 @@ void cflineSetTemplateAndIOV(struct filed *f, char *pTemplateName)
*/
if((f->f_pTpl = tplFind(pTemplateName, strlen(pTemplateName))) == NULL) {
snprintf(errMsg, sizeof(errMsg) / sizeof(char),
- "rsyslogd: Could not find template '%s'\n", pTemplateName);
- logmsgInternal(LOG_SYSLOG|LOG_ERR, errMsg, LocalHostName, ADDDATE);
- dprintf(errMsg);
+ "rsyslogd: Could not find template '%s' - selector line disabled\n",
+ pTemplateName);
+ errno = 0;
+ logerror(errMsg);
f->f_type = F_UNUSED;
} else {
if((f->f_iov = calloc(tplGetEntryCount(f->f_pTpl),
sizeof(struct iovec))) == NULL) {
/* TODO: provide better message! */
- dprintf("Could not allocate iovec memory\n");
+ errno = 0;
+ logerror("Could not allocate iovec memory - 1 selector line disabled\n");
f->f_type = F_UNUSED;
}
if((f->f_bMustBeFreed = calloc(tplGetEntryCount(f->f_pTpl),
sizeof(unsigned short))) == NULL) {
- /* TODO: provide better message! */
- dprintf("Could not allocate bMustBeFreed memory\n");
+ errno = 0;
+ logerror("Could not allocate bMustBeFreed memory - 1 selector line disabled\n");
f->f_type = F_UNUSED;
}
}
@@ -5195,6 +5197,15 @@ void cfline(line, f)
strcpy(szTemplateName, " StdDBFmt");
cflineSetTemplateAndIOV(f, szTemplateName);
+
+ /* we now check if the template was present. If not, we
+ * can abort this run as the selector line has been
+ * disabled. If we don't abort, we'll core dump
+ * below. rgerhards 2005-07-29
+ */
+ if(f->f_type == F_UNUSED)
+ break;
+
dprintf(" template '%s'\n", szTemplateName);
/* If db used, the template have to use the SQL option.
@@ -5202,8 +5213,9 @@ void cfline(line, f)
if (f->f_pTpl->optFormatForSQL != 1)
{
f->f_type = F_UNUSED;
- dprintf("DB logging disabled. You have to use"
+ logerror("DB logging disabled. You have to use"
" the SQL option in your template!\n");
+ break;
}
@@ -5544,8 +5556,13 @@ int getSubString(char **ppSrc, char *pDst, size_t DstSize, char cSep)
dprintf("in getSubString, error Src buffer > Dst buffer\n");
iErr = 1;
}
- if (*pSrc != '\0')
- *ppSrc=pSrc+1;
+ if (*pSrc == '\0')
+ /* this line was missing, causing ppSrc to be invalid when it
+ * was returned in case of end-of-string. rgerhards 2005-07-29
+ */
+ *ppSrc = pSrc;
+ else
+ *ppSrc = pSrc+1;
*pDst = '\0';
return iErr;
}