Re: RFC: libkern version of inet_ntoa_r

From: Bjoern A. Zeeb <bzeeb-lists_at_lists.zabbadoz.net>
Date: Sat, 28 Jul 2012 22:44:29 +0000 (UTC)
On Sat, 28 Jul 2012, Arnaud Lacombe wrote:

> Hi,
>
> On Sat, Jul 28, 2012 at 6:14 PM, Bjoern A. Zeeb
> <bzeeb-lists_at_lists.zabbadoz.net> wrote:
>> On Wed, 25 Jul 2012, Luigi Rizzo wrote:
>>
>>> During some ipfw/dummynet cleanup i noticed that the libkern version of
>>> inet_ntoa_r() is missing the buffer size argument that is present in
>>> the libc counterpart.
>>>
>>> Any objection if i fix it ?
>>
>>
>> And why exactly would you need it?  What does libc do with it?  Render
>> partial IPv4 addresses?
>>
> Mitigate possibilities of memory corruption ? At the very least, allow
> the following:
>
> {
>    char tmp[sizeof "255.255.255.255"];

char tmp[INET_ADDRSTRLEN];

>
>    KASSERT(size >= (sizeof tmp));

This would need to go into the called library function and cannot.


>    [...]

So that gives you what extra checking exactly?  That the programmer got
the sizeof right rather than the buffer size? You pushed some more on the
stack or reused an register for something that is supposed to be at a
minial fixed length (nothing else lower allowed and will ever result
in anything but misbehaviour) no matter what.  It's not like it's
inet_pton which can take totally different sizes.


Which again leaves me with the question - why does libc have it?

/bz

-- 
Bjoern A. Zeeb                                 You have to have visions!
          Stop bit received. Insert coin for new address family.
Received on Sat Jul 28 2012 - 20:44:34 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:29 UTC