[PATCH] Fix readdir_r with long file names

Florian Weimer fweimer@redhat.com
Fri Jun 7 11:47:00 GMT 2013


On 06/06/2013 11:06 PM, KOSAKI Motohiro wrote:
>>> So, only broken applications may hit this? If so, do you really think
>>> such
>>> broken application checks return code correctly?
>>
>> There's precedent for my approach in realpath, where we don't use
>> pathconf(path, _PC_PATH_MAX), either, but cap the path length at
>> PATH_MAX.
>
> PATH_MAX is used VFS as hard coded limitations. So, I don't think any
> Linux filesystem have a long path exceed PATH_MAX.

The canonical name of a file can be longer than PATH_MAX characters. 
This is probably true for all file systems supported by Linux (with the 
possible exception of FAT).  I don't think Linux enforces a directory 
nesting limit, but if it does, it is significantly larger than 4095 
divided by 255.

You cannot directly open such files, but it's possible to reach them 
with (potentially multiple) calls to openat.

-- 
Florian Weimer / Red Hat Product Security Team



More information about the Libc-alpha mailing list