summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2005-10-25 09:40:11 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2005-10-25 09:40:11 +0000
commitb2887a236458af9c4faace7bbc2fa1921d8e7bee (patch)
tree2753e0af6364e4ebb0c4352d5c499b905e329716
parentdb4955e4ddb3d0bb103b6780da2a650fd55a2c79 (diff)
downloadrsyslog-b2887a236458af9c4faace7bbc2fa1921d8e7bee.tar.gz
rsyslog-b2887a236458af9c4faace7bbc2fa1921d8e7bee.tar.xz
rsyslog-b2887a236458af9c4faace7bbc2fa1921d8e7bee.zip
fixed bug in tcp sender that could cause rsyslogd to dump core
-rw-r--r--NEWS9
-rw-r--r--syslogd.c20
-rw-r--r--version.h4
3 files changed, 24 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index aa09c9af..331d232b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
---------------------------------------------------------------------------
-Version 1.11.2 (RGer), 2005-10-20
+Version 1.12.0 (RGer), 2005-10-20
+- moved to a multi-threaded design. single-threading is still optionally
+ available
- fixed a potential race condition. In the original code, marking was done
by an alarm handler, which could lead to all sorts of bad things. This
has been changed now. See comments in syslogd.c/domark() for details.
@@ -13,6 +15,11 @@ Version 1.11.2 (RGer), 2005-10-20
immediately before rsyslogd was terminated.
- added comments on thread-safety of global variables in syslogd.c
- fixed a small bug: spurios printf() when TCP syslog was used
+- fixed a bug that causes rsyslogd to dump core on termination when one
+ of the selector lines did not receive a message during the run (very
+ unlikely)
+- fixed an one-too-low memory allocation in the TCP sender. Could result
+ in rsyslogd dumping core.
---------------------------------------------------------------------------
Version 1.11.1 (RGer), 2005-10-19
- support for BSD-style program name and host blocks
diff --git a/syslogd.c b/syslogd.c
index e7774387..7e5929f2 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -1440,7 +1440,14 @@ static int TCPSend(struct filed *f, char *msg)
if((*(msg+len-1) != '\n')) {
if(buf != NULL)
free(buf);
- if((buf = malloc((len + 1) * sizeof(char))) == NULL) {
+ /* in the malloc below, we need to add 2 to the length. The
+ * reason is that we a) add one character and b) len does
+ * not take care of the '\0' byte. Up until today, it was just
+ * +1 , which caused rsyslogd to sometimes dump core.
+ * I have added this comment so that the logic is not accidently
+ * changed again. rgerhards, 2005-10-25
+ */
+ if((buf = malloc((len + 2) * sizeof(char))) == NULL) {
/* extreme mem shortage, try to solve
* as good as we can. No point in calling
* any alarms, they might as well run out
@@ -1471,8 +1478,9 @@ static int TCPSend(struct filed *f, char *msg)
dprintf("TCP sent %d bytes, requested %d, msg: '%s'\n", lenSend, len, msg);
if(lenSend == len) {
/* all well */
- if(buf != NULL)
+ if(buf != NULL) {
free(buf);
+ }
return 0;
}
@@ -1507,6 +1515,7 @@ static int TCPSend(struct filed *f, char *msg)
return -1;
} while(!done); /* warning: do ... while() */
/*NOT REACHED*/
+
if(buf != NULL)
free(buf);
return -1; /* only to avoid compiler warning! */
@@ -1942,7 +1951,6 @@ static struct msg* MsgConstruct()
}
/* DEV debugging only! dprintf("MsgConstruct\t0x%x, ref 1\n", (int)pM);*/
- dprintf("MsgConstruct\t0x%x, ref 1\n", (int)pM);
return(pM);
}
@@ -1955,11 +1963,9 @@ static void MsgDestruct(struct msg * pM)
{
assert(pM != NULL);
/* DEV Debugging only ! dprintf("MsgDestruct\t0x%x, Ref now: %d\n", (int)pM, pM->iRefCount - 1); */
- dprintf("MsgDestruct\t0x%x, Ref now: %d\n", (int)pM, pM->iRefCount - 1);
if(--pM->iRefCount == 0)
{
/* DEV Debugging Only! dprintf("MsgDestruct\t0x%x, RefCount now 0, doing DESTROY\n", (int)pM); */
- dprintf("MsgDestruct\t0x%x, RefCount now 0, doing DESTROY\n", (int)pM);
if(pM->pszUxTradMsg != NULL)
free(pM->pszUxTradMsg);
if(pM->pszRawMsg != NULL)
@@ -2006,7 +2012,6 @@ static struct msg *MsgAddRef(struct msg *pM)
assert(pM != NULL);
pM->iRefCount++;
/* DEV debugging only! dprintf("MsgAddRef\t0x%x done, Ref now: %d\n", (int)pM, pM->iRefCount);*/
- dprintf("MsgAddRef\t0x%x done, Ref now: %d\n", (int)pM, pM->iRefCount);
return(pM);
}
@@ -2855,6 +2860,9 @@ int main(int argc, char **argv)
case 'v':
printf("rsyslogd %s.%s, ", VERSION, PATCHLEVEL);
printf("compiled with:\n");
+#ifdef USE_PTHREADS
+ printf("\tFEATURE_PTHREADS (dual-threading)\n");
+#endif
#ifdef FEATURE_REGEXP
printf("\tFEATURE_REGEXP\n");
#endif
diff --git a/version.h b/version.h
index 729c824b..b37b6910 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
-#define VERSION "1.11"
-#define PATCHLEVEL "2"
+#define VERSION "1.12"
+#define PATCHLEVEL "0"