Subject: Re: Generic Properties
To: None <eeh@netbsd.org>
From: None <cgd@broadcom.com>
List: tech-kern
Date: 09/28/2001 18:48:58
eeh@netbsd.org writes:
> | OK. (BTW, Assuming you think this type of representation of a list of
> | NUL-terminated strings is The Right Thing, why did you add an extra
> | NUL to the end of the list of <whichever> names returned by sysctl?
> | why not just terminate in the same way, i.e., by running out of
> | buffer?)
>
> That code only applies to the "name" field of the property. The data
> field should not be touched. The reason for that code is primarily to
> prevent kernel panics from badly formed structures passed in from userland.
Eh?
My point was, assuming you think that an array of strings is
reasonably represented by those strings' (characters with NUL at end),
why do you want to put an extra NUL at the end of the string returned
by listprops()? (from the description; i've not looked at the code.)
You can still play the same game: look down the string until you hit
NUL or max length. If you got NUL you have a real string, if not you
don't.
If it's a good enough representation for an "array of strings" ... why
not others?
cgd