This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/6654] realpath contains off-by-one errors
- From: "john at calva dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 26 Jun 2008 07:51:16 -0000
- Subject: [Bug libc/6654] realpath contains off-by-one errors
- References: <20080618130922.6654.john@calva.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- 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.