httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ken Parzygnat" <kp...@raleigh.ibm.com>
Subject RE: [PATCH] PR 3001- Win32: DocRoot x:/
Date Mon, 28 Sep 1998 20:11:06 GMT
Here's a refresh of the patch with all of
the changes that we've been discussing:

--- .\main\http_core.c.orig	Tue Sep 22 01:12:36 1998
+++ .\main\http_core.c	Mon Sep 28 18:08:21 1998
@@ -2670,8 +2670,18 @@
 				 (r->uri + r->server->pathlen), NULL);
     }
     else {
-        r->filename = ap_pstrcat(r->pool, conf->ap_document_root, r->uri,
-				 NULL);
+        /*
+         * Make sure that we do not mess up the translation by adding two
+         * /'s in a row.  This happens under windows when the document
+         * root ends with a /
+         */
+        if ((conf->ap_document_root[strlen(conf->ap_document_root)-1] == '/')
+            && (*(r->uri) == '/'))
+            r->filename = ap_pstrcat(r->pool, conf->ap_document_root,
r->uri+1,
+                                     NULL);
+        else
+            r->filename = ap_pstrcat(r->pool, conf->ap_document_root, r->uri,
+				    NULL);
     }

     return OK;
--- .\os\win32\util_win32.c.orig	Sat Sep 05 01:12:26 1998
+++ .\os\win32\util_win32.c	Mon Sep 28 19:12:02 1998
@@ -23,7 +23,18 @@
     for (nSlashes = 0; s > szFile && s[-1] == '\\'; ++nSlashes, --s)
 	;

-    n = GetFullPathName(szFile, sizeof buf, buf, &szFilePart);
+    if (strlen(szFile)==2 && szFile[1]==':') {
+        /*
+         * If the file name is x:, do not call GetFullPathName
+         * because it will use the current path of the executable
+         */
+        strcpy(buf,szFile);
+        n = strlen(buf);
+        szFilePart = buf + n;
+    }
+    else {
+        n = GetFullPathName(szFile, sizeof buf, buf, &szFilePart);
+    }
     ap_assert(n);
     ap_assert(n < sizeof buf);

@@ -36,6 +47,8 @@
      * is no '\' in szInFile, it must just be a file name, so it should be
      * valid to use the name from GetFullPathName.  Be sure to adjust the
      * 's' variable so the rest of the code functions normally.
+     * Note it is possible to get here when szFile == 'x:', but that is OK
+     * because we will bail out of this routine early.
      */
     if (!s) {
         szFile = buf;
@@ -180,9 +193,21 @@

     buf[0] = ap_tolower(buf[0]);

-    ap_assert(strlen(buf)+nSlashes < sizeof buf);
-    while (nSlashes--) {
-        strcat(buf, "/");
+    if (nSlashes) {
+        /*
+         * If there were additional trailing slashes, add them back on.
+         * Be sure not to add more than were originally there though,
+         * by checking to see if sub_canonical_filename added one;
+         * this could happen in cases where the file name is 'd:/'
+         */
+        ap_assert(strlen(buf)+nSlashes < sizeof buf);
+
+        if (nSlashes && buf[strlen(buf)-1] == '/')
+            nSlashes--;
+
+        while (nSlashes--) {
+            strcat(buf, "/");
+        }
     }

     return ap_pstrdup(pPool, buf);
@@ -233,8 +258,13 @@
 	return stat(buf, pStat);
     }

+    /*
+     * Below removes the trailing /, however, do not remove
+     * it in the case of 'x:/' or stat will fail
+     */
     n = strlen(szPath);
-    if (szPath[n - 1] == '\\' || szPath[n - 1] == '/') {
+    if ((szPath[n - 1] == '\\' || szPath[n - 1] == '/') &&
+        !(n == 3 && szPath[1] == ':')) {
         char buf[_MAX_PATH];

         ap_assert(n < _MAX_PATH);


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


Mime
View raw message