This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/6654] realpath contains off-by-one errors


------- Additional Comments From john at calva dot com  2008-06-26 07:51 -------
Subject: Re:  realpath contains off-by-one errors

drepper at redhat dot com wrote:
> ------- Additional Comments From drepper at redhat dot com  2008-06-26 00:01 -------
> Your test program is wrong (the buffer must be PATH_MAX in size) and the patch
> is wrong (you cut out the last character).  There is also no problem on any
> platform defining PATH_MAX (incl Linux) since readlink can never return a value
>   
>> PATH_MAX-1.
>>     
>
> There is a potential problem on platforms without PATH_MAX (i.e., Hurd).  So I
> added a patch.
>
>   
Aha:

/usr/include/linux/limits.h:#define PATH_MAX        4096	/* # chars in a path name including nul */

So, since readlink doesn't return the null the max return from readlink 
is (PATH_MAX-1) bytes, as you say.

(Your patch is to call readlink with (path_max -1), right?)



-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=6654

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]