subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1603879 - in /subversion/branches/svn-auth-x509/subversion/libsvn_subr: x509.h x509parse.c
Date Thu, 19 Jun 2014 13:46:41 GMT
Author: stsp
Date: Thu Jun 19 13:46:41 2014
New Revision: 1603879

URL: http://svn.apache.org/r1603879
Log:
On the svn-auth-x590 branch, constify pointers used within cert parser code.
Also fix some quirks in use of unsigned types.

* subversion/libsvn_subr/x509.h
  (x509_buf): The 'p' pointer in here needs 'const'.
  (svn_x509_parse_cert): Remove 'unsigned' from the char * in this API.
   'unsigned' types are used because an ASN1 constant has the high bit set and
   is used in logical comparisons. We'll hide this quirk inside the parser.

* subversion/libsvn_subr/x509parse.c
  (asn1_get_len, asn1_get_tag, asn1_get_int, x509_get_version,
   x509_get_serial, x509_get_alg, x509_get_name, x509_get_dates,
   x509_get_sig, x509_get_uid): Add 'const'.
  (svn_x509_parse_cert): Remove 'unsigned' from input argument.
   Internally cast the pointer to 'unsigned' instead.

Suggested by: breser

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

Modified: subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509.h
URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509.h?rev=1603879&r1=1603878&r2=1603879&view=diff
==============================================================================
--- subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509.h (original)
+++ subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509.h Thu Jun 19 13:46:41 2014
@@ -125,7 +125,7 @@
 typedef struct _x509_buf {
   int tag;
   int len;
-  unsigned char *p;
+  const unsigned char *p;
 } x509_buf;
 
 typedef struct _x509_name {
@@ -176,7 +176,7 @@ extern "C" {
   /* Parse x509 DER certificate data from BUF (with length BUFLEN),
    * returning a structured representation in *CERT, allocated in RESULT_POOL. */
   int svn_x509_parse_cert(x509_cert **cert,
-                          unsigned char *buf,
+                          const char *buf,
                           int buflen,
                           apr_pool_t *result_pool,
                           apr_pool_t *scratch_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=1603879&r1=1603878&r2=1603879&view=diff
==============================================================================
--- subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c (original)
+++ subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c Thu Jun 19 13:46:41
2014
@@ -56,7 +56,7 @@
 /*
  * ASN.1 DER decoding routines
  */
-static int asn1_get_len(unsigned char **p, const unsigned char *end, int *len)
+static int asn1_get_len(const unsigned char **p, const unsigned char *end, int *len)
 {
   if ((end - *p) < 1)
     return (TROPICSSL_ERR_ASN1_OUT_OF_DATA);
@@ -93,7 +93,7 @@ static int asn1_get_len(unsigned char **
   return (0);
 }
 
-static int asn1_get_tag(unsigned char **p,
+static int asn1_get_tag(const unsigned char **p,
       const unsigned char *end, int *len, int tag)
 {
   if ((end - *p) < 1)
@@ -107,7 +107,7 @@ static int asn1_get_tag(unsigned char **
   return (asn1_get_len(p, end, len));
 }
 
-static int asn1_get_int(unsigned char **p, const unsigned char *end, int *val)
+static int asn1_get_int(const unsigned char **p, const unsigned char *end, int *val)
 {
   int ret, len;
 
@@ -130,7 +130,7 @@ static int asn1_get_int(unsigned char **
 /*
  *  Version   ::=  INTEGER  {  v1(0), v2(1), v3(2)  }
  */
-static int x509_get_version(unsigned char **p, const unsigned char *end, int *ver)
+static int x509_get_version(const unsigned char **p, const unsigned char *end, int *ver)
 {
   int ret, len;
 
@@ -158,7 +158,7 @@ static int x509_get_version(unsigned cha
 /*
  *  CertificateSerialNumber   ::=  INTEGER
  */
-static int x509_get_serial(unsigned char **p,
+static int x509_get_serial(const unsigned char **p,
          const unsigned char *end, x509_buf * serial)
 {
   int ret;
@@ -188,7 +188,7 @@ static int x509_get_serial(unsigned char
  *     algorithm         OBJECT IDENTIFIER,
  *     parameters         ANY DEFINED BY algorithm OPTIONAL  }
  */
-static int x509_get_alg(unsigned char **p, const unsigned char *end, x509_buf * alg)
+static int x509_get_alg(const unsigned char **p, const unsigned char *end, x509_buf * alg)
 {
   int ret, len;
 
@@ -233,7 +233,7 @@ static int x509_get_alg(unsigned char **
  *
  *  AttributeValue ::= ANY DEFINED BY AttributeType
  */
-static int x509_get_name(unsigned char **p, const unsigned char *end, x509_name * cur)
+static int x509_get_name(const unsigned char **p, const unsigned char *end, x509_name * cur)
 {
   int ret, len;
   const unsigned char *end2;
@@ -312,7 +312,7 @@ static int x509_get_name(unsigned char *
  *     utcTime    UTCTime,
  *     generalTime  GeneralizedTime }
  */
-static int x509_get_dates(unsigned char **p,
+static int x509_get_dates(const unsigned char **p,
         const unsigned char *end, x509_time * from, x509_time * to)
 {
   int ret, len;
@@ -368,7 +368,7 @@ static int x509_get_dates(unsigned char 
   return (0);
 }
 
-static int x509_get_sig(unsigned char **p, const unsigned char *end, x509_buf * sig)
+static int x509_get_sig(const unsigned char **p, const unsigned char *end, x509_buf * sig)
 {
   int ret, len;
 
@@ -391,7 +391,7 @@ static int x509_get_sig(unsigned char **
 /*
  * X.509 v2/v3 unique identifier (not parsed)
  */
-static int x509_get_uid(unsigned char **p,
+static int x509_get_uid(const unsigned char **p,
       const unsigned char *end, x509_buf * uid, int n)
 {
   int ret;
@@ -421,18 +421,18 @@ static int x509_get_uid(unsigned char **
  */
 int
 svn_x509_parse_cert(x509_cert **cert,
-                    unsigned char *buf,
+                    const char *buf,
                     int buflen,
                     apr_pool_t *result_pool,
                     apr_pool_t *scratch_pool)
 {
   int ret, len;
-  unsigned char *p;
+  const unsigned char *p;
   const unsigned char *end;
   x509_cert *crt;
 
   crt = apr_pcalloc(result_pool, sizeof(*crt));
-  p = buf;
+  p = (const unsigned char *)buf;
   len = buflen;
   end = p + len;
 



Mime
View raw message