util_win32.c revision cccd31fa4a72fe23cc3249c06db181b274a55a69
842ae4bd224140319ae7feec1872b93dfd491143fielding/* ====================================================================
842ae4bd224140319ae7feec1872b93dfd491143fielding * The Apache Software License, Version 1.1
842ae4bd224140319ae7feec1872b93dfd491143fielding *
842ae4bd224140319ae7feec1872b93dfd491143fielding * Copyright (c) 2000 The Apache Software Foundation. All rights
842ae4bd224140319ae7feec1872b93dfd491143fielding * reserved.
842ae4bd224140319ae7feec1872b93dfd491143fielding *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Redistribution and use in source and binary forms, with or without
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * modification, are permitted provided that the following conditions
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * are met:
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd *
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 1. Redistributions of source code must retain the above copyright
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * notice, this list of conditions and the following disclaimer.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd *
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 2. Redistributions in binary form must reproduce the above copyright
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * notice, this list of conditions and the following disclaimer in
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * the documentation and/or other materials provided with the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * distribution.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh *
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * 3. The end-user documentation included with the redistribution,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * if any, must include the following acknowledgment:
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * "This product includes software developed by the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Apache Software Foundation (http://www.apache.org/)."
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Alternately, this acknowledgment may appear in the software itself,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * if and wherever such third-party acknowledgments normally appear.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 4. The names "Apache" and "Apache Software Foundation" must
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * not be used to endorse or promote products derived from this
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * software without prior written permission. For written
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * permission, please contact apache@apache.org.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 5. Products derived from this software may not be called "Apache",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * nor may "Apache" appear in their name, without prior written
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * permission of the Apache Software Foundation.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
f888346b48f5e5b5e3f0a47dedb8cefd2759a4e2gregames * SUCH DAMAGE.
750d12c59545dbbac70390988de94f7e901b08f2niq * ====================================================================
82632a19f2f9c346fee2b28a65920ba9737b3973minfrin *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * This software consists of voluntary contributions made by many
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * individuals on behalf of the Apache Software Foundation. For more
db455cbc662c98dbbf53175393c50086ff63370cchrisd * information on the Apache Software Foundation, please see
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * <http://www.apache.org/>.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Portions of this software are based upon public domain software
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * originally written at the National Center for Supercomputing Applications,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * University of Illinois, Urbana-Champaign.
7184de27ec1d62a83c41cdeac0953ca9fd661e8csf */
7184de27ec1d62a83c41cdeac0953ca9fd661e8csf
7184de27ec1d62a83c41cdeac0953ca9fd661e8csf#include "httpd.h"
36ef8f77bffe75d1aa327882be1b5bdbe2ff567asf#include "http_log.h"
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb#include "apr_strings.h"
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz#include <stdarg.h>
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz#include <time.h>
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz#include <stdlib.h>
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz/* Returns TRUE if the input string is a string
18b5268e013574026b2503b1641baf3299045f45sf * of one or more '.' characters.
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz */
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantzstatic BOOL OnlyDots(char *pString)
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz{
60a765cccbd3f3b5997b65b0034220c79f78369etrawick char *c;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (*pString == '\0')
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return FALSE;
4f9c22c4f27571d54197be9674e1fc0d528192aestriker
a2a0abd88b19e042a3eb2a9fa1702c25ad51303dwrowe for (c = pString;*c;c++)
4f9c22c4f27571d54197be9674e1fc0d528192aestriker if (*c != '.')
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return FALSE;
4f9c22c4f27571d54197be9674e1fc0d528192aestriker
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb return TRUE;
4f9c22c4f27571d54197be9674e1fc0d528192aestriker}
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
4f9c22c4f27571d54197be9674e1fc0d528192aestriker/* Accepts as input a pathname, and tries to match it to an
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * existing path and return the pathname in the case that
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * is present on the existing path. This routine also
18b5268e013574026b2503b1641baf3299045f45sf * converts alias names to long names.
18b5268e013574026b2503b1641baf3299045f45sf */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(char *) ap_os_systemcase_filename(apr_pool_t *pPool,
4f9c22c4f27571d54197be9674e1fc0d528192aestriker const char *szFile)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb{
4f9c22c4f27571d54197be9674e1fc0d528192aestriker char buf[HUGE_STRING_LEN];
4f9c22c4f27571d54197be9674e1fc0d528192aestriker char *pInputName;
60a765cccbd3f3b5997b65b0034220c79f78369etrawick char *p, *q, *t;
60a765cccbd3f3b5997b65b0034220c79f78369etrawick BOOL bDone = FALSE;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb BOOL bFileExists = TRUE;
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd HANDLE hFind;
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd WIN32_FIND_DATA wfd;
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd if (!szFile || strlen(szFile) == 0 || strlen(szFile) >= sizeof(buf))
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe return apr_pstrdup(pPool, "");
963f8b44ac95132458ea3b6aaa8ebc135188e473takashi
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe t = buf;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe pInputName = apr_pstrdup(pPool, szFile);
185aa71728867671e105178b4c66fbc22b65ae26sf
c2cf53a40a9814eb91db2cdf820f97d943f21628coar /* First convert all slashes to \ so Win32 calls work OK */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe for (p = pInputName; *p; p++) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (*p == '/')
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar *p = '\\';
4760b58cc9fe170e4ad4648ed4ff7a422a2cef38sf }
4760b58cc9fe170e4ad4648ed4ff7a422a2cef38sf
4760b58cc9fe170e4ad4648ed4ff7a422a2cef38sf q = p = pInputName;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* If there is drive information, copy it over. */
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar if (pInputName[1] == ':') {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* This is correct - if systemcase is used for
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * comparison, d: designations will match
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe *(t++) = tolower(*p++);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe *(t++) = *p++;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe q = p;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* If all we have is a drive letter, then we are done */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (!*p)
3e392a5afd51526de3cb15d57ee46d8cb160ae65gregames bDone = TRUE;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf q = p;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (*p == '\\') {
7184de27ec1d62a83c41cdeac0953ca9fd661e8csf ++p;
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar if (*p == '\\') /* UNC name */
3770ed746d69c7a4111cba9966169bd5d7a509a6poirier {
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar p++;
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar /* Get past the machine name. FindFirstFile
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * will not find a machine name only
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar */
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz *(t++) = '\\';
2a6e98ba4ffa30ded5d8831664c5cb2a170a56b6coar ++q;
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar p = strchr(p + 1, '\\');
185aa71728867671e105178b4c66fbc22b65ae26sf if (p)
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar {
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar p++;
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar /* Get past the share name. FindFirstFile */
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar /* will not find a \\machine\share name only */
2a6e98ba4ffa30ded5d8831664c5cb2a170a56b6coar p = strchr(p, '\\');
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz if (p) {
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz /* This was faulty - as of 1.3.13 \\machine\share
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * name is now always lowercased
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe strncpy(t,q,p-q);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe strlwr(t);
4f9c22c4f27571d54197be9674e1fc0d528192aestriker t += p - q;
4f9c22c4f27571d54197be9674e1fc0d528192aestriker q = p;
3e392a5afd51526de3cb15d57ee46d8cb160ae65gregames p++;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe }
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar }
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe if (!p) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe bFileExists = FALSE;
48e4b65042d94992c50f1db6c0b0cdbd99ca77e8sf p = q;
48e4b65042d94992c50f1db6c0b0cdbd99ca77e8sf }
48e4b65042d94992c50f1db6c0b0cdbd99ca77e8sf }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe }
7184de27ec1d62a83c41cdeac0953ca9fd661e8csf
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf p = strchr(p, '\\');
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf while (!bDone) {
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf if (p)
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe *p = '\0';
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe if (strchr(q, '*') || strchr(q, '?'))
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe bFileExists = FALSE;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
4f9c22c4f27571d54197be9674e1fc0d528192aestriker /* If the path exists so far, call FindFirstFile
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * again. However, if this portion of the path contains
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * only '.' charaters, skip the call to FindFirstFile
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * since it will convert '.' and '..' to actual names.
c2cf53a40a9814eb91db2cdf820f97d943f21628coar * Note: in the call to OnlyDots, we may have to skip
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * a leading slash.
4775dfc34c90fada8c7c4d6a57ed8a3114d55c2dtrawick */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (bFileExists && !OnlyDots((*q == '.' ? q : q+1))) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe hFind = FindFirstFile(pInputName, &wfd);
11a0edf478ca9c59d80bf73491d89cf019259feeniq
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe if (hFind == INVALID_HANDLE_VALUE) {
11a0edf478ca9c59d80bf73491d89cf019259feeniq bFileExists = FALSE;
11a0edf478ca9c59d80bf73491d89cf019259feeniq }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe else {
48e4b65042d94992c50f1db6c0b0cdbd99ca77e8sf FindClose(hFind);
48e4b65042d94992c50f1db6c0b0cdbd99ca77e8sf
48e4b65042d94992c50f1db6c0b0cdbd99ca77e8sf if (*q == '\\')
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe *(t++) = '\\';
7184de27ec1d62a83c41cdeac0953ca9fd661e8csf t = strchr(strcpy(t, wfd.cFileName), '\0');
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf }
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf }
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf if (!bFileExists || OnlyDots((*q == '.' ? q : q+1))) {
60a765cccbd3f3b5997b65b0034220c79f78369etrawick /* XXX: Comparison could be faulty ...\unknown
60a765cccbd3f3b5997b65b0034220c79f78369etrawick * names may not be tested (if they reside outside
60a765cccbd3f3b5997b65b0034220c79f78369etrawick * of the file system)!
60a765cccbd3f3b5997b65b0034220c79f78369etrawick */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe strcpy(t, q);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe t = strchr(t, '\0');
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (p) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe q = p;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe *p++ = '\\';
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe p = strchr(p, '\\');
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe }
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe else {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe bDone = TRUE;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe }
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd }
4f9c22c4f27571d54197be9674e1fc0d528192aestriker *t = '\0';
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe /* Finally, convert all slashes to / so server code handles it ok */
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd for (p = buf; *p; p++) {
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd if (*p == '\\')
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd *p = '/';
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar }
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes return apr_pstrdup(pPool, buf);
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes}
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes
18b5268e013574026b2503b1641baf3299045f45sf
18b5268e013574026b2503b1641baf3299045f45sf/* Perform canonicalization with the exception that the
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes * input case is preserved.
4f9c22c4f27571d54197be9674e1fc0d528192aestriker */
18b5268e013574026b2503b1641baf3299045f45sfAP_DECLARE(char *) ap_os_case_canonical_filename(apr_pool_t *pPool,
18b5268e013574026b2503b1641baf3299045f45sf const char *szFile)
18b5268e013574026b2503b1641baf3299045f45sf{
18b5268e013574026b2503b1641baf3299045f45sf char *pNewStr;
d9cc5de428947d5c7221d7d42ceefea649bcab48sf char *s;
18b5268e013574026b2503b1641baf3299045f45sf char *p;
18b5268e013574026b2503b1641baf3299045f45sf char *q;
18b5268e013574026b2503b1641baf3299045f45sf
18b5268e013574026b2503b1641baf3299045f45sf if (szFile == NULL || strlen(szFile) == 0)
18b5268e013574026b2503b1641baf3299045f45sf return apr_pstrdup(pPool, "");
18b5268e013574026b2503b1641baf3299045f45sf
404381a78d109fd3a4a7702e69815e4d7ff6d93asf pNewStr = apr_pstrdup(pPool, szFile);
404381a78d109fd3a4a7702e69815e4d7ff6d93asf
1a7a4f8c6a312cb237e428c77da0792eb165dc7aniq /* Change all '\' characters to '/' characters.
1a7a4f8c6a312cb237e428c77da0792eb165dc7aniq * While doing this, remove any trailing '.'.
185aa71728867671e105178b4c66fbc22b65ae26sf * Also, blow away any directories with 3 or
60fc37bb7b498f4bba5eaaa73a42a25daa27a9dasf * more '.'
60fc37bb7b498f4bba5eaaa73a42a25daa27a9dasf */
60fc37bb7b498f4bba5eaaa73a42a25daa27a9dasf for (p = pNewStr,s = pNewStr; *s; s++,p++) {
1a7a4f8c6a312cb237e428c77da0792eb165dc7aniq if (*s == '\\' || *s == '/') {
1a7a4f8c6a312cb237e428c77da0792eb165dc7aniq
1a7a4f8c6a312cb237e428c77da0792eb165dc7aniq q = p;
1a7a4f8c6a312cb237e428c77da0792eb165dc7aniq while (p > pNewStr && *(p-1) == '.')
18b5268e013574026b2503b1641baf3299045f45sf p--;
18b5268e013574026b2503b1641baf3299045f45sf
18b5268e013574026b2503b1641baf3299045f45sf if (p == pNewStr && q-p <= 2 && *p == '.')
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes p = q;
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes else if (p > pNewStr && p < q && *(p-1) == '/') {
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes if (q-p > 2)
18b5268e013574026b2503b1641baf3299045f45sf p--;
18b5268e013574026b2503b1641baf3299045f45sf else
18b5268e013574026b2503b1641baf3299045f45sf p = q;
18b5268e013574026b2503b1641baf3299045f45sf }
18b5268e013574026b2503b1641baf3299045f45sf
18b5268e013574026b2503b1641baf3299045f45sf *p = '/';
18b5268e013574026b2503b1641baf3299045f45sf }
4f9c22c4f27571d54197be9674e1fc0d528192aestriker else {
18b5268e013574026b2503b1641baf3299045f45sf *p = *s;
18b5268e013574026b2503b1641baf3299045f45sf }
18b5268e013574026b2503b1641baf3299045f45sf }
18b5268e013574026b2503b1641baf3299045f45sf *p = '\0';
d9cc5de428947d5c7221d7d42ceefea649bcab48sf
18b5268e013574026b2503b1641baf3299045f45sf /* Blow away any final trailing '.' since on Win32
18b5268e013574026b2503b1641baf3299045f45sf * foo.bat == foo.bat. == foo.bat... etc.
18b5268e013574026b2503b1641baf3299045f45sf * Also blow away any trailing spaces since
18b5268e013574026b2503b1641baf3299045f45sf * "filename" == "filename "
18b5268e013574026b2503b1641baf3299045f45sf */
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes q = p;
18b5268e013574026b2503b1641baf3299045f45sf while (p > pNewStr && (*(p-1) == '.' || *(p-1) == ' '))
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes p--;
69bbd0a9d1892949e1d4e454c10e8ad24b37c759sf if ((p > pNewStr) ||
69bbd0a9d1892949e1d4e454c10e8ad24b37c759sf (p == pNewStr && q-p > 2))
185aa71728867671e105178b4c66fbc22b65ae26sf *p = '\0';
60fc37bb7b498f4bba5eaaa73a42a25daa27a9dasf
60fc37bb7b498f4bba5eaaa73a42a25daa27a9dasf
60fc37bb7b498f4bba5eaaa73a42a25daa27a9dasf /* One more security issue to deal with. Win32 allows
69bbd0a9d1892949e1d4e454c10e8ad24b37c759sf * you to create long filenames. However, alias filenames
69bbd0a9d1892949e1d4e454c10e8ad24b37c759sf * are always created so that the filename will
69bbd0a9d1892949e1d4e454c10e8ad24b37c759sf * conform to 8.3 rules. According to the Microsoft
69bbd0a9d1892949e1d4e454c10e8ad24b37c759sf * Developer's network CD (1/98)
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes * "Automatically generated aliases are composed of the
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes * first six characters of the filename plus ~n
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes * (where n is a number) and the first three characters
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes * after the last period."
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes * Here, we attempt to detect and decode these names.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe *
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * XXX: Netware network clients may have alternate short names,
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * simply truncated, with no embedded '~'. Further, this behavior
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * can be modified on WinNT volumes. This was not a safe test,
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * therefore exclude the '~' pretest.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe */
d176cb9e596e4603f76490f9211f62b5581b3091rooneg#ifdef WIN32_SHORT_FILENAME_INSECURE_BEHAVIOR
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz p = strchr(pNewStr, '~');
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (p != NULL)
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe#endif
d176cb9e596e4603f76490f9211f62b5581b3091rooneg {
4760b58cc9fe170e4ad4648ed4ff7a422a2cef38sf char *pConvertedName, *pQstr, *pPstr;
4760b58cc9fe170e4ad4648ed4ff7a422a2cef38sf char buf[HUGE_STRING_LEN];
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* We potentially have a short name. Call
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * ap_os_systemcase_filename to examine the filesystem
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * and possibly extract the long name.
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe pConvertedName = ap_os_systemcase_filename(pPool, pNewStr);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* Since we want to preserve the incoming case as much
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * as we can, compare for differences in the string and
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * only substitute in the path names that changed.
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe */
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if (stricmp(pNewStr, pConvertedName)) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe buf[0] = '\0';
4f9c22c4f27571d54197be9674e1fc0d528192aestriker
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe q = pQstr = pConvertedName;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe p = pPstr = pNewStr;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe do {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe q = strchr(q,'/');
0540a0b469147b52e858587270dba31c2aaa9e09wrowe p = strchr(p,'/');
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if (p != NULL) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe *q = '\0';
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe *p = '\0';
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe }
4f9c22c4f27571d54197be9674e1fc0d528192aestriker
4f9c22c4f27571d54197be9674e1fc0d528192aestriker if (stricmp(pQstr, pPstr))
4f9c22c4f27571d54197be9674e1fc0d528192aestriker strcat(buf, pQstr); /* Converted name */
4f9c22c4f27571d54197be9674e1fc0d528192aestriker else
4f9c22c4f27571d54197be9674e1fc0d528192aestriker strcat(buf, pPstr); /* Original name */
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if (p != NULL) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe pQstr = q;
a2b181763cb35fd899feb4a436aeadaa80bf91eabrianp pPstr = p;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe *q++ = '/';
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd *p++ = '/';
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd }
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd } while (p != NULL);
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd pNewStr = apr_pstrdup(pPool, buf);
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd }
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd }
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd return pNewStr;
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd}
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe
a2b181763cb35fd899feb4a436aeadaa80bf91eabrianp/* Perform complete canonicalization.
f46cb698a1b32d16a0107566568f67d8c3f8ee9csf */
4f9c22c4f27571d54197be9674e1fc0d528192aestrikerAP_DECLARE(char *) ap_os_canonical_filename(apr_pool_t *pPool, const char *szFile)
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd{
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd char *pNewName;
4f9c22c4f27571d54197be9674e1fc0d528192aestriker pNewName = ap_os_case_canonical_filename(pPool, szFile);
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd strlwr(pNewName);
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd return pNewName;
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd}
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd#ifdef NEVER_SINCE_THESE_TESTS_ARE_MOVING
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd/*
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * XXX we will no longer use this redunant parsing function, it's
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * logic moves off into the canonical filename processing and the
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * apr file handling functions. Left for today till it's finished.
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd *
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * ap_os_is_filename_valid is given a filename, and returns 0 if the filename
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * is not valid for use on this system. On Windows, this means it fails any
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * of the tests below. Otherwise returns 1.
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe *
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * Test for filename validity on Win32. This is of tests come in part from
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * the MSDN article at "Technical Articles, Windows Platform, Base Services,
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * Guidelines, Making Room for Long Filenames" although the information
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * in MSDN about filename testing is incomplete or conflicting. There is a
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * similar set of tests in "Technical Articles, Windows Platform, Base Services,
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * Guidelines, Moving Unix Applications to Windows NT".
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd *
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * The tests are:
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd *
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * 1) total path length greater than MAX_PATH
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd *
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * 2) anything using the octets 0-31 or characters " < > | :
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * (these are reserved for Windows use in filenames. In addition
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * each file system has its own additional characters that are
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * invalid. See KB article Q100108 for more details).
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe *
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * 3) anything ending in "." (no matter how many)
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * (filename doc, doc. and doc... all refer to the same file)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 4) any segment in which the basename (before first period) matches
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * one of the DOS device names
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * (the list comes from KB article Q100108 although additional
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * names such as "COM5" are also special devices).
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb *
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * If the path fails ANY of these tests, the result must be to deny access.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbAP_DECLARE(int) ap_os_is_filename_valid(const char *file)
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb{
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *segstart;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb unsigned int seglength;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *pos;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb static const char * const invalid_characters = "?\"<>*|:";
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb static const char * const invalid_filenames[] = {
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe "CON", "AUX", "COM1", "COM2", "COM3",
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe "COM4", "LPT1", "LPT2", "LPT3", "PRN", "NUL", NULL
4f9c22c4f27571d54197be9674e1fc0d528192aestriker };
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* Test 1 */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe if (strlen(file) >= MAX_PATH) {
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* Path too long for Windows. Note that this test is not valid
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * if the path starts with //?/ or \\?\. */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe return 0;
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe }
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe
4f9c22c4f27571d54197be9674e1fc0d528192aestriker pos = file;
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* Skip any leading non-path components. This can be either a
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * drive letter such as C:, or a UNC path such as \\SERVER\SHARE\.
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * We continue and check the rest of the path based on the rules above.
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * This means we could eliminate valid filenames from servers which
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz * are not running NT (such as Samba).
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe */
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe if (pos[0] && pos[1] == ':') {
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar /* Skip leading drive letter */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe pos += 2;
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz }
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz else {
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz if ((pos[0] == '\\' || pos[0] == '/') &&
1e911973bcb9df6701a4c16c037771ecf25ade13niq (pos[1] == '\\' || pos[1] == '/')) {
1e911973bcb9df6701a4c16c037771ecf25ade13niq /* Is a UNC, so skip the server name and share name */
c3e233736c4a453cbb2166a041f779e86230630asf pos += 2;
c3e233736c4a453cbb2166a041f779e86230630asf while (*pos && *pos != '/' && *pos != '\\')
c3e233736c4a453cbb2166a041f779e86230630asf pos++;
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe if (!*pos) {
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar /* No share name */
11fb2f3611e6ff9a541e10b13e3108934f828141gregames return 0;
11fb2f3611e6ff9a541e10b13e3108934f828141gregames }
11fb2f3611e6ff9a541e10b13e3108934f828141gregames pos++; /* Move to start of share name */
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz while (*pos && *pos != '/' && *pos != '\\')
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz pos++;
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz if (!*pos) {
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz /* No path information */
4f9c22c4f27571d54197be9674e1fc0d528192aestriker return 0;
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe }
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe }
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe }
4f9c22c4f27571d54197be9674e1fc0d528192aestriker
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe while (*pos) {
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe unsigned int idx;
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe unsigned int baselength;
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar
c3e233736c4a453cbb2166a041f779e86230630asf while (*pos == '/' || *pos == '\\') {
c3e233736c4a453cbb2166a041f779e86230630asf pos++;
c3e233736c4a453cbb2166a041f779e86230630asf }
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe if (*pos == '\0') {
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar break;
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar }
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe segstart = pos; /* start of segment */
c3e233736c4a453cbb2166a041f779e86230630asf while (*pos && *pos != '/' && *pos != '\\') {
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe pos++;
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar }
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe seglength = pos - segstart;
1fbf6ba0f5207e6637b49f9a9dfcc779bbe952a9trawick /*
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe * Now we have a segment of the path, starting at position "segstart"
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar * and length "seglength"
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* Test 2 */
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz for (idx = 0; idx < seglength; idx++) {
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz if ((segstart[idx] > 0 && segstart[idx] < 32) ||
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz strchr(invalid_characters, segstart[idx])) {
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz return 0;
4f9c22c4f27571d54197be9674e1fc0d528192aestriker }
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe }
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Test 3 */
8aefbd756763807188d2e3ce336a8680e4893066wrowe if (segstart[seglength-1] == '.') {
700b96db75e7cfadb5219978c1735b710d583763wrowe return 0;
700b96db75e7cfadb5219978c1735b710d583763wrowe }
700b96db75e7cfadb5219978c1735b710d583763wrowe
700b96db75e7cfadb5219978c1735b710d583763wrowe /* Test 4 */
700b96db75e7cfadb5219978c1735b710d583763wrowe for (baselength = 0; baselength < seglength; baselength++) {
700b96db75e7cfadb5219978c1735b710d583763wrowe if (segstart[baselength] == '.') {
700b96db75e7cfadb5219978c1735b710d583763wrowe break;
700b96db75e7cfadb5219978c1735b710d583763wrowe }
700b96db75e7cfadb5219978c1735b710d583763wrowe }
700b96db75e7cfadb5219978c1735b710d583763wrowe
700b96db75e7cfadb5219978c1735b710d583763wrowe /* baselength is the number of characters in the base path of
700b96db75e7cfadb5219978c1735b710d583763wrowe * the segment (which could be the same as the whole segment length,
700b96db75e7cfadb5219978c1735b710d583763wrowe * if it does not include any dot characters). */
700b96db75e7cfadb5219978c1735b710d583763wrowe if (baselength == 3 || baselength == 4) {
700b96db75e7cfadb5219978c1735b710d583763wrowe for (idx = 0; invalid_filenames[idx]; idx++) {
700b96db75e7cfadb5219978c1735b710d583763wrowe if (strlen(invalid_filenames[idx]) == baselength &&
103a93c625bcde1a6a7a5155b64dcda36f612180pquerna !strnicmp(invalid_filenames[idx], segstart, baselength)) {
113961f0559eb026ea0d379cb7350f82bc09d710druggeri return 0;
700b96db75e7cfadb5219978c1735b710d583763wrowe }
700b96db75e7cfadb5219978c1735b710d583763wrowe }
6964758306167dd898baedd21048bd1515dd9d30trawick }
700b96db75e7cfadb5219978c1735b710d583763wrowe }
7184de27ec1d62a83c41cdeac0953ca9fd661e8csf
700b96db75e7cfadb5219978c1735b710d583763wrowe return 1;
700b96db75e7cfadb5219978c1735b710d583763wrowe}
700b96db75e7cfadb5219978c1735b710d583763wrowe#endif
700b96db75e7cfadb5219978c1735b710d583763wrowe
700b96db75e7cfadb5219978c1735b710d583763wroweAP_DECLARE(apr_status_t) ap_os_create_privileged_process(
700b96db75e7cfadb5219978c1735b710d583763wrowe const request_rec *r,
700b96db75e7cfadb5219978c1735b710d583763wrowe apr_proc_t *newproc, const char *progname,
700b96db75e7cfadb5219978c1735b710d583763wrowe const char * const *args,
700b96db75e7cfadb5219978c1735b710d583763wrowe const char * const *env,
700b96db75e7cfadb5219978c1735b710d583763wrowe apr_procattr_t *attr, apr_pool_t *p)
700b96db75e7cfadb5219978c1735b710d583763wrowe{
700b96db75e7cfadb5219978c1735b710d583763wrowe return apr_create_process(newproc, progname, args, env, attr, p);
700b96db75e7cfadb5219978c1735b710d583763wrowe}
700b96db75e7cfadb5219978c1735b710d583763wrowe
700b96db75e7cfadb5219978c1735b710d583763wrowe