You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ken Parzygnat <kp...@raleigh.ibm.com> on 1998/09/30 21:30:01 UTC

Win32: Why strlwr os_canonical_filename?

I have a question regarding the following code
segment from sub_canonical_filename:

if (h == INVALID_HANDLE_VALUE) {
    ap_assert(strlen(szCanon) + strlen(szFilePart) + nSlashes < nCanon);
    for (n = 0; n < nSlashes; ++n) {
        strcat(szCanon, "/");
    }
    strcat(szCanon, szFilePart);
    return FALSE;
}
else {
    ap_assert(strlen(szCanon)+strlen(d.cFileName) < nCanon);
    strlwr(d.cFileName);
    strcat(szCanon, d.cFileName);
    return TRUE;
}

Why is strlwr being called in the else leg?  Can we remove
this call?

I realize that Win32 filenames are case insensitive for the most part;
however, this line is massaging things like PATH_TRANSLATED
(as PR 3038 points out).  Interpreters such as JAVA actually
are case sensitive on Win32 when it comes to their .class filenames.

Note in the above code that if h == INVALID_HANDLE, then
the file does not actually exist, and we are not converting
to lower case.

Thanks.
- - - - - - - - - - - - - - - - - -
Ken Parzygnat
email: kparz@raleigh.ibm.com 

Re: Win32: Why strlwr os_canonical_filename?

Posted by Marc Slemko <ma...@znep.com>.
On Fri, 2 Oct 1998, Ben Laurie wrote:

> Marc Slemko wrote:
> > 
> > On Wed, 30 Sep 1998, Ken Parzygnat wrote:
> > 
> > > I have a question regarding the following code
> > > segment from sub_canonical_filename:
> > >
> > > if (h == INVALID_HANDLE_VALUE) {
> > >     ap_assert(strlen(szCanon) + strlen(szFilePart) + nSlashes < nCanon);
> > >     for (n = 0; n < nSlashes; ++n) {
> > >         strcat(szCanon, "/");
> > >     }
> > >     strcat(szCanon, szFilePart);
> > >     return FALSE;
> > > }
> > > else {
> > >     ap_assert(strlen(szCanon)+strlen(d.cFileName) < nCanon);
> > >     strlwr(d.cFileName);
> > >     strcat(szCanon, d.cFileName);
> > >     return TRUE;
> > > }
> > >
> > > Why is strlwr being called in the else leg?  Can we remove
> > > this call?
> > 
> > Because we need some way to be able to try to compare filenames, for
> > numerous purposes such as access control.
> > 
> > Because, due to the greatness of Win32, there are around 9543 different
> > names for any file, and differing case is one of those ways, we have to
> > lowercase things.
> > 
> > This should, however, only be done on the actual filename part, nothing
> > else.  I seem to remember this being fixed three or four times.
> 
> It is only being done on the actual filename part.

Except that PATH_TRANSLATED is a filename but it isn't a filename.

See PR#mumble, which likely prompted this question.  


Re: Win32: Why strlwr os_canonical_filename?

Posted by Ben Laurie <be...@algroup.co.uk>.
Ken Parzygnat wrote:
> However, the user could really use the path and
> filename in the case as it is on the file system because
> of the way the JAVA interpreter works.  Since I'm
> sympathetic to his problem, I was fiddling around
> with creating a routine like ap_os_case_filename that
> would take a filename and return the filename with
> the case on the file system respected.  We could
> use this to set the PATH_TRANSLATED variable.
> Good idea or bad idea?

I'm not sure whether it is a good idea to set PATH_TRANSLATED, but
certainly we could set _something_ to this.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686| Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org/
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd,     |Apache-SSL author     http://www.apache-ssl.org/
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache/

WE'RE RECRUITING! http://www.aldigital.co.uk/

RE: Win32: Why strlwr os_canonical_filename?

Posted by Ken Parzygnat <kp...@raleigh.ibm.com>.
> 
> It is only being done on the actual filename part.
> 

Actually, I believe it is being done on the entire 
path and filename.  Remember that sub_canonical_filename
is recursive and calls itself for every step along the
path.  Again, remember that no lower casing occurs
if the file does not exist.

The PR in question is 3038.  I closed the PR after
Marc's response and talking to Ken Coar about 
what the CGI spec says about PATH_TRANSLATED.
The spec says that PATH_TRANSLATED need only be
"the OS path to the file", which on a case insensitive
Win32 system means that all lower case is OK.

However, the user could really use the path and
filename in the case as it is on the file system because
of the way the JAVA interpreter works.  Since I'm
sympathetic to his problem, I was fiddling around 
with creating a routine like ap_os_case_filename that
would take a filename and return the filename with
the case on the file system respected.  We could
use this to set the PATH_TRANSLATED variable.
Good idea or bad idea?

- - - - - - - - - - - - - - - - - -
Ken Parzygnat
email: kparz@raleigh.ibm.com 

Re: Win32: Why strlwr os_canonical_filename?

Posted by Ben Laurie <be...@algroup.co.uk>.
Marc Slemko wrote:
> 
> On Wed, 30 Sep 1998, Ken Parzygnat wrote:
> 
> > I have a question regarding the following code
> > segment from sub_canonical_filename:
> >
> > if (h == INVALID_HANDLE_VALUE) {
> >     ap_assert(strlen(szCanon) + strlen(szFilePart) + nSlashes < nCanon);
> >     for (n = 0; n < nSlashes; ++n) {
> >         strcat(szCanon, "/");
> >     }
> >     strcat(szCanon, szFilePart);
> >     return FALSE;
> > }
> > else {
> >     ap_assert(strlen(szCanon)+strlen(d.cFileName) < nCanon);
> >     strlwr(d.cFileName);
> >     strcat(szCanon, d.cFileName);
> >     return TRUE;
> > }
> >
> > Why is strlwr being called in the else leg?  Can we remove
> > this call?
> 
> Because we need some way to be able to try to compare filenames, for
> numerous purposes such as access control.
> 
> Because, due to the greatness of Win32, there are around 9543 different
> names for any file, and differing case is one of those ways, we have to
> lowercase things.
> 
> This should, however, only be done on the actual filename part, nothing
> else.  I seem to remember this being fixed three or four times.

It is only being done on the actual filename part.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686| Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org/
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd,     |Apache-SSL author     http://www.apache-ssl.org/
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache/

WE'RE RECRUITING! http://www.aldigital.co.uk/

Re: Win32: Why strlwr os_canonical_filename?

Posted by Marc Slemko <ma...@worldgate.com>.
On Wed, 30 Sep 1998, Ken Parzygnat wrote:

> I have a question regarding the following code
> segment from sub_canonical_filename:
> 
> if (h == INVALID_HANDLE_VALUE) {
>     ap_assert(strlen(szCanon) + strlen(szFilePart) + nSlashes < nCanon);
>     for (n = 0; n < nSlashes; ++n) {
>         strcat(szCanon, "/");
>     }
>     strcat(szCanon, szFilePart);
>     return FALSE;
> }
> else {
>     ap_assert(strlen(szCanon)+strlen(d.cFileName) < nCanon);
>     strlwr(d.cFileName);
>     strcat(szCanon, d.cFileName);
>     return TRUE;
> }
> 
> Why is strlwr being called in the else leg?  Can we remove
> this call?

Because we need some way to be able to try to compare filenames, for
numerous purposes such as access control.

Because, due to the greatness of Win32, there are around 9543 different
names for any file, and differing case is one of those ways, we have to
lowercase things.

This should, however, only be done on the actual filename part, nothing
else.  I seem to remember this being fixed three or four times.

Sigh.