tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: recent sysctl changes



Thor Lancelot Simon wrote:
> > An application could, for example, maintain a single, shared,
> > malloc'ed buffer that is reused for multiple sysctl() calls and only
> > resized on ENOMEM returns.  IMO, this is allowed by the API, but with
> > your change, a read of a CTLTYPE_QUAD variable will return the wrong
> > result if the buffer happened to be left with a size of 4 by a
> > previous read of a CTLTYPE_INT variable.
> 
> But such a program would already have been buggy -- you can't read 
> CTLTYPE_QUAD
> into a buffer of size 4.

You can *attempt* to read CTLTYPE_QUAD into a buffer of size 4, 
get ENOMEM, increase the buffer size, and retry.
-- 
Andreas Gustafsson, gson%NetBSD.org@localhost


Home | Main Index | Thread Index | Old Index