Submitted By: Jim Gifford (patches at jg555 dot com)
Date: 2003-09-10
Initial Package Version: 1.4.2
Origin: inetutils CVS
Description: Fixes Long Line Support

diff -Naur inetutils-1.4.2.orig/syslogd/syslogd.c inetutils-1.4.2/syslogd/syslogd.c
--- inetutils-1.4.2.orig/syslogd/syslogd.c	2002-12-11 12:38:00.000000000 +0000
+++ inetutils-1.4.2/syslogd/syslogd.c	2003-09-10 16:35:22.000000000 +0000
@@ -1621,6 +1621,7 @@
   size_t line_max = LINE_MAX;
   char *cbuf;
   char *cline;
+  int cont_line = 0;
   struct servent *sp;
 
   (void) signo;  /* Ignored.  */
@@ -1680,7 +1681,7 @@
   cbuf = malloc (line_max);
   if (cbuf == NULL)
     {
-      /* There is no gracefull recovery here.  */
+      /* There is no graceful recovery here.  */
       dbg_printf ("cannot allocate space for configuration\n");
       return;
     }
@@ -1697,9 +1698,24 @@
     {
       size_t len = strlen (cline);
 
-      /* No newline ? then line is too big for the buffer readjust.  */
-      if (memchr (cline, '\n', len) == NULL)
+      /* If this is a continuation line, skip leading whitespace for
+	 compatibility with sysklogd.  Note that this requires
+	 whitespace before the backslash in the previous line if you
+	 want to separate the selector from the action.  */
+      if (cont_line)
+	{
+	  char *start = cline;
+	  while (*start == ' ' || *start == '\t')
+	    start++;
+	  len = len - (start - cline);
+	  memmove (cline, start, len + 1);
+	  cont_line = 0;
+	}
+
+      /* No newline, so the line is too big for the buffer.  Readjust.  */
+      if (strchr (cline, '\n') == NULL)
 	{
+	  size_t offset = cline - cbuf;
 	  char *tmp;
 	  tmp = realloc (cbuf, line_max * 2);
 	  if (tmp == NULL)
@@ -1712,8 +1728,7 @@
 	  else
 	    cbuf = tmp;
 	  line_max *= 2;
-	  strcpy (cbuf, cline);
-	  cline += len;
+	  cline = cbuf + offset + len - 1;
 	  continue;
 	}
       else
@@ -1738,6 +1753,7 @@
 	{
 	  *p = '\0';
 	  cline = p;
+	  cont_line = 1;
 	  continue;
 	}
 
