You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@locus.apache.org on 2000/09/22 20:38:00 UTC

cvs commit: apache-1.3/src/os/win32 util_win32.c

wrowe       00/09/22 11:37:59

  Modified:    src/os/win32 util_win32.c
  Log:
    Fix util_win32 to accept '/', '//', '//machine/', and '//machine/share/'
    for url parsing in order to accept those <Directory > blocks.
  
    Big warning: remove the assumption that *~* is the alias name, and always
    walk the tree for aliasing.  This test is flawed, because NT can be, and
    Novell always follows different conventions.  It is only safe to always
    test, but the old test remains with a scary symbol to include it.
  
    There is some other optimization available, to perhaps flag that the url
    has already been walked/translated, but that isn't incorporated [yet].
  
  Revision  Changes    Path
  1.37      +47 -24    apache-1.3/src/os/win32/util_win32.c
  
  Index: util_win32.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/util_win32.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- util_win32.c	2000/06/23 19:44:31	1.36
  +++ util_win32.c	2000/09/22 18:37:56	1.37
  @@ -34,7 +34,7 @@
   {
       char buf[HUGE_STRING_LEN];
       char *pInputName;
  -    char *p, *q;
  +    char *p, *q, *t;
       BOOL bDone = FALSE;
       BOOL bFileExists = TRUE;
       HANDLE hFind;
  @@ -43,7 +43,7 @@
       if (!szFile || strlen(szFile) == 0 || strlen(szFile) >= sizeof(buf))
           return ap_pstrdup(pPool, "");
   
  -    buf[0] = '\0';
  +    t = buf;
       pInputName = ap_pstrdup(pPool, szFile);
   
       /* First convert all slashes to \ so Win32 calls work OK */
  @@ -52,27 +52,30 @@
               *p = '\\';
       }
       
  -    p = pInputName;
  +    q = p = pInputName;
       /* If there is drive information, copy it over. */ 
       if (pInputName[1] == ':') {
  -        buf[0] = tolower(*p++);
  -        buf[1] = *p++;
  -        buf[2] = '\0';
  +        /* This is correct - if systemcase is used for
  +         * comparison, d: designations will match
  +         */                    
  +        *(t++) = tolower(*p++);
  +        *(t++) = *p++;
  +        q = p;
   
           /* If all we have is a drive letter, then we are done */
  -        if (strlen(pInputName) == 2)
  +        if (!*p)
               bDone = TRUE;
  -    }
  -    
  -    q = p;
  +    }    
  +
       if (*p == '\\') {
  -        p++;
  -        if (*p == '\\')  /* Possible UNC name */
  +        ++p;
  +        if (*p == '\\')  /* UNC name */
           {
  -            p++;
               /* Get past the machine name.  FindFirstFile */
               /* will not find a machine name only */
  -            p = strchr(p, '\\'); 
  +            *(t++) = '\\';
  +            ++q;
  +            p = strchr(p + 1, '\\'); 
               if (p)
               {
                   p++;
  @@ -80,14 +83,21 @@
                   /* will not find a \\machine\share name only */
                   p = strchr(p, '\\'); 
                   if (p) {
  -                    strncat(buf,q,p-q);
  +                    /* This was faulty - as of 1.3.13 \\machine\share 
  +                     * name is now always lowercased
  +                     */
  +                    strncpy(t,q,p-q);
  +                    strlwr(t);
  +                    t += p - q;
                       q = p;
                       p++;
                   }
               }
   
  -            if (!p)
  +            if (!p) {
  +                bFileExists = FALSE;
                   p = q;
  +            }
           }
       }
   
  @@ -117,13 +127,18 @@
                   FindClose(hFind);
   
                   if (*q == '\\')
  -                    strcat(buf,"\\");
  -                strcat(buf, wfd.cFileName);
  +                    *(t++) = '\\';
  +                t = strchr(strcpy(t, wfd.cFileName), '\0');
               }
           }
           
           if (!bFileExists || OnlyDots((*q == '.' ? q : q+1))) {
  -            strcat(buf, q);
  +            /* WARNING: Comparison is faulty ...\unknown
  +             * names may not match!
  +             */
  +            strcpy(t, q);
  +            strlwr(t);
  +            t = strchr(t, '\0');
           }
           
           if (p) {
  @@ -135,8 +150,9 @@
               bDone = TRUE;
           }
       }
  +    *t = '\0';
       
  -    /* First convert all slashes to / so server code handles it ok */
  +    /* Finally, convert all slashes to / so server code handles it ok */
       for (p = buf; *p; p++) {
           if (*p == '\\')
               *p = '/';
  @@ -214,9 +230,17 @@
        *   (where n is a number) and the first three characters 
        *   after the last period."
        *  Here, we attempt to detect and decode these names.
  -     */
  -    p = strchr(pNewStr, '~');
  -    if (p != NULL) {
  +     *
  +     *  XXX: Netware network clients may have alternate short names,
  +     *  simply truncated, with no embedded '~'.  Further, this behavior
  +     *  can be modified on WinNT volumes.  This was not a safe test,
  +     *  therefore exclude the '~' pretest.
  +     */     
  +#ifdef WIN32_SHORT_FILENAME_INSECURE_BEHAVIOR
  +     p = strchr(pNewStr, '~');
  +     if (p != NULL)
  +#endif
  +     {
           char *pConvertedName, *pQstr, *pPstr;
           char buf[HUGE_STRING_LEN];
           /* We potentially have a short name.  Call 
  @@ -261,7 +285,6 @@
               pNewStr = ap_pstrdup(pPool, buf);
           }
       }
  -
   
       return pNewStr;
   }
  
  
  

RE: cvs commit: apache-1.3/src/os/win32 util_win32.c

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
No...

  If you stepped my patch to util_win32.c, you will see that we have
a much more complex schema to untangle names into the pure elements.
What I've done is bypassed most of this for the /, //, //server to
actually accept these elements without any sort of find test.  We
don't really know if //server is legit until we test //server/share/.
Now we accept all these flavors, although they consitute an incomplete
path spec.

  The ap_os_canonical_filename() stuff in util_[win32|os2|netware].c
is very different right now, and OS2 and WIN32 could probably merge.
I believe OS2 also supports blehblehbleh.x, and either blehbl~1.x or 
blehbleh.x flavors of short names.  It seems very early on that NT 
had choices in the config for how short names could be composed.  
Since OS2 also allows Novell client access, and Novell would use 
blehbleh.x, I was not happy with simply expanding shortnames in the 
*~* case.  Now we always case-correct and expand shortnames in 
ap_os_systemcase_filename.

  In Win32, I'm still unhappy with the amount of duplicity in the
ap_os_case_canonical_filename and ap_os_systemcase_filename functions.
I haven't decided precisely what to do here.  If you have suggestions,
they are welcome.

  ap_os_canonical_filename() (http_core.c:1454), for OS2/NETWARE,
should really sit in their respective util_[OS2|NETWARE].c files,
if they don't already.

Bill



> -----Original Message-----
> From: Brian Havard [mailto:brianh@kheldar.apana.org.au]
> Sent: Saturday, September 23, 2000 8:12 AM
> To: new-httpd@apache.org
> Subject: RE: cvs commit: apache-1.3/src/os/win32 util_win32.c
> 
> 
> On Fri, 22 Sep 2000 13:53:48 -0500, William A. Rowe, Jr. wrote:
> 
> >> wrowe       00/09/22 11:37:59
> >> 
> >>   Modified:    src/os/win32 util_win32.c
> >>   Log:
> >>     Fix util_win32 to accept '/', '//', '//machine/', and 
> '//machine/share/'
> >>     for url parsing in order to accept those <Directory > blocks.
> >
> >Warning - a very similar fix may be required to the OS2 
> port, but since
> >I have no way to test it, I have no assurance that OS2 will 
> even match
> ><Directory /> with the other patches committed.  Please see 
> util_os2.c
> >if you work on that platform and propose a similar fix if 
> one applies.
> 
> No, <Directory /> doesn't work yet, probably because the / path gets
> processed by ap_os_canonical_filename() (http_core.c:1454), 
> turning it into
> x:/ where x: is the current drive. Wouldn't that break windows too?
> 
> -- 
>  
> ______________________________________________________________
> ________________
>  |  Brian Havard                 |  "He is not the messiah!   
>                 |
>  |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" 
> - Life of Brian |
>  
> --------------------------------------------------------------
> ----------------
> 
> 

RE: cvs commit: apache-1.3/src/os/win32 util_win32.c

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Fri, 22 Sep 2000 13:53:48 -0500, William A. Rowe, Jr. wrote:

>> wrowe       00/09/22 11:37:59
>> 
>>   Modified:    src/os/win32 util_win32.c
>>   Log:
>>     Fix util_win32 to accept '/', '//', '//machine/', and '//machine/share/'
>>     for url parsing in order to accept those <Directory > blocks.
>
>Warning - a very similar fix may be required to the OS2 port, but since
>I have no way to test it, I have no assurance that OS2 will even match
><Directory /> with the other patches committed.  Please see util_os2.c
>if you work on that platform and propose a similar fix if one applies.

No, <Directory /> doesn't work yet, probably because the / path gets
processed by ap_os_canonical_filename() (http_core.c:1454), turning it into
x:/ where x: is the current drive. Wouldn't that break windows too?

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


RE: cvs commit: apache-1.3/src/os/win32 util_win32.c

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Fri, 22 Sep 2000 13:53:48 -0500, William A. Rowe, Jr. wrote:

>> wrowe       00/09/22 11:37:59
>> 
>>   Modified:    src/os/win32 util_win32.c
>>   Log:
>>     Fix util_win32 to accept '/', '//', '//machine/', and '//machine/share/'
>>     for url parsing in order to accept those <Directory > blocks.
>
>Warning - a very similar fix may be required to the OS2 port, but since
>I have no way to test it, I have no assurance that OS2 will even match
><Directory /> with the other patches committed.  Please see util_os2.c
>if you work on that platform and propose a similar fix if one applies.

Ok, I'm on it.

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


RE: cvs commit: apache-1.3/src/os/win32 util_win32.c

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
> wrowe       00/09/22 11:37:59
> 
>   Modified:    src/os/win32 util_win32.c
>   Log:
>     Fix util_win32 to accept '/', '//', '//machine/', and '//machine/share/'
>     for url parsing in order to accept those <Directory > blocks.

Warning - a very similar fix may be required to the OS2 port, but since
I have no way to test it, I have no assurance that OS2 will even match
<Directory /> with the other patches committed.  Please see util_os2.c
if you work on that platform and propose a similar fix if one applies.

   
>     Big warning: remove the assumption that *~* is the alias name, and always
>     walk the tree for aliasing.  This test is flawed, because NT can be, and
>     Novell always follows different conventions.  It is only safe to always
>     test, but the old test remains with a scary symbol to include it.
>   
>     There is some other optimization available, to perhaps flag that the url
>     has already been walked/translated, but that isn't incorporated [yet].

I will get on this if noone else steps up... I'm now out of town till late
Sunday, but will check back then - apply any fixes, backout whatever is
completely unacceptable, etc, review thoughts, etc.