-/* @(#) $Id$ */
+/* @(#) $Id: ./src/logcollector/read_syslog.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
while(fgets(str, OS_MAXSTR - OS_LOG_HEADER, logff[pos].fp) != NULL)
{
/* Getting the last occurence of \n */
- if ((p = strrchr(str, '\n')) != NULL)
+ if ((p = strrchr(str, '\n')) != NULL)
{
*p = '\0';
}
-
+
/* If we didn't get the new line, because the
* size is large, send what we got so far.
*/
debug1("%s: Message not complete. Trying again: '%s'", ARGV0,str);
fsetpos(logff[pos].fp, &fp_pos);
break;
- }
-
+ }
+
#ifdef WIN32
if ((p = strrchr(str, '\r')) != NULL)
{
continue;
}
#endif
-
+
debug2("%s: DEBUG: Reading syslog message: '%s'", ARGV0, str);
-
+
/* Sending message to queue */
if(drop_it == 0)
{
/* Incorrectly message size */
if(__ms)
{
- merror("%s: Large message size: '%s'", ARGV0, str);
+ // strlen(str) >= (OS_MAXSTR - OS_LOG_HEADER - 2)
+ // truncate str before logging to ossec.log
+#define OUTSIZE 4096
+ char buf[OUTSIZE + 1];
+ buf[OUTSIZE] = '\0';
+ snprintf(buf, OUTSIZE, "%s", str);
+ merror("%s: Large message size(length=%d): '%s...'", ARGV0, (int)strlen(str), buf);
while(fgets(str, OS_MAXSTR - 2, logff[pos].fp) != NULL)
{
/* Getting the last occurence of \n */
}
__ms = 0;
}
-
+
fgetpos(logff[pos].fp, &fp_pos);
continue;
}
- return(NULL);
+ return(NULL);
}
/* EOF */