From: Martin Kraemer Date: Sat, 23 Oct 1999 21:20:16 +0000 (+0000) Subject: mod_speling runs in 2.0-dev now: a bug in (linux?) readdir_r handling and X-Git-Tag: 1.3.10~232 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d63973e0d40c9ac4427d4acbba1b3b52d0f03fb;p=thirdparty%2Fapache%2Fhttpd.git mod_speling runs in 2.0-dev now: a bug in (linux?) readdir_r handling and interface adaption to APR functions did it. [Martin Kraemer] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84027 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/mappers/mod_speling.c b/modules/mappers/mod_speling.c index e6699a56849..41956b20df2 100644 --- a/modules/mappers/mod_speling.c +++ b/modules/mappers/mod_speling.c @@ -61,7 +61,6 @@ #include "http_config.h" #include "http_log.h" #include "apr_file_io.h" -#include "../../lib/apr/misc/unix/misc.h" /* mod_speling.c - by Alexei Kosut June, 1996 * @@ -229,7 +228,7 @@ static int sort_by_quality(const void *left, const void *rite) static int check_speling(request_rec *r) { spconfig *cfg; - char *good, *bad, *postgood, *url; + char *good, *bad, *postgood, *url, *fname; int filoc, dotloc, urlen, pglen; ap_array_header_t *candidates = NULL; ap_dir_t *dir; @@ -302,17 +301,14 @@ static int check_speling(request_rec *r) dotloc = strlen(bad); } - while (ap_readdir(dir) == APR_SUCCESS) { + /* NOTE: ap_get_dir_filename() fills fname with a ap_palloc()ed copy + * of the found directory name already. We don't need to copy it. + * @@@: Copying *ALL* found file names is wasted energy (and memory)! + */ + while (ap_readdir(dir) == APR_SUCCESS && + ap_get_dir_filename(&fname, dir) == APR_SUCCESS) { sp_reason q; - char *fname; - ap_status_t ok; - - ok = ap_get_dir_filename(&fname, dir); -/*@@*/ - ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, APR_SUCCESS, - r, __FILE__": Check_Speling `%s' in `%s'", r->filename, good, ok==APR_SUCCESS ? fname : "ERROR"); -/*@@*/ /* * If we end up with a "fixed" URL which is identical to the * requested one, we must have found a broken symlink or some such. @@ -331,7 +327,7 @@ static int check_speling(request_rec *r) misspelled_file *sp_new; sp_new = (misspelled_file *) ap_push_array(candidates); - sp_new->name = ap_pstrdup(r->pool, fname); + sp_new->name = fname; sp_new->quality = SP_MISCAPITALIZED; } @@ -343,7 +339,7 @@ static int check_speling(request_rec *r) misspelled_file *sp_new; sp_new = (misspelled_file *) ap_push_array(candidates); - sp_new->name = ap_pstrdup(r->pool, fname); + sp_new->name = fname; sp_new->quality = q; } @@ -389,13 +385,12 @@ static int check_speling(request_rec *r) misspelled_file *sp_new; sp_new = (misspelled_file *) ap_push_array(candidates); - sp_new->name = ap_pstrdup(r->pool, fname); + sp_new->name = fname; sp_new->quality = SP_VERYDIFFERENT; } #endif } } - ap_closedir(dir); if (candidates->nelts != 0) {