tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: recent sysctl changes
On Mar 7, 2014, at 8:32 AM, Andreas Gustafsson <gson%NetBSD.org@localhost>
wrote:
> 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.
That's a specious argument. If you know the type if QUAD, and you
use less than a buffer size of 8, it's a bug (and you're an idiot).
That's like saying I can supply a bogus address, get EFAULT, and try
with a good address.
Home |
Main Index |
Thread Index |
Old Index