novi upstream verzije 2.8.3
[ossec-hids.git] / src / os_csyslogd / csyslogd.c
index 696d3fe..2772b4e 100755 (executable)
 
 
 
-/* strnlen is a GNU extension */
-#ifdef __linux__
- #define _GNU_SOURCE
- #include <string.h>
-#endif
+#include "shared.h"
+
 #include "csyslogd.h"
 #include "os_net/os_net.h"
 
 
-
 /* OS_SyslogD: Monitor the alerts and sends them via syslog.
  * Only return in case of error.
  */
@@ -56,7 +52,7 @@ void OS_CSyslogD(SyslogConfig **syslog_config)
         }
         sleep(1);
     }
-    merror("%s: INFO: File queue connected.", ARGV0 );
+    debug1("%s: INFO: File queue connected.", ARGV0 );
 
 
     /* Connecting to syslog. */
@@ -114,7 +110,7 @@ void OS_CSyslogD(SyslogConfig **syslog_config)
 int field_add_string(char *dest, int size, const char *format, const char *value ) {
     char buffer[OS_SIZE_2048];
     int len = 0;
-    int dest_sz = size - strnlen(dest, OS_SIZE_2048);
+    int dest_sz = size - strlen(dest);
 
     if(dest_sz <= 0 ) {
         // Not enough room in the buffer
@@ -139,13 +135,13 @@ int field_add_string(char *dest, int size, const char *format, const char *value
 int field_add_truncated(char *dest, int size, const char *format, const char *value, int fmt_size ) {
     char buffer[OS_SIZE_2048];
 
-    int available_sz = size - strnlen(dest, OS_SIZE_2048);
+    int available_sz = size - strlen(dest);
     int total_sz = strlen(value) + strlen(format) - fmt_size;
     int field_sz = available_sz - strlen(format) + fmt_size;
 
     int len = 0;
     char trailer[] = "...";
-    char *truncated;
+    char *truncated = NULL;
 
     if(available_sz <= 0 ) {
         // Not enough room in the buffer
@@ -188,7 +184,7 @@ int field_add_truncated(char *dest, int size, const char *format, const char *va
 int field_add_int(char *dest, int size, const char *format, const int value ) {
     char buffer[255];
     int len = 0;
-    int dest_sz = size - strnlen(dest, OS_SIZE_2048);
+    int dest_sz = size - strlen(dest);
 
     if(dest_sz <= 0 ) {
         // Not enough room in the buffer