When printing out nodes of type "string", don't print anything if
sysctl() reports that 0 bytes were returned. Reported by Matt Green with "sysctl hw.disknames" on a system with no disks.
This commit is contained in:
parent
95aae207e0
commit
f8c2d639ce
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysctl.c,v 1.58 2002/03/24 00:11:00 sommerfeld Exp $ */
|
||||
/* $NetBSD: sysctl.c,v 1.59 2002/11/03 07:06:06 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993
|
||||
|
@ -44,7 +44,7 @@ __COPYRIGHT(
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)sysctl.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: sysctl.c,v 1.58 2002/03/24 00:11:00 sommerfeld Exp $");
|
||||
__RCSID("$NetBSD: sysctl.c,v 1.59 2002/11/03 07:06:06 simonb Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -661,6 +661,9 @@ parse(char *string, int flags)
|
|||
return;
|
||||
|
||||
case CTLTYPE_STRING:
|
||||
/* If sysctl() didn't return any data, don't print a string. */
|
||||
if (size == 0)
|
||||
buf[0] = '\0';
|
||||
if (newsize == 0) {
|
||||
if (!nflag)
|
||||
printf("%s = ", string);
|
||||
|
|
Loading…
Reference in New Issue