coar 98/09/30 21:52:33
Modified: src/main http_core.c src/os/win32 util_win32.c Log: ap_os_canonical_filename was not treating 'x:/' correctly. The '/' was being stripped, then we'd call GetFullPathName which would take 'x:' and change it to the current path on x:, not the root of x:. Also, we'd end up adding another slash to x:/ and leave the routine with a 'x://'. PR: 3001 Submitted by: Ken Parzygnat <[EMAIL PROTECTED]> Reviewed by: Ben Laurie, Ken Coar Revision Changes Path 1.232 +14 -2 apache-1.3/src/main/http_core.c Index: http_core.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v retrieving revision 1.231 retrieving revision 1.232 diff -u -r1.231 -r1.232 --- http_core.c 1998/09/21 21:09:48 1.231 +++ http_core.c 1998/10/01 04:52:28 1.232 @@ -2670,8 +2670,20 @@ (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; 1.26 +35 -5 apache-1.3/src/os/win32/util_win32.c Index: util_win32.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/os/win32/util_win32.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- util_win32.c 1998/09/04 21:20:40 1.25 +++ util_win32.c 1998/10/01 04:52:32 1.26 @@ -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);