Subject: Re: port-xen/29887: sysctl kern.consdev coredumps
To: None <port-xen-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: Christos Zoulas <christos@zoulas.com>
List: netbsd-bugs
Date: 04/07/2005 14:49:01
The following reply was made to PR port-xen/29887; it has been noted by GNATS.

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@netbsd.org, port-xen-maintainer@netbsd.org,
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: port-xen/29887: sysctl kern.consdev coredumps
Date: Thu, 7 Apr 2005 10:48:35 -0400

 On Apr 7,  1:07pm, atatat@atatdot.net (Andrew Brown) wrote:
 -- Subject: Re: port-xen/29887: sysctl kern.consdev coredumps
 
 
 I would say that the proper fix is to make puts(NULL), and fputs(fp, NULL)
 behave like printf("%s\n", NULL) and fprintf(fp, "%s", NULL) respectively:
 
 Index: fputs.c
 ===================================================================
 RCS file: /cvsroot/src/lib/libc/stdio/fputs.c,v
 retrieving revision 1.13
 diff -u -u -r1.13 fputs.c
 --- fputs.c	7 Aug 2003 16:43:24 -0000	1.13
 +++ fputs.c	7 Apr 2005 14:47:13 -0000
 @@ -61,11 +61,11 @@
  	struct __siov iov;
  	int r;
  
 -	_DIAGASSERT(s != NULL);
  	_DIAGASSERT(fp != NULL);
 +	if (s == NULL)
 +		s = "(null)";
  
 -	/* LINTED we don't touch s */
 -	iov.iov_base = (void *)s;
 +	iov.iov_base = __UNCONST(s);
  	iov.iov_len = uio.uio_resid = strlen(s);
  	uio.uio_iov = &iov;
  	uio.uio_iovcnt = 1;
 Index: puts.c
 ===================================================================
 RCS file: /cvsroot/src/lib/libc/stdio/puts.c,v
 retrieving revision 1.12
 diff -u -u -r1.12 puts.c
 --- puts.c	7 Aug 2003 16:43:29 -0000	1.12
 +++ puts.c	7 Apr 2005 14:47:13 -0000
 @@ -56,16 +56,15 @@
  puts(s)
  	char const *s;
  {
 -	size_t c = strlen(s);
 +	size_t c;
  	struct __suio uio;
  	struct __siov iov[2];
  	int r;
  
 -	_DIAGASSERT(s != NULL);
 -
 -	/* LINTED we don't touch the string */
 -	iov[0].iov_base = (void *)s;
 -	iov[0].iov_len = c;
 +	if (s == NULL)
 +		s = "(null)";
 +	iov[0].iov_base = __UNCONST(s);
 +	iov[0].iov_len = c = strlen(s);
  	iov[1].iov_base = "\n";
  	iov[1].iov_len = 1;
  	uio.uio_resid = c + 1;