Skip site navigation (1) Skip section navigation (2)

Re: is_absolute_path incorrect on Windows

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Magnus Hagander" <magnus(at)hagander(dot)net>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: is_absolute_path incorrect on Windows
Date: 2010-04-09 14:02:32
Message-ID: 4BBEED280200002500030633@gw.wicourts.gov (view raw or flat)
Thread:
Lists: pgsql-hackers
Magnus Hagander <magnus(at)hagander(dot)net> wrote:
 
> it considers the following to be an absolute path:
> * Anything that starts with /
> * Anything that starst with \
 
These aren't truly absolute, because the directory you find will be
based on your current work directory's drive letter; however, if the
point is to then check whether it falls under the current work
directory, even when an absolute path is specified, it works.
 
> * Anything alphanumerical, followed by a colon, followed by either
> / or \
 
I assume we reject anything where what precedes the colon doesn't
match the current drive's designation?
 
> However, it misses the case with for example E:foo, which is a
> perfectly valid path on windows. Which isn't absolute *or*
> relative - it's relative to the current directory on the E: drive.
 
> This function is used in the genfile.c functions to read and list
> files by admin tools like pgadmin - to make sure we can only open
> files that are in our own data directory - by making sure they're
> either relative, or they're absolute but rooted in our own data
> directory. (It rejects anything with ".." in it already).
 
Well, if that's a good idea, then you would need to reject anything
specifying a drive which doesn't match the drive of the data
directory.  Barring the user from accessing directories on the
current drive which aren't under the data directory on that drive,
but allowing them to access any other drive they want, is just
silly.
 
It does raise the question of why we need to check this at all,
rather than counting on OS security to limit access to things which
shouldn't be seen.
 
-Kevin

In response to

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2010-04-09 14:25:13
Subject: Re: GSOC PostgreSQL partitioning issue
Previous:From: Magnus HaganderDate: 2010-04-09 13:16:58
Subject: is_absolute_path incorrect on Windows

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group