char docroot[512];
char *cp, *cp2;
const char *ccp;
- apr_finfo_t finfo;
unsigned int port;
int rulestatus;
int n;
* because we only do stat() on the first directory
* and this gets cached by the kernel for along time!
*/
- n = prefix_stat(r->filename, &finfo);
+ n = prefix_stat(r->filename, r->pool);
if (n == 0) {
if ((ccp = ap_document_root(r)) != NULL) {
l = apr_cpystrn(docroot, ccp, sizeof(docroot)) - docroot;
**
*/
-static int prefix_stat(const char *path, apr_finfo_t *sb)
+static int prefix_stat(const char *path, apr_pool_t *pool)
{
- char curpath[LONG_STRING_LEN];
- char *cp;
+ const char *curpath = path;
+ char *root;
+ char *slash;
+ char *statpath;
+ apr_status_t rv;
- apr_cpystrn(curpath, path, sizeof(curpath));
- if (curpath[0] != '/') {
+ rv = apr_filepath_root(&root, &curpath, APR_FILEPATH_TRUENAME, pool);
+
+ if (rv != APR_SUCCESS) {
return 0;
}
- if ((cp = strchr(curpath+1, '/')) != NULL) {
- *cp = '\0';
- }
- if (apr_stat(sb, curpath, APR_FINFO_MIN, NULL) == APR_SUCCESS) {
- return 1;
+
+ /* let's recognize slashes only, the mod_rewrite semantics are opaque
+ * enough.
+ */
+ if ((slash = ap_strchr(curpath, '/')) != NULL) {
+ rv = apr_filepath_merge(&statpath, root,
+ apr_pstrndup(pool, curpath,
+ (apr_size_t)(slash - curpath)),
+ APR_FILEPATH_NOTABOVEROOT |
+ APR_FILEPATH_NOTRELATIVE, pool);
}
else {
- return 0;
+ rv = apr_filepath_merge(&statpath, root, curpath,
+ APR_FILEPATH_NOTABOVEROOT |
+ APR_FILEPATH_NOTRELATIVE, pool);
}
+
+ if (rv == APR_SUCCESS) {
+ apr_finfo_t sb;
+
+ if (apr_stat(&sb, statpath, APR_FINFO_MIN, pool) == APR_SUCCESS) {
+ return 1;
+ }
+ }
+
+ return 0;
}
static char *subst_prefix_path(request_rec *r, char *input, char *match,
const char *subst);
static int parseargline(char *str, char **a1, char **a2, char **a3);
-static int prefix_stat(const char *path, apr_finfo_t *sb);
+static int prefix_stat(const char *path, apr_pool_t *pool);
static void add_env_variable(request_rec *r, char *s);
static void add_cookie(request_rec *r, char *s);
static int subreq_ok(request_rec *r);