some cleanup

This commit is contained in:
Rainer Gerhards 2007-12-27 14:29:09 +00:00
parent c7b246e3b6
commit cebbf6d44e
9 changed files with 21 additions and 15 deletions

2
msg.c
View File

@ -1469,7 +1469,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
++iCurrFld; ++iCurrFld;
} }
} }
dbgprintf("field requested %d, field found %d\n", pTpe->data.field.iToPos, iCurrFld); dbgprintf("field requested %d, field found %d\n", pTpe->data.field.iToPos, (int) iCurrFld);
if(iCurrFld == pTpe->data.field.iToPos) { if(iCurrFld == pTpe->data.field.iToPos) {
/* field found, now extract it */ /* field found, now extract it */

1
net.c
View File

@ -865,7 +865,6 @@ int *create_udp_socket(uchar *hostname, uchar *pszPort, int bIsServer)
int error, maxs, *s, *socks, on = 1; int error, maxs, *s, *socks, on = 1;
int sockflags; int sockflags;
dbgprintf("create_udp_socket('%s', '%s', %d);\n", hostname, pszPort, bIsServer);
assert(!((pszPort == NULL) && (hostname == NULL))); assert(!((pszPort == NULL) && (hostname == NULL)));
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
if(bIsServer) if(bIsServer)

View File

@ -305,7 +305,7 @@ static int TCPSendGSSInit(instanceData *pData)
strcpy(out_tok.value, base); strcpy(out_tok.value, base);
strcat(out_tok.value, "@"); strcat(out_tok.value, "@");
strcat(out_tok.value, pData->f_hname); strcat(out_tok.value, pData->f_hname);
dbgprintf("GSS-API service name: %s\n", out_tok.value); dbgprintf("GSS-API service name: %s\n", (char*) out_tok.value);
tok_ptr = GSS_C_NO_BUFFER; tok_ptr = GSS_C_NO_BUFFER;
context = &pData->gss_context; context = &pData->gss_context;
@ -350,7 +350,7 @@ static int TCPSendGSSInit(instanceData *pData)
goto fail; goto fail;
if (out_tok.length != 0) { if (out_tok.length != 0) {
dbgprintf("GSS-API Sending init_sec_context token (length: %d)\n", out_tok.length); dbgprintf("GSS-API Sending init_sec_context token (length: %ld)\n", (long) out_tok.length);
if (send_token(s, &out_tok) < 0) { if (send_token(s, &out_tok) < 0) {
goto fail; goto fail;
} }
@ -618,7 +618,7 @@ static int TCPSend(instanceData *pData, char *msg, size_t len)
} else { } else {
# endif # endif
lenSend = send(pData->sock, msg, len, 0); lenSend = send(pData->sock, msg, len, 0);
dbgprintf("TCP sent %d bytes, requested %d, msg: '%s'\n", lenSend, len, dbgprintf("TCP sent %d bytes, requested %ld, msg: '%s'\n", lenSend, (long) len,
bIsCompressed ? "***compressed***" : msg); bIsCompressed ? "***compressed***" : msg);
if((unsigned)lenSend == len) { if((unsigned)lenSend == len) {
/* all well */ /* all well */

View File

@ -108,7 +108,7 @@ extern int ksyslog(int type, char *buf, int len);
/* Write a message to the message queue. /* Write a message to the message queue.
* returns -1 if it fails, something else otherwise * returns -1 if it fails, something else otherwise
*/ */
static rsRetVal writeSyslogV(int iPRI, const char *szFmt, va_list va)// __attribute__((format(printf,2, 3))); static rsRetVal writeSyslogV(int iPRI, const char *szFmt, va_list va)
{ {
DEFiRet; DEFiRet;
int iChars; int iChars;

View File

@ -34,6 +34,7 @@
#include <netdb.h> #include <netdb.h>
#include "rsyslog.h" #include "rsyslog.h"
#include "syslogd.h" #include "syslogd.h"
#include "net.h"
#include "cfsysline.h" #include "cfsysline.h"
#include "module-template.h" #include "module-template.h"
@ -47,6 +48,10 @@ DEF_IMOD_STATIC_DATA
static int *udpLstnSocks = NULL; /* Internet datagram sockets, first element is nbr of elements static int *udpLstnSocks = NULL; /* Internet datagram sockets, first element is nbr of elements
* read-only after init(), but beware of restart! */ * read-only after init(), but beware of restart! */
static uchar *pszBindAddr = NULL; /* IP to bind socket to */ static uchar *pszBindAddr = NULL; /* IP to bind socket to */
static uchar *pRcvBuf = NULL; /* receive buffer (for a single packet). We use a global and alloc
* it so that we can check available memory in willRun() and request
* termination if we can not get it. -- rgerhards, 2007-12-27
*/
typedef struct _instanceData { typedef struct _instanceData {
} instanceData; } instanceData;
@ -128,7 +133,6 @@ BEGINrunInput
socklen_t socklen; socklen_t socklen;
uchar fromHost[NI_MAXHOST]; uchar fromHost[NI_MAXHOST];
uchar fromHostFQDN[NI_MAXHOST]; uchar fromHostFQDN[NI_MAXHOST];
char line[MAXLINE +1];
ssize_t l; ssize_t l;
CODESTARTrunInput CODESTARTrunInput
/* this is an endless loop - it is terminated when the thread is /* this is an endless loop - it is terminated when the thread is
@ -172,7 +176,7 @@ CODESTARTrunInput
for (i = 0; nfds && i < *udpLstnSocks; i++) { for (i = 0; nfds && i < *udpLstnSocks; i++) {
if (FD_ISSET(udpLstnSocks[i+1], &readfds)) { if (FD_ISSET(udpLstnSocks[i+1], &readfds)) {
socklen = sizeof(frominet); socklen = sizeof(frominet);
l = recvfrom(udpLstnSocks[i+1], line, MAXLINE - 1, 0, l = recvfrom(udpLstnSocks[i+1], (char*) pRcvBuf, MAXLINE - 1, 0,
(struct sockaddr *)&frominet, &socklen); (struct sockaddr *)&frominet, &socklen);
if (l > 0) { if (l > 0) {
if(cvthname(&frominet, fromHost, fromHostFQDN) == RS_RET_OK) { if(cvthname(&frominet, fromHost, fromHostFQDN) == RS_RET_OK) {
@ -186,7 +190,7 @@ CODESTARTrunInput
*/ */
if(isAllowedSender(pAllowedSenders_UDP, if(isAllowedSender(pAllowedSenders_UDP,
(struct sockaddr *)&frominet, (char*)fromHostFQDN)) { (struct sockaddr *)&frominet, (char*)fromHostFQDN)) {
printchopped((char*)fromHost, line, l, udpLstnSocks[i+1], 1); printchopped((char*)fromHost, (char*) pRcvBuf, l, udpLstnSocks[i+1], 1);
} else { } else {
dbgprintf("%s is not an allowed sender\n", (char*)fromHostFQDN); dbgprintf("%s is not an allowed sender\n", (char*)fromHostFQDN);
if(option_DisallowWarning) { if(option_DisallowWarning) {
@ -218,10 +222,14 @@ BEGINwillRun
CODESTARTwillRun CODESTARTwillRun
PrintAllowedSenders(1); /* UDP */ PrintAllowedSenders(1); /* UDP */
if((pRcvBuf = malloc(MAXLINE * sizeof(char))) == NULL) {
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
/* if we could not set up any listners, there is no point in running... */ /* if we could not set up any listners, there is no point in running... */
if(udpLstnSocks == NULL) if(udpLstnSocks == NULL)
iRet = RS_RET_NO_RUN; iRet = RS_RET_NO_RUN;
finalize_it:
ENDwillRun ENDwillRun

View File

@ -1345,8 +1345,8 @@ void printchopped(char *hname, char *msg, int len, int fd, int bParseHost)
int ret; int ret;
iLenDefBuf = MAXLINE; iLenDefBuf = MAXLINE;
ret = uncompress((uchar *) deflateBuf, &iLenDefBuf, (uchar *) msg+1, len-1); ret = uncompress((uchar *) deflateBuf, &iLenDefBuf, (uchar *) msg+1, len-1);
dbgprintf("Compressed message uncompressed with status %d, length: new %d, old %d.\n", dbgprintf("Compressed message uncompressed with status %d, length: new %ld, old %d.\n",
ret, iLenDefBuf, len-1); ret, (long) iLenDefBuf, len-1);
/* Now check if the uncompression worked. If not, there is not much we can do. In /* Now check if the uncompression worked. If not, there is not much we can do. In
* that case, we log an error message but ignore the message itself. Storing the * that case, we log an error message but ignore the message itself. Storing the
* compressed text is dangerous, as it contains control characters. So we do * compressed text is dangerous, as it contains control characters. So we do

View File

@ -49,7 +49,7 @@
#define ADDDATE 0x004 /* add a date to the message */ #define ADDDATE 0x004 /* add a date to the message */
#define MARK 0x008 /* this message is a mark */ #define MARK 0x008 /* this message is a mark */
void dbgprintf(char *, ...); void dbgprintf(char *, ...) __attribute__((format(printf, 1, 2)));
void logerror(char *type); void logerror(char *type);
void logerrorSz(char *type, char *errMsg); void logerrorSz(char *type, char *errMsg);
void logerrorInt(char *type, int iErr); void logerrorInt(char *type, int iErr);

View File

@ -924,7 +924,7 @@ int TCPSessGSSAccept(int fd)
if (maj_stat != GSS_S_COMPLETE) if (maj_stat != GSS_S_COMPLETE)
display_status("displaying name", maj_stat, min_stat); display_status("displaying name", maj_stat, min_stat);
else else
dbgprintf("GSS-API Accepted connection from: %s\n", recv_tok.value); dbgprintf("GSS-API Accepted connection from: %s\n", (char*) recv_tok.value);
gss_release_name(&min_stat, &client); gss_release_name(&min_stat, &client);
gss_release_buffer(&min_stat, &recv_tok); gss_release_buffer(&min_stat, &recv_tok);

View File

@ -79,7 +79,6 @@ static rsRetVal thrdConstruct(thrdInfo_t **ppThis)
static rsRetVal thrdDestruct(thrdInfo_t *pThis) static rsRetVal thrdDestruct(thrdInfo_t *pThis)
{ {
assert(pThis != NULL); assert(pThis != NULL);
dbgprintf("thrdDestruct, pThis: %lx\n", pThis);
if(pThis->bIsActive == 1) { if(pThis->bIsActive == 1) {
thrdTerminate(pThis); thrdTerminate(pThis);