[mirrorbrain-commits] r8388 - /trunk/mod_mirrorbrain/mod_mirrorbrain.c

From: <poeml_at_mirrorbrain.org>
Date: Fri, 07 Feb 2014 00:00:09 -0000
Author: poeml
Date: Fri Feb  7 01:00:09 2014
New Revision: 8388

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8388&view=rev
Log:
mod_mirrorbrain:
- For the base directory of the file tree, and for every request on a file
  (URL), realpath() is used to resolve the path to contain no symlinks.
  realpath() can be used in two ways, on most platforms, but on Solaris 10 the
  second argument must not be NULL. Thus, we now supply a preallocated memory
  buffer now (which should work on the other platforms as well). (issue #145)
  Thanks a lot for spotting and analysing this, Dago!

Modified:
    trunk/mod_mirrorbrain/mod_mirrorbrain.c

Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mod_mirrorbrain/mod_mirrorbrain.c?rev=8388&r1=8387&r2=8388&view=diff
==============================================================================
--- trunk/mod_mirrorbrain/mod_mirrorbrain.c	(original)
+++ trunk/mod_mirrorbrain/mod_mirrorbrain.c	Fri Feb  7 01:00:09 2014
_at_@ -1839,17 +1839,16 @@
 
     /* The basedir might contain symlinks. That needs to be taken into account. 
      * See discussion in http://mirrorbrain.org/issues/issue17 */
-    ptr = realpath(cfg->mirror_base, NULL);
+    ptr = realpath(cfg->mirror_base, apr_palloc(r->pool, APR_PATH_MAX));
     if (ptr == NULL) {
         /* this should never happen, because the MirrorBrainEngine directive would never
-         * be applied to a non-existing directories */
+         * be applied to a non-existing directory */
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, 
                 "[mod_mirrorbrain] Document root \'%s\' does not seem to "
                 "exist. Filesystem not mounted?", cfg->mirror_base);
         return HTTP_INTERNAL_SERVER_ERROR;
     }
-    mirror_base = apr_pstrdup(r->pool, ptr);
-    free(ptr);
+    mirror_base = ptr;
 
     /* prepare the filename to look up */
     if (rep != YUMLIST) {
_at_@ -1859,7 +1858,7 @@
         debugLog(r, cfg, "yum path on disk: %s", filename);
     }
 
-    ptr = realpath(filename, NULL);
+    ptr = realpath(filename, apr_palloc(r->pool, APR_PATH_MAX));
     if (ptr == NULL) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, 
                 "[mod_mirrorbrain] Error canonicalizing filename '%s'", filename);
_at_@ -1867,9 +1866,8 @@
         return HTTP_NOT_FOUND;
     }
 
-    realfile = apr_pstrdup(r->pool, ptr);
+    realfile = ptr;
     debugLog(r, cfg, "Canonicalized file on disk: %s", realfile);
-    free(ptr);
 
     /* the leading directory needs to be stripped from the file path */
     /* a directory from Apache always ends in '/'; a result from realpath() doesn't */




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Fri Feb 07 2014 - 00:00:10 GMT

This archive was generated by hypermail 2.3.0 : Fri Feb 07 2014 - 00:17:03 GMT