You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ja...@apache.org on 2014/04/24 08:29:28 UTC

svn commit: r1589599 - in /httpd/httpd/trunk: include/httpd.h server/util.c

Author: jailletc36
Date: Thu Apr 24 06:29:28 2014
New Revision: 1589599

URL: http://svn.apache.org/r1589599
Log:
Follow up to r1384924 .

Update comment and allocate one extra byte to be safe, even if not needed in the particular case described in r1384924.

Modified:
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/server/util.c

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=1589599&r1=1589598&r2=1589599&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Thu Apr 24 06:29:28 2014
@@ -1669,9 +1669,8 @@ AP_DECLARE(char *) ap_escape_path_segmen
  * @param path The path to convert
  * @param partial if set, assume that the path will be appended to something
  *        with a '/' in it (and thus does not prefix "./").
- *        If not set, there will be one byte of additional space after the
- *        NUL, to allow the caller to append a '/'.
- * @return The converted URL
+ * @return The converted URL, with one byte of extra space after the NUL
+ *         to allow the caller to add a trailing '/'. 
  * @deprecated Replaced by apr_pescape_path() in APR
  */
 AP_DECLARE(char *) ap_os_escape_path(apr_pool_t *p, const char *path, int partial)

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1589599&r1=1589598&r2=1589599&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Thu Apr 24 06:29:28 2014
@@ -1801,7 +1801,11 @@ AP_DECLARE(char *) ap_escape_path_segmen
 
 AP_DECLARE(char *) ap_os_escape_path(apr_pool_t *p, const char *path, int partial)
 {
-    char *copy = apr_palloc(p, 3 * strlen(path) + 3);
+    /* Allocate +3 for potential "./" and trailing NULL.
+     * Allocate another +1 to allow the caller to add a trailing '/' (see
+     * comment in 'ap_sub_req_lookup_dirent')
+     */
+    char *copy = apr_palloc(p, 3 * strlen(path) + 3 + 1);
     const unsigned char *s = (const unsigned char *)path;
     unsigned char *d = (unsigned char *)copy;
     unsigned c;