summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2005-07-29 08:37:47 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2005-07-29 08:37:47 +0000
commit641be9fa98ac0d4387c4fc4f5762fe4854d2efe6 (patch)
tree88ca602649564acdd36c5b75d00d2ae272776769
parent17869a5ba296c5a39e4ea2481ca3d8c6948b7cdd (diff)
downloadrsyslog-641be9fa98ac0d4387c4fc4f5762fe4854d2efe6.tar.gz
rsyslog-641be9fa98ac0d4387c4fc4f5762fe4854d2efe6.tar.xz
rsyslog-641be9fa98ac0d4387c4fc4f5762fe4854d2efe6.zip
fixed the issue where rsyslogd dumped core when an invalid template name
was given
-rw-r--r--Makefile6
-rw-r--r--syslogd.c37
-rw-r--r--version.h2
3 files changed, 36 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 67b9ffde..c2b6b12e 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 8c625709..dfadecf3 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -1054,7 +1054,7 @@ int TCPSend(struct filed *f, char *msg)
}
lenSend = send(f->f_file, msg, len, 0);
-dprintf("##Sent %d bytes, requested %d, msg: '%s'\n", lenSend, len, msg);
+ dprintf("TCP sent %d bytes, requested %d, msg: '%s'\n", lenSend, len, msg);
if(lenSend == len) {
/* all well */
if(buf != NULL)
@@ -1076,7 +1076,6 @@ dprintf("##Sent %d bytes, requested %d, msg: '%s'\n", lenSend, len, msg);
default:
f_type = f->f_type;
f->f_type = F_UNUSED;
-printf("##error(%d): %s\n", errno, strerror(errno));
logerror("message not (tcp)send");
f->f_type = f_type;
break;
@@ -1092,7 +1091,6 @@ printf("##error(%d): %s\n", errno, strerror(errno));
if(buf != NULL)
free(buf);
return -1;
-dprintf("##retry f_file %d\n", f->f_file);
} while(!done); /* warning: do ... while() */
/*NOT REACHED*/
if(buf != NULL)
@@ -5075,6 +5073,12 @@ void cfline(line, f)
/* then try to find the template and re-set f_type to UNUSED
* if it can not be found. */
cflineSetTemplateAndIOV(f, szTemplateName);
+ if(f->f_type == F_UNUSED)
+ /* safety measure to make sure we have a valid
+ * selector line before we continue down below.
+ * rgerhards 2005-07-29
+ */
+ break;
(void) strcpy(f->f_un.f_forw.f_hname, q);
memset((char *) &f->f_un.f_forw.f_addr, 0,
@@ -5119,6 +5123,13 @@ void cfline(line, f)
* and then look at the rest of the line.
*/
cflineParseFileName(f, p);
+ if(f->f_type == F_UNUSED)
+ /* safety measure to make sure we have a valid
+ * selector line before we continue down below.
+ * rgerhards 2005-07-29
+ */
+ break;
+
if (syncfile)
f->f_flags |= SYNC_FILE;
if (f->f_type == F_PIPE) {
@@ -5144,6 +5155,7 @@ void cfline(line, f)
case '*':
dprintf ("write-all");
+ f->f_type = F_WALL;
if(*(p+1) == ';') {
/* we have a template specifier! */
p += 2; /* eat "*;" */
@@ -5155,15 +5167,20 @@ void cfline(line, f)
if(szTemplateName[0] == '\0')
strcpy(szTemplateName, " WallFmt");
cflineSetTemplateAndIOV(f, szTemplateName);
+ if(f->f_type == F_UNUSED)
+ /* safety measure to make sure we have a valid
+ * selector line before we continue down below.
+ * rgerhards 2005-07-29
+ */
+ break;
+
dprintf(" template '%s'\n", szTemplateName);
- f->f_type = F_WALL;
break;
#ifdef WITH_DB
case '>': /* rger 2004-10-28: added support for MySQL
* >server,dbname,userid,password
*/
- dprintf ("in init() - WITH_DB case \n");
f->f_type = F_MYSQL;
p++;
@@ -5262,6 +5279,16 @@ void cfline(line, f)
if(szTemplateName[0] == '\0')
strcpy(szTemplateName, " StdUsrMsgFmt");
cflineSetTemplateAndIOV(f, szTemplateName);
+ /* Please note that we would need to check if the template
+ * was found. If not, f->f_type would be F_UNUSED and we
+ * can NOT carry on processing. These checks can be seen
+ * on all other selector line code above. However, as we
+ * do not have anything else to do here, we do not include
+ * this check. Should you add any further processing at
+ * this point here, you must first add a check for this
+ * condition!
+ * rgerhards 2005-07-29
+ */
break;
}
return;
diff --git a/version.h b/version.h
index 421e21c3..4d21322e 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
#define VERSION "0.9"
-#define PATCHLEVEL "4"
+#define PATCHLEVEL "5"