summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--configure.ac2
-rw-r--r--tests/Makefile.am8
-rwxr-xr-xtests/cfg.sh12
-rw-r--r--tests/ourtail.c43
-rw-r--r--tests/rscript.c41
-rw-r--r--tools/omfwd.c1
-rw-r--r--tools/syslogd.c2
8 files changed, 95 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 4540d6e6..23a2e3e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,8 @@ Version 4.1.6 [DEVEL] (rgerhards), 2009-03-??
- improved omfile so that it properly suspends itself if there is an
i/o or file name generation error. This enables it to be used with
the full high availability features of rsyslog's engine
+- bugfix: fixed some segaults on Solaris, where vsprintf() does not
+ check for NULL pointers
---------------------------------------------------------------------------
Version 4.1.5 [DEVEL] (rgerhards), 2009-03-11
- bugfix: parser did not correctly parse fields in UDP-received messages
diff --git a/configure.ac b/configure.ac
index fcd935e8..2db856cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -98,7 +98,7 @@ AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_STRERROR_R
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([flock basename alarm clock_gettime gethostbyname gethostname gettimeofday localtime_r memset mkdir regcomp select setid socket strcasecmp strchr strdup strerror strndup strnlen strrchr strstr strtol strtoul uname ttyname_r epoll_wait])
+AC_CHECK_FUNCS([flock basename alarm clock_gettime gethostbyname gethostname gettimeofday localtime_r memset mkdir regcomp select setid socket strcasecmp strchr strdup strerror strndup strnlen strrchr strstr strtol strtoul uname ttyname_r epoll_wait getline])
# Check for MAXHOSTNAMELEN
AC_MSG_CHECKING(for MAXHOSTNAMELEN)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f941f3a6..093742db 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-check_PROGRAMS = rt_init rscript parsertest
+check_PROGRAMS = rt_init rscript ourtail parsertest
TESTS = $(check_PROGRAMS) cfg.sh
TESTS_ENVIRONMENT = RSYSLOG_MODDIR='$(abs_top_builddir)'/runtime/.libs/
DISTCLEANFILES=rsyslog.pid
@@ -25,12 +25,14 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testruns/rfc5424-4.parse1 \
cfg.sh
+ourtail_SOURCES = ourtail.c
+
rt_init_SOURCES = rt-init.c $(test_files)
rt_init_CPPFLAGS = -I$(top_srcdir) $(PTHREADS_CFLAGS) $(RSRT_CFLAGS)
-rt_init_LDADD = $(RSRT_LIBS) $(ZLIB_LIBS) $(PTHREADS_LIBS)
+rt_init_LDADD = $(RSRT_LIBS) $(ZLIB_LIBS) $(PTHREADS_LIBS) $(SOL_LIBS)
rt_init_LDFLAGS = -export-dynamic
rscript_SOURCES = rscript.c $(test_files)
rscript_CPPFLAGS = -I$(top_srcdir) $(PTHREADS_CFLAGS) $(RSRT_CFLAGS)
-rscript_LDADD = $(RSRT_LIBS) $(ZLIB_LIBS) $(PTHREADS_LIBS)
+rscript_LDADD = $(RSRT_LIBS) $(ZLIB_LIBS) $(PTHREADS_LIBS) $(SOL_LIBS)
rscript_LDFLAGS = -export-dynamic
diff --git a/tests/cfg.sh b/tests/cfg.sh
index fb22fbf3..8acbf342 100755
--- a/tests/cfg.sh
+++ b/tests/cfg.sh
@@ -36,7 +36,7 @@ echo "local directory"
#
# check empty config file
#
-../tools/rsyslogd -c4 -N1 -f/dev/null 2>&1 |tail --lines=+2 > tmp
+../tools/rsyslogd -c4 -N1 -f/dev/null 2>&1 |./ourtail > tmp
cmp tmp $srcdir/DevNull.cfgtest
if [ ! $? -eq 0 ]; then
echo "DevNull.cfgtest failed"
@@ -51,7 +51,7 @@ fi;
#
# check missing config file
#
-../tools/rsyslogd -c4 -N1 -f/This/does/not/exist 2>&1 |tail --lines=+2 > tmp
+../tools/rsyslogd -c4 -N1 -f/This/does/not/exist 2>&1 |./ourtail > tmp
cmp tmp $srcdir/NoExistFile.cfgtest
if [ ! $? -eq 0 ]; then
echo "NoExistFile.cfgtest failed"
@@ -74,7 +74,7 @@ exit 0
#
# check config with invalid directive
#
-../tools/rsyslogd -c4 -u2 -N1 -f$srcdir/cfg1.testin 2>&1 |tail --lines=+2 > tmp
+../tools/rsyslogd -c4 -u2 -N1 -f$srcdir/cfg1.testin 2>&1 |./ourtail > tmp
cmp tmp $srcdir/cfg1.cfgtest
if [ ! $? -eq 0 ]; then
echo "cfg1.cfgtest failed"
@@ -91,7 +91,7 @@ fi;
# the one with the invalid config directive, so that we may see
# an effect of the included config ;)
#
-../tools/rsyslogd -c4 -u2 -N1 -f$srcdir/cfg2.testin 2>&1 |tail --lines=+2 > tmp
+../tools/rsyslogd -c4 -u2 -N1 -f$srcdir/cfg2.testin 2>&1 |./ourtail > tmp
cmp tmp $srcdir/cfg2.cfgtest
if [ ! $? -eq 0 ]; then
echo "cfg2.cfgtest failed"
@@ -106,7 +106,7 @@ fi;
#
# check included config file, where included file does not exist
#
-../tools/rsyslogd -c4 -u2 -N1 -f$srcdir/cfg3.testin 2>&1 |tail --lines=+2 > tmp
+../tools/rsyslogd -c4 -u2 -N1 -f$srcdir/cfg3.testin 2>&1 |./ourtail > tmp
cmp tmp $srcdir/cfg3.cfgtest
if [ ! $? -eq 0 ]; then
echo "cfg3.cfgtest failed"
@@ -121,7 +121,7 @@ fi;
#
# check a reasonable complex, but correct, log file
#
-../tools/rsyslogd -c4 -u2 -N1 -f$srcdir/cfg4.testin 2>&1 |tail --lines=+2 > tmp
+../tools/rsyslogd -c4 -u2 -N1 -f$srcdir/cfg4.testin 2>&1 |./ourtail > tmp
cmp tmp $srcdir/cfg4.cfgtest
if [ ! $? -eq 0 ]; then
echo "cfg4.cfgtest failed"
diff --git a/tests/ourtail.c b/tests/ourtail.c
new file mode 100644
index 00000000..f2751c72
--- /dev/null
+++ b/tests/ourtail.c
@@ -0,0 +1,43 @@
+/* This is a quick and dirty "tail implementation", one which always
+ * skips the first line, but nothing else. I have done this to prevent
+ * the various incompatible options of tail come into my way. One could
+ * probably work around this by using autoconf magic, but for me it
+ * was much quicker writing this small C program, which really should
+ * be portable across all platforms.
+ *
+ * Part of the testbench for rsyslog.
+ *
+ * Copyright 2009 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This file is part of rsyslog.
+ *
+ * Rsyslog is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Rsyslog is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ int c;
+
+ for(c = getchar() ; c != EOF && c != '\n' ; c = getchar())
+ /*skip to newline*/;
+
+ if(c == '\n')
+ c = getchar();
+
+ for( ; c != EOF ; c = getchar())
+ putchar(c);
+}
diff --git a/tests/rscript.c b/tests/rscript.c
index 3eec9c3c..4906f91a 100644
--- a/tests/rscript.c
+++ b/tests/rscript.c
@@ -39,6 +39,38 @@ DEFobjCurrIf(ctok)
DEFobjCurrIf(ctok_token)
DEFobjCurrIf(vmprg)
+
+/* we emulate getline (the dirty way) if we do not have it
+ * We do not try very hard, as this is just a test driver.
+ * rgerhards, 2009-03-31
+ */
+#ifndef HAVE_GETLINE
+ssize_t getline(char **lineptr, size_t *n, FILE *fp)
+{
+ int c;
+ int len = 0;
+
+ if(*lineptr == NULL)
+ *lineptr = malloc(1024); /* quick and dirty! */
+
+ c = fgetc(fp);
+ while(c != EOF && c != '\n') {
+ (*lineptr)[len++] = c;
+ c = fgetc(fp);
+ }
+ if(c != EOF) /* need to add NL? */
+ (*lineptr)[len++] = c;
+
+ (*lineptr)[len] = '\0';
+
+ *n = len;
+ //printf("getline returns: '%s'\n", *lineptr);
+
+ return (len > 0) ? len : -1;
+}
+#endif /* #ifndef HAVE_GETLINE */
+
+
BEGINInit
CODESTARTInit
pErrObj = "expr"; CHKiRet(objUse(expr, CORE_COMPONENT));
@@ -101,10 +133,9 @@ PerformTest(cstr_t *pstrIn, rsRetVal iRetExpected, cstr_t *pstrOut)
CHKiRet(vmprg.Obj2Str(pExpr->pVmprg, pstrPrg));
if(strcmp((char*)rsCStrGetSzStr(pstrPrg), (char*)rsCStrGetSzStr(pstrOut))) {
- int iLen;
printf("error: compiled program different from expected result!\n");
- printf("generated vmprg (%d bytes):\n%s\n", strlen(rsCStrGetSzStr(pstrPrg)), rsCStrGetSzStr(pstrPrg));
- printf("expected (%d bytes):\n%s\n", strlen(rsCStrGetSzStr(pstrOut)), rsCStrGetSzStr(pstrOut));
+ printf("generated vmprg (%d bytes):\n%s\n", strlen((char*)rsCStrGetSzStr(pstrPrg)), rsCStrGetSzStr(pstrPrg));
+ printf("expected (%d bytes):\n%s\n", strlen((char*)rsCStrGetSzStr(pstrOut)), rsCStrGetSzStr(pstrOut));
ABORT_FINALIZE(RS_RET_ERR);
}
@@ -139,6 +170,7 @@ ProcessTestFile(uchar *pszFileName)
size_t lenLn;
cstr_t *pstrIn = NULL;
cstr_t *pstrOut = NULL;
+ int iParse;
rsRetVal iRetExpected;
DEFiRet;
@@ -161,10 +193,11 @@ ProcessTestFile(uchar *pszFileName)
/* once we had a comment, the next line MUST be "result: <nbr>". Anything
* after nbr is simply ignored.
*/
- if(sscanf(lnptr, "result: %d", &iRetExpected) != 1) {
+ if(sscanf(lnptr, "result: %d", &iParse) != 1) {
printf("error in result line, scanf failed, line: '%s'\n", lnptr);
ABORT_FINALIZE(RS_RET_ERR);
}
+ iRetExpected = iParse;
getline(&lnptr, &lenLn, fp); CHKEOF;
/* and now we look for "in:" (and again ignore the rest...) */
diff --git a/tools/omfwd.c b/tools/omfwd.c
index 1dd184ef..7a945ce0 100644
--- a/tools/omfwd.c
+++ b/tools/omfwd.c
@@ -615,7 +615,6 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
} else {
CHKmalloc(pData->f_hname = strdup((char*) q));
}
-dbgprintf("hostname '%s', port '%s'\n", pData->f_hname, pData->port);
/* process template */
CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, OMSR_NO_RQD_TPL_OPTS,
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 9f962899..c72160fb 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -3476,7 +3476,7 @@ int realMain(int argc, char **argv)
/* END core initializations - we now come back to carrying out command line options*/
while((iRet = bufOptRemove(&ch, &arg)) == RS_RET_OK) {
- dbgprintf("deque option %c, optarg '%s'\n", ch, arg);
+ dbgprintf("deque option %c, optarg '%s'\n", ch, (arg == NULL) ? "" : arg);
switch((char)ch) {
case '4':
glbl.SetDefPFFamily(PF_INET);