This is the mail archive of the libc-alpha@sources.redhat.com 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]

Re: [PATCH] Realpath gives a path when it probably should not


Hi,

On Mon, Apr 25, 2005 at 09:15:56AM -0700, Ranjani Murthy wrote:
> Realpath gives a path to existing non directories.  It gives a path
> for pathnames like /tmp/file1.c/../../tmp/file2.c.  Realpath should
> return NULL and set errno to ENOTDIR in such a case.  Attached is the
> patch and a test case.
> 
> Ranjani
> 
> --- libc/stdlib/canonicalize.c.orig      2004-04-14 21:39:53 +0400
> +++ libc/stdlib/canonicalize.c   2004-06-14 21:42:05 +0400
> @@ -199,6 +199,11 @@ __realpath (const char *name, char *reso
>                 if (dest > rpath + 1)
>                   while ((--dest)[-1] != '/');
>             }
> +         else if (!S_ISDIR (st.st_mode) && *end)
> +           {
> +             __set_errno (ENOTDIR);
> +             goto error;
> +           }
>         }
>      }
>    if (dest > rpath + 1 && dest[-1] == '/')

Looks very similar to the patch I made about a year ago, even timezone
matches. :)

There are also 4 tests in test-canon.c which should be adjusted.

Here is that patch, just in case somebody really cares of this problem.


-- 
ldv

Attachment: glibc-2.3.3-alt-realpath.patch
Description: Text document

Attachment: pgp00000.pgp
Description: PGP signature


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