subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1848997 - in /subversion/trunk/subversion: include/svn_dirent_uri.h libsvn_subr/dirent_uri.c
Date Sat, 15 Dec 2018 14:09:14 GMT
Author: brane
Date: Sat Dec 15 14:09:13 2018
New Revision: 1848997

URL: http://svn.apache.org/viewvc?rev=1848997&view=rev
Log:
Add a safe variant of svn_dirent_internal_style().

* subversion/include/svn_dirent_uri.h
  (svn_dirent_internal_style): Update docstring, pointing to ...
  (svn_dirent_internal_style_safe): ... this new prototype.

* subversion/libsvn_subr/dirent_uri.c
  (svn_dirent_internal_style_safe): Implement.

Modified:
    subversion/trunk/subversion/include/svn_dirent_uri.h
    subversion/trunk/subversion/libsvn_subr/dirent_uri.c

Modified: subversion/trunk/subversion/include/svn_dirent_uri.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_dirent_uri.h?rev=1848997&r1=1848996&r2=1848997&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_dirent_uri.h (original)
+++ subversion/trunk/subversion/include/svn_dirent_uri.h Sat Dec 15 14:09:13 2018
@@ -147,17 +147,47 @@ extern "C" {
 #endif /* __cplusplus */
 
 
-/** Convert @a dirent from the local style to the canonical internal style.
+/**
+ * Convert @a dirent from the local style to the canonical internal style.
  * "Local style" means native path separators and "." for the empty path.
  *
  * Allocate the result in @a result_pool.
  *
+ * @warning This function may call @c abort() if the @a dirent parameter
+ *          is not a valid local-style path.
+ *          Use svn_dirent_internal_style_safe() for tainted input.
+ *
  * @since New in 1.6.
  */
 const char *
 svn_dirent_internal_style(const char *dirent,
                           apr_pool_t *result_pool);
 
+/**
+ * Convert @a dirent from the local style to the canonical internal style
+ * and return it in @a *internal_style_dirent. "Local style" means native
+ * path separators and "." for the empty path.
+ *
+ * Similar to svn_dirent_internal_style() (which see), but returns an error
+ * if the @a dirent can not be canonicalized or of the result does not pass
+ * the svn_dirent_is_canonical() test.
+ *
+ * If the function fails and @a non_canonical_result is not @c NULL, the
+ * result of the failed canonicalization attempt (which may be @c NULL)
+ * will be returned in @a *non_canonical_result.
+ *
+ * Allocates the results in @a result_pool. Uses @a scratch_pool for
+ * temporary allocations.
+ *
+ * @since New in 1.12.
+ */
+svn_error_t *
+svn_dirent_internal_style_safe(const char **internal_style_dirent,
+                               const char **non_canonical_result,
+                               const char *dirent,
+                               apr_pool_t *result_pool,
+                               apr_pool_t *scratch_pool);
+
 /** Convert @a dirent from the internal style to the local style.
  * "Local style" means native path separators and "." for the empty path.
  * If the input is not canonical, the output may not be canonical.

Modified: subversion/trunk/subversion/libsvn_subr/dirent_uri.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/dirent_uri.c?rev=1848997&r1=1848996&r2=1848997&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/trunk/subversion/libsvn_subr/dirent_uri.c Sat Dec 15 14:09:13 2018
@@ -897,6 +897,20 @@ svn_dirent_internal_style(const char *di
   return svn_dirent_canonicalize(internal_style(dirent, pool), pool);
 }
 
+svn_error_t *
+svn_dirent_internal_style_safe(const char **internal_style_dirent,
+                               const char **non_canonical_result,
+                               const char *dirent,
+                               apr_pool_t *result_pool,
+                               apr_pool_t *scratch_pool)
+{
+  return svn_error_trace(
+      svn_dirent_canonicalize_safe(internal_style_dirent,
+                                   non_canonical_result,
+                                   internal_style(dirent, scratch_pool),
+                                   result_pool, scratch_pool));
+}
+
 const char *
 svn_dirent_local_style(const char *dirent, apr_pool_t *pool)
 {



Mime
View raw message