mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fixed NSLog when it's using syslog to output - it needs to NULL-terminate
strings before feeding them to syslog git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13781 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e1854a3a76
commit
43fd602c10
2 changed files with 13 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Jun 5 17:46:47 2002 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
* Source/NSLog.m (_NSLog_standard_printf_handler): Fixed
|
||||
syslogging of strings: add a NULL at the end of strings before
|
||||
feeding them to syslog.
|
||||
|
||||
2002-06-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSURL.h: Added a couple of ivars and removed
|
||||
|
|
|
@ -84,6 +84,11 @@ _NSLog_standard_printf_handler (NSString* message)
|
|||
|| write(_NSLogDescriptor, buf, len) != len)
|
||||
{
|
||||
int mask;
|
||||
/* We NULL-terminate the string in order to feed it to
|
||||
* syslog. */
|
||||
char *null_terminated_buf = objc_malloc (sizeof (char) * (len + 1));
|
||||
strncpy (null_terminated_buf, buf, len);
|
||||
null_terminated_buf[len] = '\0';
|
||||
|
||||
#ifdef LOG_ERR
|
||||
mask = LOG_ERR;
|
||||
|
@ -98,7 +103,8 @@ _NSLog_standard_printf_handler (NSString* message)
|
|||
#ifdef LOG_USER
|
||||
mask |= LOG_USER;
|
||||
#endif
|
||||
syslog(mask, "%s", buf);
|
||||
syslog(mask, "%s", null_terminated_buf);
|
||||
objc_free (null_terminated_buf);
|
||||
}
|
||||
#else
|
||||
write(_NSLogDescriptor, buf, len);
|
||||
|
|
Loading…
Reference in a new issue