kern/117010: [linux] linux_getdents() get somethinng like buffer overflow

Alexander Leidinger Alexander at Leidinger.net
Mon Jul 28 11:40:49 UTC 2008


Quoting "Chagin Dmitry" <chagin.dmitry at gmail.com> (from Mon, 28 Jul  
2008 15:12:31 +0400 (MSD)):

> On Mon, 28 Jul 2008, Chagin Dmitry wrote:
>
>>
>> agree, we should do check before calculating linuxreclen, like:
>>
>> 	if (bdp->d_namlen > LINUX_NAME_MAX) {
>> 		error = ENAMETOOLONG;
>> 		goto out;
>> 	}
>>
>
> d_namlen declared as uint8_t, so comparison is always false. lets's  
> leave it will not changed FreeBSD d_namlen type?

In the kernel I prefer defensive programming. Better safe than sorry.  
As long as there's no evidence that it is a performance bottleneck,  
there's no need to micro-optimize.

Bye,
Alexander.

-- 
Capitalism can exist in one of only two states:
welfare or warfare.

http://www.Leidinger.net    Alexander @ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org       netchild @ FreeBSD.org  : PGP ID = 72077137


More information about the freebsd-emulation mailing list