*BSD News Article 12068


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!olivea!uunet!emba-news.uvm.edu!sadye.emba.uvm.edu!wollman
From: wollman@sadye.emba.uvm.edu (Garrett Wollman)
Newsgroups: comp.os.386bsd.bugs
Subject: syslog()/vsyslog() bug
Message-ID: <1993Mar1.212610.14687@uvm.edu>
Date: 1 Mar 93 21:26:10 GMT
Sender: news@uvm.edu
Organization: University of Vermont, EMBA Computer Facility
Lines: 47

According to the syslog(3) manual page, the first argument to the
syslog() and vsyslog() functions is a priority:

     The message is tagged with priority. Priorities are encoded as a facility
     and a level. The facility describes the part of the system generating the
     message.  The level is selected from the following ordered (high to low)
     list:

However, the code in /usr/src/lib/libc/gen/syslog.c sometimes doesn't
expect to be passed a facility in this argument as is done by, e.g.,
`logger'.  The following patch corrects the error.  It does not
attempt to fix other questionable code which nonetheless still works,
such as use of sprintf() and vsprintf() where snprintf()/vsnprintf()
would be preferred.

Note the reason why this error wasn't more noticeable is that most
programs set the facility during the openlog() call, and pass only a
level to syslog().


*** /usr/src/lib/libc/gen/syslog.c	Wed Jun 26 21:53:08 1991
--- syslog.c	Mon Mar  1 14:53:17 1993
***************
*** 99,105 ****
  
  	/* check for invalid bits or no priority set */
  	if (!LOG_PRI(pri) || (pri &~ (LOG_PRIMASK|LOG_FACMASK)) ||
! 	    !(LOG_MASK(pri) & LogMask))
  		return;
  
  	saved_errno = errno;
--- 99,105 ----
  
  	/* check for invalid bits or no priority set */
  	if (!LOG_PRI(pri) || (pri &~ (LOG_PRIMASK|LOG_FACMASK)) ||
! 	    !(LOG_MASK(LOG_PRI(pri)) & LogMask))
  		return;
  
  	saved_errno = errno;

-GAWollman

-- 
Garrett A. Wollman   | Shashish is simple, it's discreet, it's brief. ... 
wollman@emba.uvm.edu | Shashish is the bonding of hearts in spite of distance.
uvm-gen!wollman      | It is a bond more powerful than absence.  We like people
UVM disagrees.       | who like Shashish.  - Claude McKenzie + Florent Vollant