1. Daniel Cid
  2. ossec-hids

Commits

Daniel Cid  committed a48059d

Removing empty lines.

  • Participants
  • Parent commits 389859b
  • Branches default

Comments (0)

Files changed (2)

File src/logcollector/read_command.c

View file
         {
             *p = '\0';
         }
+
+        /* Removing empty lines. */
+        #ifdef WIN32
+        if(str[0] == '\r' && str[1] == '\0')
+        {
+            continue;
+        }
+        #endif
+        if(str[0] == '\0')
+        {
+            continue;
+        }
+        
         
         debug2("%s: DEBUG: Reading command message: '%s'", ARGV0, str);
 

File src/logcollector/read_fullcommand.c

View file
     int cmd_size = 0;
     char *p;
     char str[OS_MAXSTR+1];
+    char strfinal[OS_MAXSTR+1];
 
     FILE *cmd_output;
 
     str[OS_MAXSTR]= '\0';
+    strfinal[OS_MAXSTR]= '\0';
     *rc = 0;
 
 
         {
             *p = '\0';
         }
+
         
         debug2("%s: DEBUG: Reading command message: '%s'", ARGV0, str);
 
+        /* Removing empty lines. */
+        n = 0;
+        p = str;
+        while(*p != '\0')
+        {
+            if(p[0] == '\r')
+            {
+                p++;
+                continue;
+            }
+
+            if(p[0] == '\n' && p[1] == '\n')
+            {
+                p++;
+            }
+            strfinal[n] = *p;
+            n++;
+            p++;
+        }
+        strfinal[n] = '\0';
+
         
         /* Sending message to queue */
         if(drop_it == 0)
         {
-            if(SendMSG(logr_queue,str,
+            if(SendMSG(logr_queue,strfinal,
                         (NULL != logff[pos].alias) ? logff[pos].alias : logff[pos].command,
                         LOCALFILE_MQ) < 0)
             {