[net.bugs.4bsd] Bug in syslog

rusty@sdccsu3.UUCP (03/08/84)

there is a bug in syslog(3) that causes lines containing %C where
C isn't 'm' to screw up. syslog(3) is null terminating the string
incorrectly. diffs follow:

*** /src/lib/libc/gen/syslog.c	Mon Jun 27 15:06:44 1983
--- syslog.c	Wed Mar  7 17:01:37 1984
***************
*** 70,76
  			}
  			c = *f++;
  			if (c != 'm') {
! 				*b++ = '%', *b++ = c, *b++ = '\0';
  				continue;
  			}
  			if ((unsigned)errno > sys_nerr)

--- 70,76 -----
  			}
  			c = *f++;
  			if (c != 'm') {
! 				*b++ = '%', *b++ = c;
  				continue;
  			}
  			if ((unsigned)errno > sys_nerr)

stephen@comp.lancs.ac.uk (Stephen J. Muir) (08/04/86)

Index:	lib/libc/gen/syslog.c 4.2 Fix

Description:
	syslog(3) fails when a %c (where c != 'm') occurs in the string
Repeat-By:
	use the following call:

	syslog ("%s: %m", "filename");

	The string is truncated after the "%s" and no newline is added.  The
	next call to syslog() (even from another program) will tack it's output
	onto the same line as the previous and be processed as one.

Fix:
	apply the following patch to /usr/src/lib/libc/gen/syslog.c
73c73
< 				*b++ = '%', *b++ = c, *b++ = '\0';
---
> 				*b++ = '%', *b++ = c;

-- 
EMAIL:	stephen@comp.lancs.ac.uk	| Post: University of Lancaster,
UUCP:	...!mcvax!ukc!dcl-cs!stephen	|	Department of Computing,
Phone:	+44 524 65201 Ext. 4120		|	Bailrigg, Lancaster, UK.
Project:Alvey ECLIPSE Distribution	|	LA1 4YR