subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phi...@apache.org
Subject svn commit: r1636393 - in /subversion/branches/svn-auth-x509/subversion/libsvn_subr: x509info.c x509parse.c
Date Mon, 03 Nov 2014 17:02:00 GMT
Author: philip
Date: Mon Nov  3 17:01:59 2014
New Revision: 1636393

URL: http://svn.apache.org/r1636393
Log:
On svn-auth-x509 branch: avoid using svn_stringbuf_t/svn_string_t in
APIs that generate nul-terminated C strings.

* subversion/libsvn_subr/x509parse.c
  (fuzzy_escape, nul_escape, x509name_to_utf8_string): Change return type.
  (asn1_oid_to_string): Change parameter type.
  (x509_name_to_certinfo, x509parse_get_hostnames): Change variable type.

* subversion/libsvn_subr/x509info.c
  (deep_copy_array, deep_copy_hash): Add comments.

Modified:
    subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509info.c
    subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c

Modified: subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509info.c
URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509info.c?rev=1636393&r1=1636392&r2=1636393&view=diff
==============================================================================
--- subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509info.c (original)
+++ subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509info.c Mon Nov  3 17:01:59
2014
@@ -34,6 +34,7 @@
 
 
 
+/* Array elements are assumed to be nul-terminated C strings. */
 static apr_array_header_t *
 deep_copy_array(apr_array_header_t *s, apr_pool_t *result_pool)
 {
@@ -55,6 +56,7 @@ deep_copy_array(apr_array_header_t *s, a
   return d;
 }
 
+/* Hash key and value are assumed to be nul-terminated C strings. */
 static apr_hash_t *deep_copy_hash(apr_hash_t *s,
                                   apr_pool_t *scratch_pool, 
                                   apr_pool_t *result_pool)

Modified: subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c
URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c?rev=1636393&r1=1636392&r2=1636393&view=diff
==============================================================================
--- subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c (original)
+++ subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c Mon Nov  3 17:01:59
2014
@@ -686,8 +686,8 @@ x509_get_ext(apr_array_header_t *dnsname
  * All of the encoding formats somewhat overlap with ascii (BMPString
  * and UniversalString are actually always wider so you'll end up
  * with a bunch of escaped nul bytes, but ideally we don't get here
- * for those). */
-static const svn_string_t *
+ * for those).  The result is always a nul-terminated C string. */
+static const char *
 fuzzy_escape(const svn_string_t *src, apr_pool_t *result_pool)
 {
   const char *end = src->data + src->len;
@@ -702,7 +702,7 @@ fuzzy_escape(const svn_string_t *src, ap
     }
 
   if (q == end)
-    return src;
+    return src->data;
 
   outstr = svn_stringbuf_create_empty(result_pool);
   while (1)
@@ -726,12 +726,12 @@ fuzzy_escape(const svn_string_t *src, ap
       p = q + 1;
     }
 
-  return svn_stringbuf__morph_into_string(outstr);
+  return outstr->data;
 }
 
 /* Escape only NUL characters from a string that is presumed to
- * be UTF-8 encoded. */
-static const svn_string_t *
+ * be UTF-8 encoded and return a nul-terminated C string. */
+static const char *
 nul_escape(const svn_string_t *src, apr_pool_t *result_pool)
 {
   const char *end = src->data + src->len;
@@ -745,7 +745,7 @@ nul_escape(const svn_string_t *src, apr_
     }
 
   if (q == end)
-    return src;
+    return src->data;
 
   outstr = svn_stringbuf_create_empty(result_pool);
   while (1)
@@ -767,7 +767,7 @@ nul_escape(const svn_string_t *src, apr_
       p = q + 1;
     }
 
-  return svn_stringbuf__morph_into_string(outstr);
+  return outstr->data;
 }
 
 
@@ -801,7 +801,7 @@ latin1_to_utf8(const svn_string_t **resu
 /* Make a best effort to convert a X.509 name to a UTF-8 encoded
  * string and return it.  If we can't properly convert just do a
  * fuzzy conversion so we have something to display. */
-static const svn_string_t *
+static const char *
 x509name_to_utf8_string(const x509_name *name, apr_pool_t *result_pool)
 {
   const svn_string_t *src_string;
@@ -879,11 +879,11 @@ x509name_to_utf8_string(const x509_name 
   return nul_escape(utf8_string, result_pool);
 }
 
-/* Given an OID return a string representation in RESULT.
+/* Given an OID return a null-terminated C string representation in *RESULT.
  * For example an OID with the bytes "\x2A\x86\x48\x86\xF7\x0D\x01\x09\x01"
  * would be converted to the string "1.2.840.113549.1.9.1". */
 static svn_error_t *
-asn1_oid_to_string(svn_stringbuf_t **result, const x509_buf *oid,
+asn1_oid_to_string(const char **result, const x509_buf *oid,
                    apr_pool_t *scratch_pool, apr_pool_t *result_pool)
 {
   svn_stringbuf_t *out = svn_stringbuf_create_empty(result_pool);
@@ -934,7 +934,7 @@ asn1_oid_to_string(svn_stringbuf_t **res
     svn_stringbuf_appendcstr(out, temp);
   }
 
-  *result = out;
+  *result = out->data;
   return SVN_NO_ERROR;
 }
 
@@ -951,18 +951,18 @@ x509_name_to_certinfo(apr_array_header_t
   *hash = apr_hash_make(result_pool);
 
   while (name != NULL) {
-    svn_stringbuf_t *oid_string;
-    const svn_string_t *utf8_value;
+    const char *oid_string;
+    const char *utf8_value;
 
     SVN_ERR(asn1_oid_to_string(&oid_string, &name->oid,
                                scratch_pool, result_pool));
-    APR_ARRAY_PUSH(*oids, const char *) = oid_string->data;
+    APR_ARRAY_PUSH(*oids, const char *) = oid_string;
     utf8_value = x509name_to_utf8_string(name, result_pool);
     if (utf8_value)
-      svn_hash_sets(*hash, oid_string->data, utf8_value->data);
+      svn_hash_sets(*hash, oid_string, utf8_value);
     else
       /* this should never happen */
-      svn_hash_sets(*hash, oid_string->data, "??");
+      svn_hash_sets(*hash, oid_string, "??");
 
     name = name->next;
   }
@@ -1025,8 +1025,8 @@ x509parse_get_hostnames(svn_x509_certinf
                                                         dnsname->len,
                                                         scratch_pool);
 
-          temp = fuzzy_escape(temp, result_pool);
-          APR_ARRAY_PUSH(ci->hostnames, const char*) = temp->data;
+          APR_ARRAY_PUSH(ci->hostnames, const char*)
+            = fuzzy_escape(temp, result_pool);
         }
     }
   else



Mime
View raw message