summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-09-02 11:38:31 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-09-02 11:38:31 +0200
commit1a9ac0ced72dd163228438af4f31f233fab20529 (patch)
tree6f228f58615d596bef9ca4f3f0da934368191369 /plugins
parentc2f30a2fc3fb1f87c157828dd08ee20fe444833d (diff)
downloadrsyslog-1a9ac0ced72dd163228438af4f31f233fab20529.tar.gz
rsyslog-1a9ac0ced72dd163228438af4f31f233fab20529.tar.xz
rsyslog-1a9ac0ced72dd163228438af4f31f233fab20529.zip
removed compile time fixed message size limit (was 2K)
The limit can now be set via $MaxMessageSize global config directive (finally gotten rid of MAXLINE ;))
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imgssapi/imgssapi.c12
-rw-r--r--plugins/imklog/bsd.c37
-rw-r--r--plugins/imtemplate/imtemplate.c2
-rw-r--r--plugins/imudp/imudp.c7
-rw-r--r--plugins/imuxsock/imuxsock.c27
-rw-r--r--plugins/omgssapi/omgssapi.c13
-rw-r--r--plugins/omrelp/omrelp.c4
7 files changed, 81 insertions, 21 deletions
diff --git a/plugins/imgssapi/imgssapi.c b/plugins/imgssapi/imgssapi.c
index 766cb519..cce6c40f 100644
--- a/plugins/imgssapi/imgssapi.c
+++ b/plugins/imgssapi/imgssapi.c
@@ -55,6 +55,7 @@
#include "tcps_sess.h"
#include "errmsg.h"
#include "netstrm.h"
+#include "glbl.h"
MODULE_TYPE_INPUT
@@ -80,6 +81,7 @@ DEFobjCurrIf(gssutil)
DEFobjCurrIf(errmsg)
DEFobjCurrIf(netstrm)
DEFobjCurrIf(net)
+DEFobjCurrIf(glbl)
static tcpsrv_t *pOurTcpsrv = NULL; /* our TCP server(listener) TODO: change for multiple instances */
static gss_cred_id_t gss_server_creds = GSS_C_NO_CREDENTIAL;
@@ -392,10 +394,14 @@ OnSessAcceptGSS(tcpsrv_t *pThis, tcps_sess_t *pSess)
allowedMethods = pGSrv->allowedMethods;
if(allowedMethods & ALLOWEDMETHOD_GSS) {
/* Buffer to store raw message in case that
- * gss authentication fails halfway through.
+ * gss authentication fails halfway through. This buffer
+ * is currently dynamically allocated, for performance
+ * reasons we should look for a better way to do it.
+ * rgerhars, 2008-09-02
*/
- char buf[MAXLINE];
+ char *buf;
int ret = 0;
+ CHKmalloc(buf = (char*) malloc(sizeof(char) * (glbl.GetMaxLine() + 1)));
dbgprintf("GSS-API Trying to accept TCP session %p\n", pSess);
@@ -648,6 +654,7 @@ CODESTARTmodExit
objRelease(tcpsrv, LM_TCPSRV_FILENAME);
objRelease(gssutil, LM_GSSUTIL_FILENAME);
objRelease(errmsg, CORE_COMPONENT);
+ objRelease(glbl, CORE_COMPONENT);
objRelease(netstrm, LM_NETSTRM_FILENAME);
objRelease(net, LM_NET_FILENAME);
ENDmodExit
@@ -695,6 +702,7 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(tcpsrv, LM_TCPSRV_FILENAME));
CHKiRet(objUse(gssutil, LM_GSSUTIL_FILENAME));
CHKiRet(objUse(errmsg, CORE_COMPONENT));
+ CHKiRet(objUse(glbl, CORE_COMPONENT));
CHKiRet(objUse(netstrm, LM_NETSTRM_FILENAME));
CHKiRet(objUse(net, LM_NET_FILENAME));
diff --git a/plugins/imklog/bsd.c b/plugins/imklog/bsd.c
index 39b644c0..0a581081 100644
--- a/plugins/imklog/bsd.c
+++ b/plugins/imklog/bsd.c
@@ -110,15 +110,32 @@ klogWillRun(void)
static void
readklog(void)
{
- char *p, *q, line[MAXLINE + 1];
+ char *p, *q;
int len, i;
+ int iMaxLine;
+ uchar bufRcv[4096+1];
+ uchar *pRcv = NULL; /* receive buffer */
+
+ iMaxLine = glbl.GetMaxLine();
+
+ /* we optimize performance: if iMaxLine is below 4K (which it is in almost all
+ * cases, we use a fixed buffer on the stack. Only if it is higher, heap memory
+ * is used. We could use alloca() to achive a similar aspect, but there are so
+ * many issues with alloca() that I do not want to take that route.
+ * rgerhards, 2008-09-02
+ */
+ if((size_t) iMaxLine < sizeof(bufRcv) - 1) {
+ pRcv = bufRcv;
+ } else {
+ CHKmalloc(pRcv = (uchar*) malloc(sizeof(uchar) * (iMaxLine + 1)));
+ }
len = 0;
for (;;) {
- dbgprintf("----------imklog waiting for kernel log line\n");
- i = read(fklog, line + len, MAXLINE - 1 - len);
+ dbgprintf("----------imklog(BSD) waiting for kernel log line\n");
+ i = read(fklog, pRcv + len, iMaxLine - len);
if (i > 0) {
- line[i + len] = '\0';
+ pRcv[i + len] = '\0';
} else {
if (i < 0 && errno != EINTR && errno != EAGAIN) {
imklogLogIntMsg(LOG_ERR,
@@ -129,20 +146,24 @@ readklog(void)
break;
}
- for (p = line; (q = strchr(p, '\n')) != NULL; p = q + 1) {
+ for (p = pRcv; (q = strchr(p, '\n')) != NULL; p = q + 1) {
*q = '\0';
Syslog(LOG_INFO, (uchar*) p);
}
len = strlen(p);
- if (len >= MAXLINE - 1) {
+ if (len >= iMaxLine - 1) {
Syslog(LOG_INFO, (uchar*)p);
len = 0;
}
if (len > 0)
- memmove(line, p, len + 1);
+ memmove(pRcv, p, len + 1);
}
if (len > 0)
- Syslog(LOG_INFO, (uchar*)line);
+ Syslog(LOG_INFO, pRcv);
+
+finalize_it:
+ if(pRcv != NULL && (size_t) iMaxLine >= sizeof(bufRcv) - 1)
+ free(pRcv);
}
diff --git a/plugins/imtemplate/imtemplate.c b/plugins/imtemplate/imtemplate.c
index 6d29c4f1..c391d314 100644
--- a/plugins/imtemplate/imtemplate.c
+++ b/plugins/imtemplate/imtemplate.c
@@ -315,7 +315,7 @@ CODESTARTwillRun
if(udpLstnSocks == NULL)
ABORT_FINALIZE(RS_RET_NO_RUN);
- if((pRcvBuf = malloc(MAXLINE * sizeof(char))) == NULL) {
+ if((pRcvBuf = malloc(glbl.GetMaxLine * sizeof(char))) == NULL) {
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
*
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c
index 6d3a075f..92d930d4 100644
--- a/plugins/imudp/imudp.c
+++ b/plugins/imudp/imudp.c
@@ -51,6 +51,7 @@ DEFobjCurrIf(errmsg)
DEFobjCurrIf(glbl)
DEFobjCurrIf(net)
+static int iMaxLine; /* maximum UDP message size supported */
static int *udpLstnSocks = NULL; /* Internet datagram sockets, first element is nbr of elements
* read-only after init(), but beware of restart! */
static uchar *pszBindAddr = NULL; /* IP to bind socket to */
@@ -180,7 +181,7 @@ CODESTARTrunInput
for (i = 0; nfds && i < *udpLstnSocks; i++) {
if (FD_ISSET(udpLstnSocks[i+1], &readfds)) {
socklen = sizeof(frominet);
- l = recvfrom(udpLstnSocks[i+1], (char*) pRcvBuf, MAXLINE - 1, 0,
+ l = recvfrom(udpLstnSocks[i+1], (char*) pRcvBuf, iMaxLine, 0,
(struct sockaddr *)&frominet, &socklen);
if (l > 0) {
if(net.cvthname(&frominet, fromHost, fromHostFQDN, fromHostIP) == RS_RET_OK) {
@@ -231,7 +232,9 @@ CODESTARTwillRun
if(udpLstnSocks == NULL)
ABORT_FINALIZE(RS_RET_NO_RUN);
- if((pRcvBuf = malloc(MAXLINE * sizeof(char))) == NULL) {
+ iMaxLine = glbl.GetMaxLine();
+
+ if((pRcvBuf = malloc((iMaxLine + 1) * sizeof(char))) == NULL) {
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
finalize_it:
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 4f1fcea4..6e0fa1d3 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -196,14 +196,31 @@ static rsRetVal readSocket(int fd, int iSock)
{
DEFiRet;
int iRcvd;
- uchar line[MAXLINE +1];
+ int iMaxLine;
+ uchar bufRcv[4096+1];
+ uchar *pRcv = NULL; /* receive buffer */
assert(iSock >= 0);
- iRcvd = recv(fd, line, MAXLINE - 1, 0);
+
+ iMaxLine = glbl.GetMaxLine();
+
+ /* we optimize performance: if iMaxLine is below 4K (which it is in almost all
+ * cases, we use a fixed buffer on the stack. Only if it is higher, heap memory
+ * is used. We could use alloca() to achive a similar aspect, but there are so
+ * many issues with alloca() that I do not want to take that route.
+ * rgerhards, 2008-09-02
+ */
+ if((size_t) iMaxLine < sizeof(bufRcv) - 1) {
+ pRcv = bufRcv;
+ } else {
+ CHKmalloc(pRcv = (uchar*) malloc(sizeof(uchar) * (iMaxLine + 1)));
+ }
+
+ iRcvd = recv(fd, pRcv, iMaxLine, 0);
dbgprintf("Message from UNIX socket: #%d\n", fd);
if (iRcvd > 0) {
parseAndSubmitMessage(funixHName[iSock] == NULL ? glbl.GetLocalHostName() : funixHName[iSock],
- (uchar*)"127.0.0.1", line,
+ (uchar*)"127.0.0.1", pRcv,
iRcvd, funixParseHost[iSock], funixFlags[iSock], funixFlowCtl[iSock]);
} else if (iRcvd < 0 && errno != EINTR) {
char errStr[1024];
@@ -212,6 +229,10 @@ static rsRetVal readSocket(int fd, int iSock)
errmsg.LogError(errno, NO_ERRCODE, "recvfrom UNIX");
}
+finalize_it:
+ if(pRcv != NULL && (size_t) iMaxLine >= sizeof(bufRcv) - 1)
+ free(pRcv);
+
RETiRet;
}
diff --git a/plugins/omgssapi/omgssapi.c b/plugins/omgssapi/omgssapi.c
index 82fca2db..e0cc8af6 100644
--- a/plugins/omgssapi/omgssapi.c
+++ b/plugins/omgssapi/omgssapi.c
@@ -378,6 +378,7 @@ ENDtryResume
BEGINdoAction
char *psz; /* temporary buffering */
register unsigned l;
+ int iMaxLine;
CODESTARTdoAction
switch (pData->eDestState) {
case eDestFORW_SUSP:
@@ -392,10 +393,11 @@ CODESTARTdoAction
case eDestFORW:
dbgprintf(" %s:%s/%s\n", pData->f_hname, getFwdSyslogPt(pData), "tcp-gssapi");
+ iMaxLine = glbl.GetMaxLine();
psz = (char*) ppString[0];
l = strlen((char*) psz);
- if (l > MAXLINE)
- l = MAXLINE;
+ if((int) l > iMaxLine)
+ l = iMaxLine;
# ifdef USE_NETZIP
/* Check if we should compress and, if so, do it. We also
@@ -407,10 +409,14 @@ CODESTARTdoAction
* rgerhards, 2006-11-30
*/
if(pData->compressionLevel && (l > MIN_SIZE_FOR_COMPRESS)) {
- Bytef out[MAXLINE+MAXLINE/100+12] = "z";
+ Bytef *out;
uLongf destLen = sizeof(out) / sizeof(Bytef);
uLong srcLen = l;
int ret;
+ /* TODO: optimize malloc sequence? -- rgerhards, 2008-09-02 */
+ CHKmalloc(out = (Bytef*) malloc(iMaxLine + iMaxLine/100 + 12));
+ out[0] = 'z';
+ out[1] = '\0';
ret = compress2((Bytef*) out+1, &destLen, (Bytef*) psz,
srcLen, pData->compressionLevel);
dbgprintf("Compressing message, length was %d now %d, return state %d.\n",
@@ -442,6 +448,7 @@ CODESTARTdoAction
}
break;
}
+finalize_it:
ENDdoAction
diff --git a/plugins/omrelp/omrelp.c b/plugins/omrelp/omrelp.c
index 71d6e797..8d74c82f 100644
--- a/plugins/omrelp/omrelp.c
+++ b/plugins/omrelp/omrelp.c
@@ -159,8 +159,8 @@ CODESTARTdoAction
lenMsg = strlen((char*) pMsg); /* TODO: don't we get this? */
/* TODO: think about handling oversize messages! */
- if(lenMsg > MAXLINE)
- lenMsg = MAXLINE;
+ if((int) lenMsg > glbl.GetMaxLine())
+ lenMsg = glbl.GetMaxLine();
/* forward */
ret = relpCltSendSyslog(pData->pRelpClt, (uchar*) pMsg, lenMsg);