Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jun 2004 12:11:53 +1200 (NZST)
From:      Matthew Luckie <mjl@luckie.org.nz>
To:        hackers@freebsd.org
Cc:        mjl@luckie.org.nz
Subject:   use of kernel_sysctl
Message-ID:  <20040609115052.D24917@lycra.luckie.org.nz>

next in thread | raw e-mail | index | archive | help
in sys/netsmb/smb_subr.c the following code fragment is used:

[FreeBSD 4.10]

int smb_checksmp(void)
{
 	int name[2];
 	int olen, ncpu, plen, error;

 	name[0] = CTL_HW;
 	name[1] = HW_NCPU;
 	error = kernel_sysctl(curproc, name, 2, &ncpu, &olen, NULL, 0, &plen);
 	if (error)
 		return error;

olen is passed without having its value set.  on input, i'd expect it to 
specify sizeof(ncpu).  looking in kernel_sysctl.c, *olen is used by 
kernel_sysctl.

I had a quick grep through the source and saw a similar code fragment to 
this in nwfs.  So it could be either that I've got it wrong and I'm not 
understanding something, or the code was used as a template in more than 
one place and was bug-for-bug copied.

Feedback appreciated, cc'd

Matthew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040609115052.D24917>